Is there an example of loading a .Net System.Data.DataSet or System.Data.SQLClient.SQLDataReader to a TimeSimpleDataset or TimeGroupDataset? I am new to this graphing package.
Sorry, we dont' have any examples for either of those two.
The main issue for you is that you need to know how to read data from a dataset or database that you design. We can't tell you how to do that.
You will need to read a pair of values for each point of the graph. The value for x will be time based and you need to assign it to an object of the System.DateTime class. The value for y will be a numeric value. You should be able to do this without any reference to our Charting software.
Once you can read those values you can initialize one of our chart datasets using the following pseudo code.
int numPnts = (Get the number of points from dataset ) double [] yvalues = new double[numPnts]; DateTime [] timevalues = new DateTime[numPnts]; . . . You need to initialize the yvalues and timevalues arrays with values from . your database. You must initialize exactly numPnts worth since that is the size . of the arrays.
// Our datasets require an array of our ChartCalendar objects, rather than // DateTime objects. This array is initialized below ChartCalendar [] xvalues = new ChartCalendar[numPnts];
for (int = 0; i < numPnts; i++) xvalues[i] = new ChartCalendar(timevalues[i]);
// Then create the dataset TimeSimpleDataset Dataset1 = new TimeSimpleDataset("MyData",xvalues,yvalues);
Here is the dataset conversion function. This is simple. Could be modified to return TimeGroupDataset if multiple tables or possibly multiple YValues included in System.Data.DataSet. I will be working on such utilities in the future.
Public Function ConvertDataSet(ByVal ds As System.Data.DataSet) As TimeSimpleDataset
Dim i As Integer = 0 Dim DataPoints As Integer = ds.Tables(0).Rows.Count - 1 Dim YValues(DataPoints) As Double Dim XValues(DataPoints) As ChartCalendar
For i = 0 To ds.Tables(0).Rows.Count - 1 YValues(i) = CType(ds.Tables(0).Rows(i).Item("ITEM_VALUE").ToString, Double) XValues(i) = New ChartCalendar(CType(ds.Tables(0).Rows(i).Item("VALUE_DATE").ToString, DateTime)) Next i
Dim tsd As New TimeSimpleDataset("MyData", XValues, YValues) Return tsd