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; }
There is a typo in the Data Mapping. It is QRT not QTR. May be that is why the binding fails.
Hope this helps.
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.