Skip to main content

Side-by-Side Full-Stacked Bar Chart

  • 3 minutes to read

Short Description

The Side-by-Side Full-Stacked Bar Chart is represented by the SideBySideFullStackedBarSeriesView object, which belongs to Bar and Column Series Views. This view combines the advantages of both the Full-Stacked Bar Chart and Side-by-Side Bar Chart chart types, so that you can stack different bars, and combine them into groups shown side-by-side across the same axis value (via the SideBySideFullStackedBarSeriesView.StackedGroup property).

Note

When you use series template binding for Side-by-Side Full-Stacked Bars, the SideBySideFullStackedBarSeriesView.StackedGroup property should be specified at runtime, in the WebChartControl.BoundDataChanged event handler.

A Side-by-Side Full-Stacked Bar chart is shown in the image below. Note that this chart type is based upon the XYDiagram, so it can be rotated to show bars either vertically or horizontally.

SeriesView_SideBySideFullStackedBar

Note

A Side-by-Side Full-Stacked Bar chart can display series that contain data points with positive or negative values. A series with positive values, however, is stacked only with other series that contain positive values; and a series with negative values is stacked with other series that contain negative values.

Note that if a series contains data points with both positive and negative values, it is treated as a series with positive values, while all its negative values are treated as zeros.

Chart Type Characteristics

The table below lists the main characteristics of this chart type.

Feature Value
Series View type SideBySideFullStackedBarSeriesView
Diagram type 2D-XYDiagram
Number of arguments per series point 1
Number of values per series point 1

Note

For information on which chart types can be combined with the Side-by-Side Full-Stacked Bar Chart, refer to the following help topic: Combining Different Series Views.

Example

The following example populates the Chart Control with series that have the SideBySideFullStackedBarSeriesView at runtime:

private void Form1_Load(object sender, EventArgs e) {
    ConfigureChartData();
    ConfigureChartDiagram();

    chartControl.BoundDataChanged += this.OnChartBoundDataChanged;
}

private void ConfigureChartData() {
    chartControl.DataSource = repository.GetAll();
    chartControl.SeriesTemplate.SeriesDataMember = "SeriesId";
    chartControl.SeriesTemplate.SetDataMembers("Country", "Value");
    chartControl.SeriesTemplate.View = new SideBySideFullStackedBarSeriesView();
}

private void ConfigureChartDiagram() {
    if (!(chartControl.Diagram is XYDiagram diagram)) return;
    diagram.Rotated = true;
    diagram.AxisY.Label.TextPattern = "{VP:P}";
    diagram.AxisY.WholeRange.AutoSideMargins = false;
    diagram.AxisY.WholeRange.SideMarginsValue = 0;
}

private void OnChartBoundDataChanged(object sender, EventArgs e) {
    if (chartControl.Series.Count == 0) return;

    foreach (Series series in chartControl.Series) {
        SetViewStackGroupByDataItem(series);
    }
}
private void SetViewStackGroupByDataItem(Series series) {
    if (series.Points.Count == 0) return;
    PopulationItem item = series.Points[0].Tag as PopulationItem;
    if (item == null) return;

    SideBySideFullStackedBarSeriesView view = series.View as SideBySideFullStackedBarSeriesView;
    if (view == null) return;

    // This property specifies the Id of the bar group in which the Chart Control displays series.
    view.StackedGroup = item.Sex;
}