Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
585
Stacked Barchart in Composite Chart
posted

Hello NG,

I want to use a Stacked Barchart within a Composite Chart. The second Chart should be a Linechart. I know I can use the Numericseries to fill data for a bar and a line chart but what class can i use for a stacked barchart to fill data for? Can anyone provide me a short codesample how to fill  a stacked barchart within a composite chart with data via code?

 Thanks in advance for your help.

 

Stefan

Parents
No Data
Reply
  • 26458
    Offline posted

    Using data series with stacked layers works exactly like using series with bar/column layers. The difference is only in rendering. All points within a series are stacked and each series represents a bar/column.

    NumericSeries s1 = new NumericSeries();
    s1.Points.Add(
    new NumericDataPoint(10, "p1", false));
    s1.Points.Add(
    new NumericDataPoint(20, "p2", false));
    s1.Points.Add(
    new NumericDataPoint(30, "p3", false));

    NumericSeries s2 = new NumericSeries();
    s2.Points.Add(
    new NumericDataPoint(10, "p1", false));
    s2.Points.Add(
    new NumericDataPoint(20, "p2", false));
    s2.Points.Add(
    new NumericDataPoint(30, "p3", false));

    this
    .ultraChart1.CompositeChart.Series.Add(s1);
    this.ultraChart1.CompositeChart.Series.Add(s2);

    ChartLayerAppearance layer = new ChartLayerAppearance();
    layer.ChartType =
    ChartType.StackBarChart;
    layer.AxisX =
    this.ultraChart1.CompositeChart.ChartAreas[0].Axes[0];
    layer.AxisY =
    this.ultraChart1.CompositeChart.ChartAreas[0].Axes[1];
    layer.ChartArea =
    this.ultraChart1.CompositeChart.ChartAreas[0];
    layer.Series.Add(s1);
    layer.Series.Add(s2);

    this.ultraChart1.CompositeChart.ChartLayers.Add(layer);


     

Children
No Data