I am trying to bind a DataTable to a Line chart. The table is just quarterly figures
Number QRT------------ -------1000 Q11001 Q21002 Q31003 Q4
So I wish to have the 4 series, the code snippit is shown below... any ideas?
foreach (DataRow dr in dt.Rows) { Series c = new Series(); c.Stroke = Brushes.Black; c.Label = dr[1].ToString(); c.ChartType = ChartType.Line; c.DataSource = dr; c.Fill = Brushes.Blue; c.DataMapping = "ValueX = Number; ValueY = QTR;"; Marker seriesMarker = new Marker(); seriesMarker.Type = MarkerType.Rectangle; seriesMarker.Foreground = Brushes.Black; seriesMarker.FontSize = 14;
xamChart5.Series.Add(c); this.xamChart5.Series[Index].Marker = seriesMarker; Index = Index + 1; }
In both 2D and 3D if you are using Line chart you need to use Value. If you are using Scatter, StatterLine, Bubble charts you need to use ValueX ValueY and ValueZ syntax.
Thanks mate Im at idiot. If it isnt broken dont fix. I guess I was lead down this path due to the 3D option. Would I need to use ValueX ValueY and ValueZ sytax if I made my line graph 3D?
Thanks for you help
ValueX and ValueY are used in Scatter or ScatterLine charts.
Hi, I am still unable to bind using the ValueX, ValueY syntax but the Value, Label syntax is ok? Any ideas
Thank you
c1.Label = "QTR";c1.ChartType = ChartType.Line;c1.DataSource = dt;//below works -->//c1.DataMapping = "Value=Number;Label=QTR";//below fails -->c1.DataMapping = "ValueX = QTR; ValueY = Number";xamChart7.Series.Add(c1);
Thanks your reply. I did spell it incorrect in the post.
The problem was that I was using the wrong graph for what i needed to do. I was trying to use a line graph, 1 line for each quarter but a line graph requires more than one data point per series.
Once I changed it to one series instead of 4 it worked fine.