I am trying to create an ultradatachart that should show 8 or 9 lines from a datatable.
The x axis should show the date column "dtg" and the Y values should come from the "tagvalues" column.
here is my code so far:
using (MySqlDataAdapter da = new MySqlDataAdapter(sql, con)) { da.Fill(dt); var data = dt.AsEnumerable() // convert the data to Enumerable so you can use linq over it .Select(r => new { dtg = r["DTG"], tagname = r["TagName"], tagvalue = r["TagValue"] }) // convert data to list of anonimous objects .GroupBy(d => d.tagname, (key, value) => new { key = key, value = value.ToList() }) // group the data by line names .ToArray(); ////////////////////// /// ultraDataChart1.Series.Clear(); ultraDataChart1.Axes.Clear(); ultraDataChart1.IsHorizontalZoomEnabled = true; ultraDataChart1.IsVerticalZoomEnabled = true; var xAxis = new CategoryDateTimeXAxis { Label = "Label", DataSource = dt, DataMember="dtg" }; var yAxis = new NumericYAxis(); ultraDataChart1.Axes.Add(xAxis); ultraDataChart1.Axes.Add(yAxis); foreach (var x in data) { AreaSeries useries = new AreaSeries(); useries.XAxis = xAxis; useries.YAxis = yAxis; useries.ValueMemberPath = "tagvalue"; useries.DataSource = x.value;//.Select(a => a.tagvalue).ToArray(); ultraDataChart1.Series.Add(useries); }
I cant get it to show the data.
Any help would be greatly appreciated.
Hello Paul,
Thank you for contacting Infragistics!
You are having issues seeing the chart render because you are anonymizing the data. If you really want to do that you can use a dictionary. Otherwise if you want to see binding to different datasources you can look in our samples browser XamDataChart > Data > Binding Data Types.
Thanks Mike. Sterling service as always!