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.

Parents
No Data
Reply
  • 25665
    Verified Answer
    Offline posted

    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.

Children