Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 System.Data.DataSet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kinetric

5 Posts

Posted - 05 Jan 2005 :  16:34:38  Show Profile  Reply with Quote
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.

quinncurtis

1164 Posts

Posted - 05 Jan 2005 :  18:30:46  Show Profile  Reply with Quote
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);




Go to Top of Page

kinetric

5 Posts

Posted - 06 Jan 2005 :  09:06:19  Show Profile  Reply with Quote
Thanks, this clears it up some. I will post the code when complete to provide an example. Perhaps it can become a utility like that for loading CSV.
Go to Top of Page

kinetric

5 Posts

Posted - 11 Jan 2005 :  22:01:24  Show Profile  Reply with Quote
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

End Function
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07