|
addLineIndicator2 ? |
Posted by tuyen on Feb-19-2013 22:49 |
|
Hi Peter,
your software tool is great.
How can you help me:
I have a project which can add very very addLineIndicator2. Because I do'nt want repeart
add all addLineIndicator2 from begin, then when user choose a line, I will add a
addLineIndicator2.
I user viewer as WinChartViewer.
How can I addLineIndicator2 after call viewer.chart=m, with m is as finance chart.
Thankyou very much.
Best Regards
Tuyen |
Re: addLineIndicator2 ? |
Posted by Peter Kwan on Feb-20-2013 00:39 |
|
Hi tuyen,
If you have tried the "Interactive Financial Chart" sample code, you may have realized that it allows the user to add/remove many types of indicators. This is achieved by creating a charting subroutine that plots the chart according to user selections. So no matter what the user do, we just need to call the charting subrouting the update the chart.
For your case, I suggest a similar method. You can create a charting subroutine the draws the chart according to user selections. Then no matter what the user does, you just call that subroutine again. In this way, you do not need to write any additional code at all.
In ChartDirector, once the chart is drawn, the chart object cannot be modified. So if the chart is modified, you would need to create the chart object again. As mentioned above, it will not require any additional code, as the same code that creates the chart object in the first place is reused.
Also, re-creating the chart object has little to no performance impact. It is because configuring the chart itself takes negligible CPU time. The rendering of the chart takes around 100ms. This is required no matter the chart object is re-created or not. (If you add or remove one line, it may change the axis scale, and so the size and position of every chart object can be changed, and the legend box may need to be reflowed, etc..)
Hope this can help.
Regards
Peter Kwan |
Re: addLineIndicator2 ? |
Posted by tuyen on Feb-20-2013 14:36 |
|
Thank for your answer.
But because I'm setting up the chart to compare a lot of stock.Each stock should load data
from database, so the repeat makes repeated to get data from database, take a lot of time.
Do you have any idea to solve this problem?
sorry for my very bad english vocabulary. I had to use goole to translation.
Thank you again.
Best regards. |
Re: addLineIndicator2 ? |
Posted by Peter Kwan on Feb-21-2013 00:12 |
|
Hi tuyen,
If the data are from a database, your code must first read the data into memory (into an array), before they can be used to plot the chart. The solution to your issue is not to delete the memory afterwards, but to keep the data in memory.
In our "Interactive Financial Chart" sample code, you may notice that the timeStamps, highData, lowData, openData, closeData and volData are all member variables of the Form, not local variables, so they will not be deleted after the drawChart subroutine.
Hope this can help.
Regards
Peter Kwan |
Re: addLineIndicator2 ? |
Posted by tuyen on Feb-23-2013 09:42 |
|
Oh, it's a good idea.
I wil try it.
Thankyou very much.
Best regards. |
|