Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
cannot get a datatable data to display in ultradatachart
posted

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.