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
I wanted to send some screen shots of what is going on. I want the data to come from a view in SQL 2005.
G'day Max
Currently i have a graph - see image - that is created from a query in a DAL and then 2 paramertors are passed - customer, and the other from a control on the page - this displays fine - however, i am now tyring it create it with a line graph on top - therefore using the composite graph - i am just haveing trouble getting the Numeric Series to see the datasource.
this.FiscalInputCostChart.ChartType = ChartType .Composite;
ChartArea myChartArea = new ChartArea();
this.FiscalInputCostChart.CompositeChart.ChartAreas.Add(myChartArea);
AxisItem axisX = new AxisItem();
axisX.OrientationType =
AxisNumber .X_Axis;
axisX.DataType =
AxisDataType.String;
axisX.SetLabelAxisType =
SetLabelAxisType .GroupBySeries;
axisX.Labels.ItemFormatString = "
Fiscal\nMonth\n<SERIES_LABEL>";
axisX.Labels.Orientation =
TextOrientation.VerticalLeftFacing;
AxisItem axisY = new AxisItem();
axisY.OrientationType =
AxisNumber.Y_Axis;
axisY.DataType =
AxisDataType.Numeric;
axisY.Labels.ItemFormatString =
"<DATA_VALUE:0.#>";
myChartArea.Axes.Add(axisX);
myChartArea.Axes.Add(axisY);
ChartLayerAppearance myColumnLayer = new ChartLayerAppearance();
myColumnLayer.ChartType =
ChartType.ColumnChart;
myColumnLayer.ChartArea = myChartArea;
myColumnLayer.AxisX = axisX;
myColumnLayer.AxisY = axisY;
//myColumnLayer.Series.Add(series);
NumericSeries seriesColumn1 = new NumericSeries();
seriesColumn1.Data.DataSource = odsInput;
seriesColumn1.Data.LabelColumn =
"Fiscal_Month";
seriesColumn1.Data.ValueColumn =
"2007";
NumericSeries seriesColumn2 = new NumericSeries();
seriesColumn2.Data.DataSource = odsInput;
seriesColumn2.Data.LabelColumn =
seriesColumn2.Data.ValueColumn =
"2008";
NumericSeries seriesColumn3 = new NumericSeries();
seriesColumn3.Data.DataSource = odsInput;
seriesColumn3.Data.LabelColumn =
seriesColumn3.Data.ValueColumn =
"2009";
Trying to get the data source this way
{
dt.Columns.Add(
"Fiscal_Month", typeof(string));
"2007", typeof(int));
"2008", typeof(int));
"2009", typeof(int));
I would really appreciate your direction on this.
Column and line layers use different type of x axis, so you need another x axis for the line layer.Here's a code snippet that should help you:
DataTable dt = new DataTable();dt.Columns.Add("2007", typeof(int));dt.Columns.Add("2008", typeof(int));dt.Columns.Add("label", typeof(string));dt.Rows.Add(new object[] { 10, 15, "Month1" });dt.Rows.Add(new object[] { 20, 25, "Month2" });dt.Rows.Add(new object[] { 30, 35, "Month3" });dt.Rows.Add(new object[] { 40, 45, "Month4" });dt.Rows.Add(new object[] { 50, 55, "Month5" });
UltraChart chart = new UltraChart();this.Controls.Add(chart);
chart.ChartType = ChartType.Composite;ChartArea area = new ChartArea();chart.CompositeChart.ChartAreas.Add(area);
//column layers use a string, GroupBySeries x axisAxisItem columnXAxis = new AxisItem(chart, AxisNumber.X_Axis);columnXAxis.DataType = AxisDataType.String;columnXAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries;columnXAxis.Labels.ItemFormat = AxisItemLabelFormat.ItemLabel;columnXAxis.Labels.SeriesLabels.Format = AxisSeriesLabelFormat.SeriesLabel;area.Axes.Add(columnXAxis);
//line layers use a string, ContinuousData x axisAxisItem lineXAxis = new AxisItem(chart, AxisNumber.X_Axis);lineXAxis.DataType = AxisDataType.String;lineXAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.ContinuousData;area.Axes.Add(lineXAxis);
//the layers can share the numeric y axis.AxisItem YAxis = new AxisItem(chart, AxisNumber.Y_Axis);YAxis.DataType = AxisDataType.Numeric;YAxis.Labels.ItemFormat = AxisItemLabelFormat.DataValue;area.Axes.Add(YAxis);
NumericSeries series1 = new NumericSeries();series1.Data.DataSource = dt;series1.Data.ValueColumn = "2007";series1.Data.LabelColumn = "label";chart.CompositeChart.Series.Add(series1);
NumericSeries series2 = new NumericSeries();series2.Data.DataSource = dt;series2.Data.ValueColumn = "2008";series2.Data.LabelColumn = "label";
chart.CompositeChart.Series.Add(series2);ChartLayerAppearance columnLayer = new ChartLayerAppearance();columnLayer.AxisX = columnXAxis;columnLayer.AxisY = YAxis;columnLayer.ChartArea = area;columnLayer.ChartType = ChartType.ColumnChart;columnLayer.Series.Add(series1);columnLayer.Series.Add(series2);columnLayer.SwapRowsAndColumns = true;chart.CompositeChart.ChartLayers.Add(columnLayer);
ChartLayerAppearance lineLayer = new ChartLayerAppearance();lineLayer.AxisX = lineXAxis;lineLayer.AxisY = YAxis;lineLayer.ChartArea = area;lineLayer.ChartType = ChartType.LineChart;lineLayer.Series.Add(series1);lineLayer.Series.Add(series2);chart.CompositeChart.ChartLayers.Add(lineLayer);
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);
In your code, for the 2nd data table, you've added rows to 'table' instead of 'budgetTable'.Also, for the X axis that's used for the line layer you need to setxAxisLine.SetLabelAxisType = SetLabelAxisType.ContinuousData;
Hey Max, thanks for getting back with me -
I have acutually workout the issues that i was dealing with however, i have some more formating tasks - 1. how to formate the Yaxis range so it goes in 1000s rather than the actual values
2. Because there will be 3 lines for each year i need a way to map the line circle to land on the acutal colum that is the same year.
Thanks in advance for your thoughs.
Thanks Max, you blokes have been such a great help gettiing my head around charting.
Thanks so much!
For Item Labels:seriesColumn1.Label = "2007";seriesColumn2.Label = "2008";seriesColumn3.Label = "2009";xAxisColumn.Labels.Orientation = TextOrientation.VerticalLeftFacing;
For Series Labels:xAxisColumn.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection;AxisLabelLayoutBehavior behavior = new WrapTextAxisLabelLayoutBehavior();behavior.Enabled = true;behavior.EnableRollback=false;behavior.UseOnlyToPreventCollisions=false;xAxisColumn.Labels.SeriesLabels.Layout.BehaviorCollection.Add(behavior);
Ok, one more issue - i am trying to get the SeriesLables to center and show the colomn names ie. 2007, 2008 and 2009 i tried everything i know to do but alas -
xAxisColumn.DataType = AxisDataType.String; xAxisColumn.OrientationType = AxisNumber.X_Axis;xAxisColumn.SetLabelAxisType = SetLabelAxisType.GroupBySeries;xAxisColumn.Labels.HorizontalAlign = StringAlignment.Center;xAxisColumn.Labels.VerticalAlign = StringAlignment.Center;xAxisColumn.Labels.SeriesLabels.FormatString = "Fiscal\nMonth\n";xAxisColumn.Labels.Orientation = TextOrientation.VerticalLeftFacing;xAxisColumn.RangeType = AxisRangeType.Automatic;xAxisColumn.LineThickness = 1;
xAxisLine.DataType = AxisDataType.String;xAxisLine.SetLabelAxisType = SetLabelAxisType.ContinuousData;xAxisLine.Labels.Orientation = TextOrientation.VerticalLeftFacing;xAxisLine.LineThickness = 1;xAxisLine.Margin.Near.MarginType = LocationType.Percentage;xAxisLine.Margin.Near.Value = 3;xAxisLine.Margin.Far.MarginType = LocationType.Percentage;xAxisLine.Margin.Far.Value = 3;
That worked great!! Thanks so much !
1. The best way is to setyAxis.TickmarkStyle = AxisTickStyle.Smart;This setting automatically picks a round interval, along with start and end values. 2. This is something that requires a little bit of trial and error. You can set a margin on the x axis that you use for the line layer in order to make the line points appear in the center of the column points. A value of 3 or 4 percent seems to work well.
xAxisLine.Margin.Near.MarginType =
LocationType.Percentage;xAxisLine.Margin.Near.Value = 3;xAxisLine.Margin.Far.MarginType = LocationType.Percentage;xAxisLine.Margin.Far.Value = 3;