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

Message ListMessage List     Post MessagePost Message

  General question on zooming (implementation)
Posted by Christian Wegmann on Apr-12-2013 18:06
Hello Peter,

we are planing to use ChartDirector to display a Financial Chart similar to your Interactive Financial Chart example. After looking at the Chart Director examples and forum entries I'm still struggling in understanding the zooming concept. I will try to describe my problem:

There is a ChartViewer allowing to specify a viewport which determines the "visible area" of a chart. Then there is the FinanceChart for which a certain data set can be set.

Considering this setup my expectation was that a manipulation of the viewer's viewport would automatically switch to an according subset of data being displayed in the chart. However looking at the example code it seems this is not the case and the viewport's borders can only be used to "manually" extract data from the original data set and recreate the chart from the reduced data set.

Could you please confirm (shortly) that the "manual data extraction" is the only possible implementation to actually zoom a graph please? By manual I mean that the reduction of the initial data is not done by ChartDirector. Thanks a lot!

Looking at the zooming examples it seems unnecessary to me that the "manual data extraction" is repeated on every chart redraw also the data extract might not have been changed, but some colours might have been changed or new data points might have been added outside of the visible data extract. But I guess the repeated data extraction is only done to keep the example simple?

Regards,
Chris

  Re: General question on zooming (implementation)
Posted by Peter Kwan on Apr-13-2013 00:22
Hi Christian,

ChartDirector only manages the viewport and the axis scale. Your code would need to obtain the correct data to be displayed.

In many applications, not all data are loaded at once, or different data are displayed at different zoom levels. For example, suppose you have financial data for the last 50 years, and have both intraday and daily data (and perhaps weekly or monthly data). If the user zooms to one or a few days, you may want to use the intraday data. If the user zooms to a few months, you may want to use daily data.

Furthermore, it may not be desirable to load all 30 years of intraday and interday data when the user is viewing the last 90 days of data. It is not likely the user scroll to read the intraday or daily data 50 years ago. So many applications will just load the data that are visible and cache them in memory. This is particular true for web applications, but it also applicable to desktop applications if you have a large amounts of data.

So in brief, unless your system only has a small amount of data, and only have one type of data at all scales (that is, does not have intraday and daily data) it is generally not preferrable to extract all the data and ask ChartDirector to display part of them. It is more preferable for the calling code to extract the data using methods appropriate for the application, and pass only the necessary data to ChartDirector.

If you are reading the desktop version of the sample code, it uses the method to load all the data in memory at once, and then extract the visible part out and pass them to ChartDirector. (I am not sure which programming language editions you are using. Some editions include sample code for both web and desktop applications.) This assumes there are only a small amount of data and only one type of data to be displayed at all scale. As you can see from the sample code, the extraction code is very simple in this case. (In the C++ edition of the code, there is only 3 lines of overhead, plus 1 line for each data series.)

If you have a huge amount of data (like a few hundred MB of data for each stock), you may not want to load all of them to memory at once. In this cases, you may want to develop a method to load the data on demand. Also, if you are displaying different data at different scale (like intraday data for a few days, and daily data for up to 1 year, and weekly data for up to 5 years, ....), your code would need to pick the data you want to use based on the axis scale.

In an analogy, you may think about zooming and scrolling in Google Map. If you zooms in, you can see the street map. If you zooms out, you may see the terrain map. In other words, you see different data at different scale. Also, it is not preferrably to load all the street maps of all cities in the entire planet into the drawing engine just because the user is viewing the street map of a certain city. For large amount of data, it is better if the data are loaded on demand.

Regards
Peter Kwan