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
90
Composite Chart with BoxChart and LineChart
posted

I am attempting to create a chart that has a line connection to the mean points of a box chart in the example provided below. 

I have created a composite chart with two layers (BoxChart, and LineChart).  BoxChart uses the X_Axis, "ContinuousData", and the Y_Axis, "GroupBySeries", with a BoxSetSeries bound datatable. 

The LineChart uses the X2_Axis, "ContinuousData", and shares the before mentioned Y_Axis, "GroupBySeries", with a NumericSeries bound datatable.

First, the linechart refuses to acknowledge a datatable of the example format:

"Line1", 1, 2, 3, 4, 5

"Line2", 2, 3, 4, 5, 6

According to the Infragistics WebChart.pdf, the chart should use the first string column as labels and the first numerical value as point1, second numerical value as point2, and so forth.  This will not render, nor are any errors thrown.

Even when I can get the linechart to render using a points collection or a different datatable format in cooperation with multiple series, the points will not plot in the same "columns" as the BoxChart because of the LineChart's  X2_Axis.SetLabelAxisType = "Continuous".

Please let me know if this is even possible using the 2008 vol 3 infragistics controls.

Thank you.

Parents
  • 26458
    Offline posted

    Here's an example of using box and line charts in a composite chart:

    DataTable chartData = new DataTable();
    chartData.Columns.Add("Name", typeof(string));
    chartData.Columns.Add("Min", typeof(double));
    chartData.Columns.Add("Max", typeof(double));
    chartData.Columns.Add("Q1", typeof(double));
    chartData.Columns.Add("Q2", typeof(double));
    chartData.Columns.Add("Q3", typeof(double));

    chartData.Rows.Add(new object[] { "item1", 5, 20, 7, 10, 12 });
    chartData.Rows.Add(new object[] { "item2", 4, 25, 6, 16, 20 });
    chartData.Rows.Add(new object[] { "item3", 2, 10, 3, 5, 7 });
    chartData.Rows.Add(new object[] { "item4", 7, 30, 12, 20, 25 });
    chartData.Rows.Add(new object[] { "item5", 5, 25, 8, 12, 21 });

    BoxSetSeries boxSeries = new BoxSetSeries();
    boxSeries.Data.DataSource = chartData;
    boxSeries.Data.LabelColumn = "Name";
    boxSeries.Data.MinColumn = "Min";
    boxSeries.Data.MaxColumn = "Max";
    boxSeries.Data.Q1Column = "Q1";
    boxSeries.Data.Q2Column = "Q2";
    boxSeries.Data.Q3Column = "Q3";
    boxSeries.DataBind();

    NumericSeries lineSeries = new NumericSeries();
    lineSeries.Data.DataSource = chartData;
    lineSeries.Data.LabelColumn = "Name";
    lineSeries.Data.ValueColumn = "Q2";
    lineSeries.DataBind();

    ultraChart1.ChartType = ChartType.Composite;

    ultraChart1.CompositeChart.Series.Add(boxSeries);
    ultraChart1.CompositeChart.Series.Add(lineSeries);

    ChartArea area = new ChartArea();
    ultraChart1.CompositeChart.ChartAreas.Add(area);

    AxisItem xAxisBox = new AxisItem(ultraChart1, AxisNumber.X_Axis);
    xAxisBox.DataType = AxisDataType.String;
    xAxisBox.SetLabelAxisType = SetLabelAxisType.ContinuousData;

    AxisItem xAxisLine = new AxisItem(ultraChart1, AxisNumber.X_Axis);
    xAxisLine.DataType = AxisDataType.String;
    xAxisLine.SetLabelAxisType = SetLabelAxisType.ContinuousData;
    xAxisLine.Margin.Near.MarginType = LocationType.RowColumn;
    xAxisLine.Margin.Near.Value = .4;
    xAxisLine.Margin.Far.MarginType = LocationType.RowColumn;
    xAxisLine.Margin.Far.Value = .4;

    AxisItem yAxis = new AxisItem(ultraChart1, AxisNumber.Y_Axis);
    yAxis.DataType = AxisDataType.Numeric;

    area.Axes.Add(xAxisBox);
    area.Axes.Add(xAxisLine);
    area.Axes.Add(yAxis);

    ChartLayerAppearance boxLayer = new ChartLayerAppearance();
    boxLayer.ChartArea = area;
    boxLayer.AxisX = xAxisBox;
    boxLayer.AxisY = yAxis;
    boxLayer.ChartType = ChartType.BoxChart;

    ChartLayerAppearance lineLayer = new ChartLayerAppearance();
    lineLayer.ChartArea = area;
    lineLayer.AxisX = xAxisLine;
    lineLayer.AxisY = yAxis;
    lineLayer.ChartType = ChartType.LineChart;

    boxLayer.Series.Add(boxSeries);
    lineLayer.Series.Add(lineSeries);

    ultraChart1.CompositeChart.ChartLayers.Add(boxLayer);
    ultraChart1.CompositeChart.ChartLayers.Add(lineLayer);

Reply Children
No Data