I really need help creating a chart with dual Y axis. I am getting a simple data from SQL database. The data I'm getting looks like:
Date
Price
TRP Analyst Rating
2009-08-03 00:00:00
119.92
2
2009-08-04 00:00:00
119.6
3
2009-08-05 00:00:00
118.47
2009-08-06 00:00:00
117.38
2009-08-07 00:00:00
119.33
2009-08-10 00:00:00
118.7
2009-08-11 00:00:00
117.79
5
2009-08-12 00:00:00
119.29
2009-08-13 00:00:00
119.58
2009-08-14 00:00:00
118.57
2009-08-17 00:00:00
116.86
1
2009-08-18 00:00:00
117.63
I would like my X-axis to be column "Date", Y1_axis to be "Price" and Y2_axis to be "TRP Analyst Rating".
I've read the posts about this topic but for some reason none of them seem to work for me.
I just tried using ColumnLine chart and it didn't work.
Please Help!!
Try this example:DataTable dt = new DataTable();dt.Columns.Add("Date", typeof(string));dt.Columns.Add("Price", typeof(double));dt.Columns.Add("Rating", typeof(double));
dt.Rows.Add(new object[] { "2009-08-03", 119, 2 });dt.Rows.Add(new object[] { "2009-08-04", 118, 3 });dt.Rows.Add(new object[] { "2009-08-05", 117, 2 });dt.Rows.Add(new object[] { "2009-08-06", 119, 2 });dt.Rows.Add(new object[] { "2009-08-07", 117, 3 });
UltraChart1.ChartType = ChartType.ColumnLineChart;
UltraChart1.ColumnLineChart.ColumnData.DataSource = dt;UltraChart1.ColumnLineChart.ColumnData.IncludeColumn(2, false);UltraChart1.ColumnLineChart.ColumnData.SwapRowsAndColumns = true;
UltraChart1.ColumnLineChart.LineData.DataSource = dt;UltraChart1.ColumnLineChart.LineData.IncludeColumn(1, false);UltraChart1.ColumnLineChart.LineData.SwapRowsAndColumns = true;
UltraChart1.Axis.X2.Visible = false;UltraChart1.Data.DataBind();
This should display a columnline chart with a few rows of data. While this is a decent starting point, I do reccomend using a composite chart for this, because it is more customizable.
Hi Max, you solution on color to graphics is good, tks. I have other problem and i don't know as do it or explicator, ok this is the problem.
I have the next DataSource:
Value A = Null
Value B = 10
Value C = 25
Value D = 20
Value E = Null
And my graphic the Value RangeMin the Axis Y and Y2 is -10(this is a value real to my graphic), so the value "A" is null the line begin in the value in -10("A") to point "B" that value is 10, the next line is point "B" to "C", the next line is point "C" to "D" and last line as the first line the value is the point "D" to -10 so my value is Null. I only want view the line of the point "B" to "C", "C" to "D". I don't know if you understand me? or You know as do it?. Realy so much thank you, regards.
Assuming that this is for a line chart, you can set NullHandling to DontPlot in order to hide null values. Here's a small example:ultraChart1.ChartType = ChartType.LineChart;DataTable dataTable1 = new DataTable();dataTable1.Columns.Add("label", typeof(string));dataTable1.Columns.Add("value", typeof(double));dataTable1.Rows.Add(new object[] { "Value A", null });dataTable1.Rows.Add(new object[] { "Value B", 10 }); dataTable1.Rows.Add(new object[] { "Value C", 25 });dataTable1.Rows.Add(new object[] { "Value D", 20 });dataTable1.Rows.Add(new object[] { "Value E", null });
NumericSeries series = new NumericSeries();series.Data.DataSource = dataTable1;series.Data.LabelColumn = "label";series.Data.ValueColumn = "value";series.DataBind();
ultraChart1.Series.Add(series);ultraChart1.LineChart.NullHandling = NullHandling.DontPlot;