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
220
Composite Chart data values (column/line)
posted

In following the steps given on the web site below, I am able to generate a chart, but only with the axis value I entered in the wizard, but I am wanting to use the values from a data source. I must be missing something very simple. I have added a data source, but values not there. Help please?

http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Chart_Creating_a_Composite_Chart_Using_the_Chart_Wizard_Part_1_of_2.html

http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Chart_Creating_a_Composite_Chart_Using_the_Chart_Wizard_Part_2_of_2.html

Parents Reply
  • 310
    posted in reply to Max Rivlin [Infragistics]

    Hey Max,

    THanks so much for your help - just a few more issues that i cannot seem to get the syntext for: the graph doubles the series and i can not duplicate the formatting on the series lables on the original graph. THis is how it displays with the code below. and the original is in the post before this one - thanks again for your help

     

    DataTable table = new DataTable();
    table.Columns.Add("Fiscal_Month", typeof(string));
    table.Columns.Add("2007", typeof(double));
    table.Columns.Add("2008", typeof(double));
    table.Columns.Add("2009", typeof(double));
    table.Rows.Add(new object[] { "1", 588426.7373,623701.4100, 628932.2500 });
    table.Rows.Add(new object[] { "2", 441615.3699, 660547.8900, 589465.1700 });
    table.Rows.Add(new object[] { "3", 458654.3890, 651692.2200, 642681.8500 });
    table.Rows.Add(new object[] { "4", 444097.9300, 589707.9100, 579662.1300 });
    table.Rows.Add(new object[] { "5", 451595.6100, 576037.4300, 56223.9600});
    table.Rows.Add(new object[] { "6", 495655.3500, 617554.8500, null});
    table.Rows.Add(new object[] { "7", 592918.8000, 589333.0800, null });
    table.Rows.Add(new object[] { "8", 671417.1600, 655549.2800, null });
    table.Rows.Add(new object[] { "9", 696396.9100, 719232.4900, null });
    table.Rows.Add(new object[] { "10", 718624.1000, 782330.6300, null });
    table.Rows.Add(new object[] { "11", 778600.8200, 679905.9000, null });
    table.Rows.Add(new object[] { "12", 711886.9200, 642694.0000, null });

    DataTable budgetTable = new DataTable();
    budgetTable.Columns.Add("Fiscal_Month", typeof(string));
    budgetTable.Columns.Add("08", typeof(double));
    budgetTable.Columns.Add("09", typeof(double));
    table.Rows.Add(new object[] { "1", 588426.7373, 623701.4100 });
    table.Rows.Add(new object[] { "2", 441615.3699, 660547.8900 });
    table.Rows.Add(new object[] { "3", 458654.3890, 651692.2200 });
    table.Rows.Add(new object[] { "4", 444097.9300, 589707.9100 });
    table.Rows.Add(new object[] { "5", 451595.6100, 576037.4300 });
    table.Rows.Add(new object[] { "6", 495655.3500, 617554.8500 });
    table.Rows.Add(new object[] { "7", 592918.8000, 589333.0800 });
    table.Rows.Add(new object[] { "8", 671417.1600, 655549.2800 });
    table.Rows.Add(new object[] { "9", 696396.9100, 719232.4900 });
    table.Rows.Add(new object[] { "10", 718624.1000, 782330.6300 });
    table.Rows.Add(new object[] { "11", 778600.8200, 679905.9000 });
    table.Rows.Add(new object[] { "12", 711886.9200, 642694.0000 });

    this.BudgetLineGraph.ChartType = ChartType.Composite;
    ChartArea myChartArea = new ChartArea();
    this.BudgetLineGraph.CompositeChart.ChartAreas.Add(myChartArea);

     

    // column layers use a string, GroupBySeries x axis

    AxisItem xAxisColumn = new AxisItem(BudgetLineGraph, AxisNumber.X_Axis);
    xAxisColumn.DataType = AxisDataType.String;
    xAxisColumn.SetLabelAxisType = SetLabelAxisType.GroupBySeries;

    xAxisColumn.Labels.ItemFormatString = "<ITEM_LABEL>";
    xAxisColumn.Labels.SeriesLabels.Format = AxisSeriesLabelFormat.SeriesLabel;
    xAxisColumn.Labels.SeriesLabels.FormatString = "Fiscal\nMonth\n<SERIES_LABEL>";
    xAxisColumn.LineThickness = 1;
    myChartArea.Axes.Add(xAxisColumn);

    //line layers use a string, ContinuousData x axis

    AxisItem xAxisLine = new AxisItem(BudgetLineGraph, AxisNumber.X_Axis);
    xAxisLine.DataType = AxisDataType.String;

    // xAxisLine.SetLabelAxisType = SetLabelAxisType.GroupBySeries;

    xAxisLine.LineThickness = 1;
    myChartArea.Axes.Add(xAxisLine);

    //the layers will share the numeric y axis.

    AxisItem yAxis = new AxisItem(BudgetLineGraph, AxisNumber.Y_Axis);
    yAxis.DataType = AxisDataType.Numeric;
    yAxis.Labels.ItemFormat = AxisItemLabelFormat.DataValue;
    yAxis.Labels.ItemFormatString = "<DATA_VALUE:00.##>";
    yAxis.LineThickness = 1;
    myChartArea.Axes.Add(yAxis);

    NumericSeries seriesColumn1 = new NumericSeries();
    seriesColumn1.Data.DataSource = table;
    seriesColumn1.Data.LabelColumn = "Fiscal_Month";
    seriesColumn1.Data.ValueColumn = "2007";
    BudgetLineGraph.CompositeChart.Series.Add(seriesColumn1);

    NumericSeries seriesColumn2 = new NumericSeries();
    seriesColumn2.Data.DataSource = table;
    seriesColumn2.Data.LabelColumn = "Fiscal_Month";
    seriesColumn2.Data.ValueColumn = "2008";
    BudgetLineGraph.CompositeChart.Series.Add(seriesColumn2);

    NumericSeries seriesColumn3 = new NumericSeries();
    seriesColumn3.Data.DataSource = table;
    seriesColumn3.Data.LabelColumn = "Fiscal_Month";
    seriesColumn3.Data.ValueColumn = "2009";
    BudgetLineGraph.CompositeChart.Series.Add(seriesColumn3);

    NumericSeries seriesLine1 = new NumericSeries();
    seriesLine1.Data.DataSource = budgetTable;
    seriesLine1.Data.LabelColumn = "Fiscal_Month";
    seriesLine1.Data.ValueColumn = "08";
    BudgetLineGraph.CompositeChart.Series.Add(seriesLine1);
    seriesLine1.PEs.Add(new PaintElement(Color.Red));

    NumericSeries seriesLine2 = new NumericSeries();
    seriesLine2.Data.DataSource = budgetTable;
    seriesLine2.Data.LabelColumn = "Fiscal_Month";
    seriesLine2.Data.ValueColumn = "09";
    BudgetLineGraph.CompositeChart.Series.Add(seriesLine2);
    seriesLine2.PEs.Add(new PaintElement(Color.Blue));

    ChartLayerAppearance columnLayer = new ChartLayerAppearance();
    columnLayer.AxisX = xAxisColumn;
    columnLayer.AxisY = yAxis;
    columnLayer.ChartArea = myChartArea;
    columnLayer.ChartType = ChartType.ColumnChart;
    columnLayer.Series.Add(seriesColumn1);
    columnLayer.Series.Add(seriesColumn2);
    columnLayer.Series.Add(seriesColumn3);
    columnLayer.SwapRowsAndColumns = true;
    BudgetLineGraph.CompositeChart.ChartLayers.Add(columnLayer);

    ChartLayerAppearance lineLayer = new ChartLayerAppearance();
    lineLayer.AxisX = xAxisLine;
    lineLayer.AxisY = yAxis;
    lineLayer.ChartArea = myChartArea;
    lineLayer.ChartType = ChartType.LineChart;
    lineLayer.Series.Add(seriesLine1);
    lineLayer.Series.Add(seriesLine2);
    BudgetLineGraph.CompositeChart.ChartLayers.Add(lineLayer);

Children