Skip to main content
A newer version of this page is available. .

StackedBarSeriesView() Constructor

Initializes a new instance of the StackedBarSeriesView class with the default settings.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v18.2.dll

Declaration

public StackedBarSeriesView()

Example

The following example demonstrates how to create a ChartControl with two series of the StackedBarSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, first create a Windows Forms Application in Visual Studio, and include all necessary assemblies to the References list of your project.

Then, add the following code to the Form.Load event handler.

using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

private void Form1_Load(object sender, EventArgs e) {
    // Create a new chart.
    ChartControl stackedBarChart = new ChartControl();

    // Create two stacked bar series.
    Series series1 = new Series("Series 1", ViewType.StackedBar);
    Series series2 = new Series("Series 2", ViewType.StackedBar);

    // Add points to them
    series1.Points.Add(new SeriesPoint("A", 10));
    series1.Points.Add(new SeriesPoint("B", 12));
    series1.Points.Add(new SeriesPoint("C", 14));
    series1.Points.Add(new SeriesPoint("D", 17));

    series2.Points.Add(new SeriesPoint("A", 15));
    series2.Points.Add(new SeriesPoint("B", 18));
    series2.Points.Add(new SeriesPoint("C", 25));
    series2.Points.Add(new SeriesPoint("D", 33));

    // Add both series to the chart.
    stackedBarChart.Series.AddRange(new Series[] { series1, series2 });

    // Access the view-type-specific options of the series.
    ((StackedBarSeriesView)series1.View).BarWidth = 0.8;

    // Access the type-specific options of the diagram.
    ((XYDiagram)stackedBarChart.Diagram).EnableAxisXZooming = true;

    // Hide the legend (if necessary).
    stackedBarChart.Legend.Visible = false;

    // Add a title to the chart (if necessary).
    stackedBarChart.Titles.Add(new ChartTitle());
    stackedBarChart.Titles[0].Text = "A Stacked Bar Chart";

    // Add the chart to the form.
    stackedBarChart.Dock = DockStyle.Fill;
    this.Controls.Add(stackedBarChart);
}
See Also