I am trying to setup the Datasource for a Column / Line Chart so I can show monthly quantities as columns, and a trend line. Here is my data:
Unfortunately, the Column / Line sample code is incomprehensible to me. I am able to create a Column chart with the following code. How do I change this code for a Column / Line chart where Quantity is the columns & ThreeMoAvg is the line? Thanks!
public struct Hist { public string Month; public float Quantity; public float ThreeMoAvg; }
private Hist[ arrHist;
private void buttonDmdHist_Click(object sender, EventArgs e) { // hide the chart this.ultraChartResults.Visible = false;
//attach the history to the chart this.ultraChartResults.DataSource = this.GetHistDataTable(); this.ultraChartResults.DataBind();
// setup X labels this.ultraChartResults.Axis.X.Labels.Visible = false; this.ultraChartResults.Axis.X.Labels.SeriesLabels.Visible = true; this.ultraChartResults.Axis.X.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
// show the chart this.ultraChartResults.Visible = true; }
private DataTable GetHistDataTable() { // Turn the array into a datatable DataTable retDT = new DataTable(); retDT.Columns.Add("Month", typeof(String)); retDT.Columns.Add("Quantity", typeof(Single)); for (int index = 0; index < this.arrHist.Length; index++) retDT.Rows.Add(new Object[ { this.arrHist[index].Month, this.arrHist[index].Quantity }); return retDT; }
Hi,
Your code looks correct, but the image doesn't match the code you posted. For example, in the image, you have 5 columns per row, but your data table only has 2 numeric values per row. Are you absolutely sure that you're looking at the correct image and that you're binding the correct chart control? Perhaps you can attach a sample project to this thread for debugging.
Hi max,
I tried the way u said but i didnt get the result i want.. see my code below
dt.Rows.Add(New [Object]() {"2010", 2000, 12})
dt.Rows.Add(New [Object]() {"2011", 3000, 25})
dt.Rows.Add(New [Object]() {"2012", 2500, 10})
dt.Rows.Add(New [Object]() {"2013", 1000, 13})
dt.Rows.Add(New [Object]() {"2014", 1500, 5})
dt.Rows.Add(New [Object]() {"2015", 2100, 7})
Chart10.ColumnLineChart.ColumnData.DataSource = dt
Chart10.ColumnLineChart.ColumnData.IncludeColumn("Eliminated", False)
Chart10.ColumnLineChart.ColumnData.DataBind()
Chart10.ColumnLineChart.LineData.DataSource = dt
Chart10.ColumnLineChart.LineData.IncludeColumn("Identified", False)
Chart10.ColumnLineChart.LineData.SwapRowsAndColumns = True
Chart10.ColumnLineChart.LineData.DataBind()
what i get is
what i exactly want is
Please help me on this issue..
Thank in Advance!!!!!!!!!
Great! Thanks!
daamruth,
You will want to set properties on both the Y and Y2 axes to make them have the same intervals. Your code should look something like:
this.ultraChart1.Axis.Y.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom; this.ultraChart1.Axis.Y.RangeMin = 0; this.ultraChart1.Axis.Y.RangeMax = 20; this.ultraChart1.Axis.Y.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.DataInterval; this.ultraChart1.Axis.Y.TickmarkInterval = 2;
this.ultraChart1.Axis.Y2.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom; this.ultraChart1.Axis.Y2.RangeMin = 0; this.ultraChart1.Axis.Y2.RangeMax = 20; this.ultraChart1.Axis.Y2.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.DataInterval; this.ultraChart1.Axis.Y2.TickmarkInterval = 2;
Hi there,
a question regarding the ColumnLineChart and its axis:
In case I do it the way you did it in the above sample how could I make the Y and the Y2 axis to have the same intervals. The one of the line-part is not the same as the one of the column-part though this is - in my eyes - the way it should be.
Working on an old version 2006.1 - so I can't use compositecharts because wanting to add a custom layer to the ColumnLineChart.
Regards and thanks in advance
Daniel