问题
Can someone please provide a simple example of adding a line series to an UltraChart from a data table? The table has time series values (time values on x-axis, measurement (double) values on the y-axis).
So far the only examples I've seen where time series are added to the Chart are for a finite set of hard-coded datapoints. I want to be able to fee the data series from a selection in the table.
Any thoughts ideas and/or advice is greatly appreciated. Thanks, Ruben.
回答1:
Define a Numeric Series
Loop through each Data row in the Datatable
Add Datapoints from the Datarow inside the loop
NumericSeries.Points.Add(new NumericTimeDataPoint(System.DateTime.Parse(row["Date"]), row["value1"], "Label Name", false));
Add the Series to the Chart
For Multiple Line Series create as many Series as you want with different columns.
NumericTimeSeries waterDataSeries = null;
foreach (DataRow currentRow in myDataTable.Rows)
{
waterDataSeries.Points.Add(new NumericTimeDataPoint(Convert.ToDateTime(currentRow["Date"]), Convert.ToDouble(currentRow["qtyMeasure"]), "Water", false));
}
Chart.Series.Add(waterDataSeries);
来源:https://stackoverflow.com/questions/4116199/c-sharp-infragistics-ultrachart-linechart