|
Multichart - Replace one chart on the Fly (C++ MFC) |
Posted by Sal on Apr-22-2016 02:57 |
|
Hello Peter,
I have several charts part of a MultiChart container class view
All these charts were added using the addChart() method, inside a class of my creation
The addition order, defines the logical order, while those offsets defines the viewing position of the charts into the container
This triggers the following question:
Q1: Can I replace the chart at a specific position in the container class order with another on the fly (another type) in response to an action by User ?
I do not see any methods for this
I want to do this, because while CD renders the charts, I am working in what to show in the next charts cycle update
Q2: Say the Top chart is the main chart grabbing the mouse actions. How would I change the chart Position order so they would swap place and let the mouse actions handlers follow the change of position ?
I hope you have some code sample of link that illustrates some of the concepts I am asking about
Thanks
Sal |
Re: Multichart - Replace one chart on the Fly (C++ MFC) |
Posted by Peter Kwan on Apr-22-2016 21:39 |
|
Hi Sal,
The "Interactive Financial Chart" is an example where the charts in a MultiChart are modified according to user actions. (The FinanceChart is a MultiChart object.) In that example, the chart is simply redrawn whenever the user changes the selection.
Redrawing the chart makes the code simple, as you just need to use the same code that draws the chart in the first place, that is, you do not need to write any extra code to handle the change. Also, the same code can handle many types of user changes (adding or removing charts in the MultiChart, or changing the data to plot, changing the data representation, styles, etc).
You may want to try the "Interactive Finance Chart" in "Release Mode". Personally, I think it is quite responsive to user actions.
For your case, to replace a chart in the MultiChart, you may simply to redraw the entire chart (again, this usually requires only minimal code as you already have the code that draws the entire chart), or you can create a new MultiChart and add the existing charts to the new MultiChart. After re-ordering the chart, you can set the main chart so to the desired chart.
In brief, you may not need any particular code to handle these changes. You just need one chart drawing code which draws the chart according to user selections, and calls the same code whenever user selection changes.
Regards
Peter Kwan |
|