ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Very simple example how to add viewPortControl to winChartViewer in real-time chart
Posted by Zipsoft on Aug-03-2021 20:57
Hi,

I am interested in using a ChartDirector library but I do not understand how to use the viewPortControl, The sample in website is too complicated.
Does anyone have a simple example to understand how this is supposed to be done?

Thanks

  Re: Very simple example how to add viewPortControl to winChartViewer in real-time chart
Posted by Peter Kwan on Aug-04-2021 00:44
Hi Zipsoft,

There is an example in the Library section of our web site:

https://www.advsofteng.com/tutorials/real_time_chart_viewport/real_time_chart_viewport.html

(Note: The sample code in the Library section is written sometime ago and it includes the ChartDirector 6.x assembly (DLL). The same code also works with ChartDirector 7. You just need to change the project to reference the ChartDirector 7 assembly.)

You can consider the WinViewPortControl to be just a "scrollbar with a background image", in which the background image is the chart with the full x-range.

The above sample code also demonstrates multi-threading, in which the data come from another thread. The code also works if the data come from the main thread.

Regards
Peter Kwan

  Re: Very simple example how to add viewPortControl to winChartViewer in real-time chart
Posted by Zipsoft on Aug-04-2021 03:57
Attachments:
Hi,

Can you please explain how can I reflect the chart into ViewPortControl in the attached program?

Thanks
WinFormsApp3.zip
WinFormsApp3.zip

124.79 Kb

  Re: Very simple example how to add viewPortControl to winChartViewer in real-time chart
Posted by Peter Kwan on Aug-04-2021 12:54
Hi Zipsoft,

I am not too sure what you mean by "reflect the chart". If you just want to display the same chart in the viewport control, just use the same axis configuration and same data in the viewport control.

In your current code, for the viewport control, the x-axis scale is consistent with the actual data. It appears you are starting the the "Simple Real-Time Chart" sample code:

https://www.advsofteng.com/doc/cdnet.htm#realtimedemo.htm

The x-coordinates in the above code is clock time (the time you see on the clock), and the x-axis displays clock time.

For the viewport control, it appears to come from:

https://www.advsofteng.com/tutorials/real_time_chart_viewport/real_time_chart_viewport.html

The above example uses stopwatch time. It always starts at 00:00 like a stopwatch, and not the actual time on the clock. It is normally it cannot display your data as their x-coordinates are clock time. They are outside the range of the stopwatch based x-axis scale.


In real-time chart, normally the viewport control contains future times. In the "Real-Time Chart with Viewport Control" example, you can see the x-axis range of the viewport control includes future times. Obviously, we cannot determine future times from your data, as the data do not exist yet. So they must be specified by your code. Only your code knows how far in the future the viewport control needs to include. In the sample code, it is done by "WinChartViewer.setFullRange".

https://www.advsofteng.com/doc/cdnet.htm#WinChartViewer.setFullRange.htm

The range must be consistent with the actual data. If your data are using clock time, it needs to be in clock time with the time range consistent with your actual data. If the data are using stopwatch time, it needs to be in stopwatch time.

Regards
Peter Kwan