Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Ultrachart – StackedBar Chart and Line Chart composites

Ultrachart – StackedBar Chart and Line Chart composites

New Discussion
Change
Change asked on Oct 8, 2008 8:17 PM

Hi There,

 

Has anyone got an example they are willing to share with a stacked bar chart together with line chart. I am new to Ultrachart and of course the first one I have to develop is quiete complicated.

 I can't find any tutorials or examples anywhere.

 Any help much appreciated.

 

Sign In to post a reply

Replies

  • 0
    David Negley
    David Negley answered on Sep 25, 2008 4:35 PM

    that is an unusual combination of charts because bar charts have a numeric x-axis and line charts have a numeric y-axis … but anyway, here's some code to get you started

     

    this.ultraChart1.ChartType = ChartType.Composite;

    NumericSeries stackSeries1 = new NumericSeries();
    stackSeries1.Label = "Stack One";
    stackSeries1.Points.Add(new NumericDataPoint(1.0, "A", false));
    stackSeries1.Points.Add(new NumericDataPoint(2.0, "B", false));
    stackSeries1.Points.Add(new NumericDataPoint(3.0, "C", false));

    NumericSeries stackSeries2 = new NumericSeries();
    stackSeries2.Label = "Stack Two";
    stackSeries2.Points.Add(new NumericDataPoint(4.0, "D", false));
    stackSeries2.Points.Add(new NumericDataPoint(5.0, "E", false));
    stackSeries2.Points.Add(new NumericDataPoint(6.0, "F", false));

    NumericSeries lineSeries1 = new NumericSeries();
    lineSeries1.Points.Add(new NumericDataPoint(7.0, "G", false));
    lineSeries1.Points.Add(new NumericDataPoint(8.0, "H", false));
    lineSeries1.Points.Add(new NumericDataPoint(9.0, "I", false));

    NumericSeries lineSeries2 = new NumericSeries();
    lineSeries2.Points.Add(new NumericDataPoint(8.0, "J", false));
    lineSeries2.Points.Add(new NumericDataPoint(7.0, "K", false));
    lineSeries2.Points.Add(new NumericDataPoint(6.0, "L", false));

    ChartArea area = new ChartArea();

    AxisItem xAxisForStackBar = new AxisItem();
    xAxisForStackBar.OrientationType = AxisNumber.X_Axis;
    xAxisForStackBar.DataType = AxisDataType.Numeric;
    xAxisForStackBar.Extent = 10;
    xAxisForStackBar.Labels.ItemFormatString = "<DATA_VALUE:0.0>";
    xAxisForStackBar.TickmarkStyle = AxisTickStyle.Smart;

    AxisItem yAxisForStackBar = new AxisItem();
    yAxisForStackBar.OrientationType = AxisNumber.Y_Axis;
    yAxisForStackBar.DataType = AxisDataType.String;
    yAxisForStackBar.SetLabelAxisType = SetLabelAxisType.GroupBySeries;
    yAxisForStackBar.Labels.SeriesLabels.FormatString = "<SERIES_LABEL>";

    AxisItem xAxisForLine = new AxisItem();
    xAxisForLine.OrientationType = AxisNumber.X_Axis;
    xAxisForLine.DataType = AxisDataType.String;
    xAxisForLine.SetLabelAxisType = SetLabelAxisType.ContinuousData;
    xAxisForLine.Labels.ItemFormatString = "<ITEM_LABEL>";

    AxisItem yAxisForLine = new AxisItem();
    yAxisForLine.OrientationType = AxisNumber.Y_Axis;
    yAxisForLine.DataType = AxisDataType.Numeric;
    yAxisForLine.Extent = 10;
    yAxisForLine.Labels.ItemFormatString = "<DATA_VALUE:0.0>";
    yAxisForLine.TickmarkStyle = AxisTickStyle.Smart;

    area.Axes.Add(xAxisForStackBar);
    area.Axes.Add(yAxisForStackBar);
    area.Axes.Add(xAxisForLine);
    area.Axes.Add(yAxisForLine);

    ChartLayerAppearance stackBarLayer = new ChartLayerAppearance();
    stackBarLayer.ChartType = ChartType.StackBarChart;
    stackBarLayer.Series.Add(stackSeries1);
    stackBarLayer.Series.Add(stackSeries2);
    stackBarLayer.ChartArea = area;
    stackBarLayer.AxisX = xAxisForStackBar;
    stackBarLayer.AxisY = yAxisForStackBar;

    ChartLayerAppearance lineLayer = new ChartLayerAppearance();
    lineLayer.ChartType = ChartType.LineChart;
    lineLayer.Series.Add(lineSeries1);
    lineLayer.Series.Add(lineSeries2);
    lineLayer.ChartArea = area;
    lineLayer.AxisX = xAxisForLine;
    lineLayer.AxisY = yAxisForLine;

    this.ultraChart1.CompositeChart.ChartAreas.Add(area);
    this.ultraChart1.CompositeChart.ChartLayers.Add(stackBarLayer);
    this.ultraChart1.CompositeChart.ChartLayers.Add(lineLayer);

     

    • 0
      Change
      Change answered on Oct 1, 2008 4:59 AM

      Thanks mate.

    • 0
      Change
      Change answered on Oct 2, 2008 1:34 AM

      Question mate!

       I'm grabing my data from a web service and attaching the datatable as the datasource for the stack series. Similarly with the line series.

       Now I'll only have one stack series and the table form is like as follows:

      With the Price columns I have actually named these as the actual price value, where the actual corresponding row value is the volume. Cause I wanna stack the actual 10 volumes and use the column headings in the legend to show what the actual price is. I did at one stage have price and volume as seperate columns but I think this way would be better.

      eg. price1 column heading is actually labelled 10 (dollars)

      Period, Price1 (10), Price2 (20), Price3 (30), ….., Price10 (100)

      1,  120, 60, 0, …., 30

      2, 100, 30, 10, ….., 20

      etc etc etc

      So, how can I stack price1 thru 10 for each period and use the actual column headings in the legend.

       I'll have about 6 line series layers and they are generally in the form of period, value, these will represent trend in volumes over the period and layered over the stack bar chart.

      Hope this makes some sense.

      This is an example of what I am trying to achieve.Example Chart

       

      • 0
        Change
        Change answered on Oct 2, 2008 8:15 AM

        Actually I have inadevrtly said a stackedbar chart above, this should actually be a StackColumnChart.

        I'm sorta getting abit further with this, I think my main problem is within the series for the stack data, I wasn;t setting a ValueColumn, look's like I need to but how do I do this for multiple values as per above table example?

        Maybe I don't do this as a series, but what else is available within a composite graph. Any examples or help would be greatly appreciated.

      • 0
        David Negley
        David Negley answered on Oct 8, 2008 8:17 PM

         each stack is represented by one NumericSeries, bound to one ValueColumn.  If you have multiple columns of data, you need to create multiple NumericSeries, one for each column.

        If the data appears "sideways," just toggle the SwapRowsAndColumns property on your chart layer.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Change
Favorites
0
Replies
5
Created On
Oct 08, 2008
Last Post
18 years ago

Suggested Discussions

Tags

Created by

Created on

Oct 8, 2008 8:17 PM

Last activity on

Oct 8, 2008 8:17 PM