Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I implement this with CWGraph control?

Who can help me,i meet a difficult problem:
Now i have a form(historygraph.frm), four DTPicker controls(DTPicker1,DTPicker2,DTPicker3,DTPicker4), and three command control(cmdFind,cmdNextPage,cmdPreviousPage).
My database is SQL SERVER 2000,
In my table(mytable),I have two fields:
(1)savetime(datetime) (2)value(integer)
So DTPicker1 and DTPicker2 stand for the time that I want begin to find in the database table savetime field. DTPicker3 and DTPicker4 stand for the time that I want end to find in the database table savetime field.

DTPicker1.Format = dtpShortDate
DTPicker2.Format = dtpTime

DTPicker3.Format = dtpShortDate
DTPicker4.Format = dtpTime

When the user select the time query range.(from begin time to end time)
and press the command(cmdFind),I need these data value to display with the CWGraph control.Meanwhile,I must display the data savetime on X Axes,and the data value on Y Axes.

Because the amounts of data is very large,So I must display the Graph on limited amount,When the chartlength is full,user can press the Next Page command,also user can press the Previous Page command to look the last page data chart. The whole interval of the pages can set 1 hour or 3 hour and so on.
For Example:
data1 savetime:09:00:03,data1 value:1000
data2 savetime:09:00:08,data2 value:1020
data3 savetime:09:00:20,data3 value:2000
...
On the X Axes,display in order: 09:00:03 09:00:08 09:00:20 ...

I have complete the code that get the savetime and value when user select the datetime query range,But I can't display it with chart,and implement the function as I describe above.
Who can give me help ,how to use CWGraph control,How to set it,I have see the sample but can not solute this problem.

Please Help me,otherwhise My boss will ......

Thanks.
0 Kudos
Message 1 of 2
(6,793 Views)
Okay, first you will want to use the PlotXvsY method of CWGraph. This method plots a 1D or 2D array of Y data against a 1D array of X data.

Place a CWGraph on your form. By default its name will be CWGraph1. You can change the format X axis by right-clicking on the graph and selecting Properties. On the Format tab, you will see that time is one of the Built-in format styles. Select the appropriate format string and press Apply. Anywhere you want the graph to plot your data you can place the command:

CWGraph1.PlotXvsY savetime, value

To view help on this method, you can type in the above command, place the cursor somewhere in the method call and press F1.

Now, in terms of displaying only part of the data, I recommend deciding the maximum number of data points you want displayed at a time. You can then create arrays of the desired subsets of times and values to display, and use these subsets in your call to PlotXvsY. If you create a Sub with arguments for selecting the subsets of data, the Sub could be called from the callbacks of your command buttons.

Regards,

Eric
0 Kudos
Message 2 of 2
(6,772 Views)