|
ChartDirector in a stand-alone application |
Posted by Saibal on May-31-2012 07:29 |
|
Hi,
I am planning to use ChartDirector in a stand-alone application. Haven't decided about
the platform yet (mostly Qt in Linux platform in C++ ). I am in the process of evaluating
charting software. I have certain requirements for the charting software,
Can you let me know whether ChartDirector can satisfy my requirement? That will help
me a lot.
My requirements are the following:
1. In the application user will be able to view 4 or more charts (all static, no dynamic
chart)
2. The data for each charts will be of large scale. It is a time series (100 records per
second for 7 days which boils down to 100*60*60*24*7=60480000 = 60.5 millions of
records). I am talking about the maximum limit. Typical size will be 2 days run which is
10-20 million records. The plot is a XY plot (X axis is the millisecond and the Y is a
double)
3. User should be able to zoom into the plot and reach to the millisecond level.
4. The response time for zooming (chart rendering) etc should not be very high (couple of
seconds). I am ready to spend initial load time (couple of minutes).
System requirements:
5. The software is going to run on machine with 8 core and 32 G memory. I will dedicate
at least 4-6 threads for the plot. Not many instance of the program will run at the same
time.
6. The data will be contained in local file system.
regards,
Saibal |
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Jun-01-2012 04:17 |
|
Hi Saibal,
Thank you very much for your enquiry. Below please find our response to your enquiry:
1. Yes. You can certainly display 4 or more charts at the same time.
2, 3, 4:
Yes. You can display this amount of data on a line chart. Remember to enable "fast line mode" (call LineLayer.setFastLineMode) for this amount of data. It should take a few seconds to plot a chart with 60000000 points. When you zoom in so that less data points are visible, the speed will be significantly faster.
If you want really fast response time (much smaller than one second) no matter how many data points are there and are willing to do some preprocessing of data, I suggest you to prepare simplified versions of your data.
Usually, there is no need to plot significant more data points than the number of pixels on the chart. Plotting more data points will not increase resolution, as the resolution is limited by the number of pixels. If you plot 60000000 points with fast line mode, ChartDirector will reduce the data to a much smaller number of points to match the actual chart size, so that the chart is visually the same as if all the data are plotted. It may take a few seconds to reduce 60000000 points. The issue is, each time the chart is changed (eg. scrolled), ChartDirector will do the reduction again.
One method to avoid repeating data reduction is to preprocess the data. You may prepare a version of your data that only contains 5% of your data points (which means there are only 3000000 data points). It only takes 5% more memory. Then you can prepare yet version of the data that contains only 5% of the 3000000 data points (which means it contains 150000 data points). The memory requirement is so small that it is negligible compared to your original data. You can continue to prepare several versions until there are only a few thousand points.
When a chart is plotted or zoom in/out, your code would need to determine which version of the data series to use, and ask ChartDirector to use that series. You can determine this based on the visible range. If the user has zoom in a lot (eg. zoom in 10000 times), you can use the 60000000 points version, as the visible portion is just 6000 points. If the user is not zooming in (viewing the entire time range), you may use the version that only have a few thousand points.
One common concern with data reduction is that it may miss the original peak of the data (or more technically the "envelope" of the data). To avoid this, a data reduction method can pick only the extreme points. For example, for every 40 data points, it can keep the maximum and minimum points, and throw away the other points. This will reduce the data to 5% of the original, and the chart plotted will be visually indistinguishable from the original data.
5. Your system is much more than enough. I would tend to think that 1 core with 4G of memory more than enough.
6. Your data can come from anywhere you want. Note that ChartDirector will not read the data from anywhere. Your code would need to read the data into memory, then pass to ChartDirector as a variable of your programming language (in C++, it would be a "double *").
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector in a stand-alone application |
Posted by Saibal on Jun-05-2012 15:18 |
|
Hi Peter,
Thanks for your detail reply. I appreciate that.
I tested with data reduction as you mentioned and it works good. I have one question:
Are the ChartDirector APIs thread-safe? I am going to call the API in different threads for
multiple charts. I saw the data is protected under the Chart object but just want to make
sure there is no thread-unsafe code inside the ChartDirector and you claim it to be thread-
safe.
regards,
Saibal |
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Jun-05-2012 23:24 |
|
Hi Saibal,
ChartDirector is thread-safe. ChartDirector is very commonly used in multi-threaded applications (such as multi-threaded web servers).
Note that "thread-safe" means you can have multiple threads, with each thread creating a separate chart object. So you can call the API in multiple threads, assuming there are operating on different chart objects. If you use multiple threads to operate on the same chart object, the calls to the ChartDirector API for the same chart object need to be serialized.
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector in a stand-alone application |
Posted by Saibal on Jun-15-2012 04:56 |
|
Hi Peter,
Thanks for your clarification.
I am planning to plot two data series (Y1 and Y2) in a single XY chart. The X axis is the
timestamp. I have the following data.
X Y1
100 10.0
102 11.1
104 12.1
X Y2
100 10.90
101 10.91
103 10.23
104 9.10
Please note that the X axis values are different for both series. Can I plot them in the single
chart with different timstamp values?
Or do I need to process the data to have the same X axis ?
regards,
Saibal |
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Jun-16-2012 00:16 |
|
Hi Saibal,
There is an example called "Uneven Data Points" in ChartDirector that shows how to plot multiple lines with different x-coordinates. You may look up "Uneven Data Points" from the ChartDirector documentation index.
In brief, the code is like:
LineLayer *layer1 = c->addLineLayer(DoubleArray(Y1, noOfPoints1), ....);
layer1->setXData(DoubleArray(X1, noOfPoints1));
LineLayer *layer2 = c->addLineLayer(DoubleArray(Y2, noOfPoints2), ....);
layer2->setXData(DoubleArray(X2, noOfPoints2));
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector in a stand-alone application |
Posted by Saibal on Jun-22-2012 07:33 |
|
Hi Peter,
Thanks for your reply. I could do that. One more question regarding one more chart type.
I want to plot a horizontal range bar chart (shown in the attached diagram), how can i do
that?
The data for that file is the following type:
series event_name start_time end_time
process1 event1 10:00am 10:30am
process1 event2 10:40am 10:45am
process2 event1 11:00am 10:20am
process2 event2 11:10am 10:50am
It is not exactly gnatt chart, because gnatt chart displays one event in one line, i want
multiple events for the same series in the same line because I will have few series but many
events for each series.
The colors/dotted lines you are seeing are the events.
regards,
Saibal
|
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Jun-23-2012 02:23 |
|
Hi Saibal,
The chart in your case is similar to the "Multi-Color Gantt Chart" included in the ChartDirector distribution (the first chart in http://www.advsofteng.com/gallery_gantt.html). Note that in the "Multi-Color Gantt Chart", each event can have more than 1 bar. In your case, the bars happen to overlap. In your case, the long blue bars at the bottom, and the short color bars at the top.
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector in a stand-alone application |
Posted by Saibal on Jun-26-2012 08:40 |
|
Thanks Peter,
I could do that. I have one question. By the way, I am using the chartTime to give the date
and time ( Chart::chartTime )
Can it take milliseconds? I see this constructor doesn't take milliseconds. Can we have
millisecond support? My data is in Millisecond.
regards,
Saibal |
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Jun-26-2012 23:05 |
|
Hi Saibal,
As the ChartDirector date/time represents elapsed seconds since Jan 1, 0001 00:00:00 and is a double value, you can just add the fractional seconds to the return value of Chart::chartTime for the millisecond part. For example:
double myTime = Chart::chartTime(yyyy, mm, dd, hh, nn, ss) + ms / 1000.0;
(In the above, ms is assumed to be a number from 0 to 999 representing the millisecond part of the date/time.)
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector in a stand-alone application |
Posted by Prakash on Nov-11-2012 17:13 |
|
Hi Peter,
Thank you for the help so far. I work with Saibal and taking up the task of evaluating
ChartDirector in our
application. I have some queries regarding makeChart() API's behavior.
1 : LineLayer *layer = c->addLineLayer(DoubleArray(pX1, 1024), 0x880000, "series1");
2 : MemBlock m = c->makeChart(Chart::BMP);
3 : layer = c->addLineLayer(DoubleArray(pX2, 1024), 0x88ffff, "series2");
4: MemBlock m = c->makeChart(Chart::BMP);
5: QLabel myQLabel;
6: QPixmap image;
7: image.loadFromData((uchar *)m.data, (uint)m.len);
My queries are as below
1. The final image creates a chart with only one line instead of two lines. If i remove the
makeChart() call at line no 2, then it creates 2 lines. According to my understanding,
makeChart() creates a chart with all the layers within it at the time the API is called. Are
there any gotchas ?
2. How can i remove a layer from the chart ? In our application, user may deselect only 1
series out of existing "n" series inside the chart at which we want to remove the
corresponding layer from the chart and create a new image by calling makeChart(). I don't
see any such API's at the moment. We are currently creating a new chart and loading all
(n-1) series.
Thanks
Prakash |
Re: ChartDirector in a stand-alone application |
Posted by Peter Kwan on Nov-12-2012 23:47 |
|
Hi Prakash,
Once the chart object is made, it cannot be changed. To change the chart, you would need to create another chart object.
To add or remove a layer, simply recreate the chart object with the required layers. The code actually is very simple. You just need to draw a chart based on the state of the user controls (the state of the check boxes, drop down list boxes, etc). It is like:
void drawChart()
{
... draw a chart based on the state of the user controls ....
}
Then no matter what the user does (whether he selects or unselects something), you just call drawChart again. Also, you can save the "user preference" or "profiles" by just saving the state of the user controls. The user can later reload those selections or profiles, and your code just need to call drawChart to recreate the chart with the user selections.
You may refer to the "Interactive Financial Chart" sample code for an example. In that example, there are many controls that the user can use to control the chart. The signal handlers for these controls basically just calls drawChart.
Hope this can help.
Regards
Peter Kwan |
|