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

Message ListMessage List     Post MessagePost Message

  Realtime data and zooming
Posted by Stephan Bielmann on Jun-12-2014 15:58
Hello there,

I have a use case when I have to draw real time data, the update frequency is rather low, it may be in several minutes.

The chart that is drawn does grow in the X axis, so in the beginning there wont be data, then after some minutes one or some data points and so on. Thus after 15 minutes the X axis will have a span of 15 minutes for example.

Now I would like to enable zoom and scroll functionality for this chart too. All I do is sync all the axes on viewport changes. This does however not work, it looks like Chart Director is having trouble with the automatic setup of the full range of the view port.

You may see the effects when using your example realtimedemo (I took the Qt one), and set the mouse usage mode to zoom in, and sync the axis right before setChart() for the viewer.

Is there a solution to use zoom and scroll for this use case at all ?

  Re: Realtime data and zooming
Posted by Peter Kwan on Jun-13-2014 00:35
Hi Stephan,

As according to the ChartDirector documentation, syncDateAxisWithViewPort can be used
to synchronize a date/time axis with the view port. You may use setFullRange to define
the full range of the view port. If you do not define the full range, ChartDirector will
automatically set the full range as the axis scale the first time syncDateAxisWithViewPort
is called. After that, the full range is defined, so ChartDirector will continue to use that
full range.

For your case, if you do not set up the full range of the view port, the full range will be
obtained from the first chart, which is the chart with no data. Even if you have more
data later, ChartDirector will continue to use the full range based on the no data axis.

In many applications, ChartDirector cannot know the full range. For example, suppose
there is a database with 20 years of data. If someone is plotting the last 30 days of
data, most like the code would retrieve the last 30 days of data from the database and
pass them to ChartDirector. ChartDirector would not know that there are actually 20
years of data in the database. If ChartDirector is to automatically set the full range, it
can only set it based on the available data, which is for 30 days. So in most applications,
the full range should be defined explicitly using setFullRange.

For your case, if the full range keep changing, you would need to call setFullRange again
to change the full range. Depending on the exact behaviour you want, you may want to
adjust the view port as well. For example, suppose your have 2 hours of data from 10:00
to 12:00, and the user has zoomed to view the last hour 11:00 to 12:00. Later you have
more data, and your data are from 10:00 to 14:00. How the chart should be updated in
the case? Should it continue to show 11:00 to 12:00 (as this is what the user has
zoomed to)? Or should it show 13:00 to 14:00 (the intention of the user may be is to see
the last 60 minutes of data)? Or should it show 12:00 to 14:00 (the intention is to show
the last 50% of the data)? There are many other possibilities and you can adjust the full
range and view port to reflect the behaviour you want.

Hope this can help.

Regards
Peter Kwan

  Re: Realtime data and zooming
Posted by Stephan Bielmann on Jun-13-2014 19:56
Hello Peter,

thank you, that is ok for me I will implement a solution with setFullRange()