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.