0
votes

Does anyone work with Infragistics UltraChart? I'm trying to bind a DataTable with elevation monitor data to a line graph in a Windows form.

As you can see from the following code, I have the DataSet and DataTable defined, and have started setting up the properties of the chart, but I'm not sure how to tie the DataTable table to the XYDataPointCollection series in the chart. Basically I want to be able to graph a line from two fields in the data table: "dateTime" (x-axis) and "gwElevation" (y-axis) for a specified date range.

} GroundwaterMonitorDataSet gwMonDataSet = new GroundwaterMonitorDataSet(); DataTable gwMonDataTable = new DataTable(); gwMonDataTable = gwMonDataSet.Tables.Add("P-14-01_Data");

  this.chartGwData.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;
  Infragistics.UltraChart.Data.Series.XYDataPointCollection gwMonSeries = new Infragistics.UltraChart.Data.Series.XYDataPointCollection();

  chartGwData.LineChart.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Solid;
  chartGwData.LineChart.StartStyle = Infragistics.UltraChart.Shared.Styles.LineCapStyle.Round;
  chartGwData.LineChart.EndStyle = Infragistics.UltraChart.Shared.Styles.LineCapStyle.Flat;
  chartGwData.LineChart.NullHandling = Infragistics.UltraChart.Shared.Styles.NullHandling.DontPlot;
  chartGwData.LineChart.Thickness = 3;

  this.chartGwData.DataSource = gwMonDataTable;
  this.chartGwData.DataBind();

}

Thanks for any help.

1

1 Answers

0
votes

Well I finally figured it out on my own:

First an EnumerableRowCollection must be created. I created one using a linq query which read from a table in my DataSet:

//create EnumerableRowCollection using the linq query on the DataSet table
gwMonDataTable = gwMonDataSet.P1401;
      EnumerableRowCollection<DataRow> qrySelectGwMonRecords =
        (from g in gwMonDataTable.AsEnumerable()
         where g.Field<DateTime>("readingDate") >= clndrGwMonStart.Value && g.Field<DateTime>("readingDate")<= clndrGwMonEnd.Value
         select g);

Then I create a NumericTimeSeries, which is populated using a foreach loop:

//create NumericTimeSeries; populate using foreach loop
Infragistics.UltraChart.Resources.Appearance.NumericTimeSeries gwElevSeries = new Infragistics.UltraChart.Resources.Appearance.NumericTimeSeries();
      foreach (DataRow gwElevDr in qrySelectGwMonRecords)
      {
        gwElevSeries.Points.Add(new Infragistics.UltraChart.Resources.Appearance.NumericTimeDataPoint(System.DateTime.Parse(gwElevDr.ItemArray[2].ToString()),System.Double.Parse(gwElevDr.ItemArray[8].ToString()),"C",false));
      }

Now the NumericTimeSeries is ready to be added to the UltraChart:

//add the data series to the chart as the data source
chartGwData.Series.Add(gwElevSeries);