|
When to use a new layer vs a new data set in the same layer |
Posted by DC Kelley on Mar-24-2011 07:56 |
|
A design approach question (in fact a couple) to ask from a new user...
Q #1
When should I use a new layer with a single data set vs when should I just add multiple data sets to the same layer? The general preferred approach is not clear to me.
Is there a speed benefit either way? Both are now working and so far I do not seem to see one.
Q #2
If I am in the middle of populating a data set into a specific layer (I passed a layer pointer to a function in one test, and a chart pointer in an earlier one I then discarded) is there a way to get the underlying chart object back, or do I *always* need to pass that in? Looking for a call like currChartPtr = myLayer->GetChart() to use for this and do not see one.
I have some data which, until I am in the middle of adding it to the layers data set, I will not know that I will then want to then add a new (different) layer with other information. This is causing me to re-think how we isolate the functions that deal with the data and brought the need up.
Q #3
If I want to use a trend or a confidence band, I understand these live in their own layers, and will likely need to provide them a copy of the same data, but am I forced to duplicate this or can they in some way share? Can the call *getDataSet(int dataSet) be used to achieve this?
Same basic question for creating candle sticks.
And again my thanks for what is turning into a great tool
DC Kelley |
Re: When to use a new layer vs a new data set in the same layer |
Posted by Peter Kwan on Mar-24-2011 11:34 |
|
Hi DC Kelley,
Q #1:
If you use multiple data sets within the same layer, some layer type allows you to combine the data sets in various ways. For example, in a bar or area layer, you can stacked data set (created a stacked bar). Data sets in the same layer must share the same x-coordinates for their data points (that's why they can be combined in various ways). Also, if you put the data sets in the same layer, they can share the same configuration. For example, in a liner layer, you can use Layer.setLineWidth to set the line widths that apply to all data sets.
Different layers can use different x-coordinates for their data sets.
Q #2:
Unluckily, you cannot get a chart object from a layer object. You can only get a layer object from a chart object by creating the layer.
Q #3:
When you pass data to ChartDirector, ChartDirector always duplicates them internally. For example, when you add a data set, ChartDirector will copy your data into an internal buffer. After that, you can free the memory for your data and ChartDirector will still have an internal copy. You can also add the same data (that is, using the same "double*" pointer in C++) to multiple layers without copying or duplicating the data in your code.
In a normal computer, duplicating data takes negligible CPU and memory (at least when compared to plotting the data), so duplicating data should not have any significant effect to your system.
Hope this can help.
Regards
Peter Kwan |
Re: When to use a new layer vs a new data set in the same layer |
Posted by DC Kelley on Mar-25-2011 04:53 |
|
Understand, will rework things to just pass in the current chart object each time. As I come to understand the use of the layers better this seems less of an issue. Memory is still precious in this app, at any given time we always ~300 megs or so of static data but are also generating that much every 15 seconds or so and so I have to think out how we can plot/save the ideal graph as we go along as there is no going back. And I think that with only a few exceptions (where we will just have to keep the data around), we can clone our data into the CD data sets as you previously suggested. |
|