|
ChartDirector with Remote Desktop Control |
Posted by Serron on May-18-2012 10:34 |
|
Hi there,
I am not sure if this is a known issue or not.
I use a Mac Mini running as Windows7 and run the demo version of .Net ChartDirector on it.
The VGA/HDMI of Mac mini is not connected,
I always use "Remote Desktop Control" to check if the software is running well or not.
Sometimes, I got an error message when ChartDirector draw a FinanceChart.
the error message is "Attempt to divide by zero".
but when I restart the software it becomes good and without any error.
I do check my ChartDirector code and any data code that pass to ChartDirector but can
not find any bug.
I use a message recorder to trace this issue, I get the error is happened while calling
"setData()".
And I also update to the latest version which is v5.1 and it is the same.
Is there any suggestion how to dig out the root cause?
thank you very much. |
Re: ChartDirector with Remote Desktop Control |
Posted by Peter Kwan on May-19-2012 00:19 |
|
Hi Serron,
I have checked many times. The setData method basically just stores the data. There is only 1 division in the code, but the divisor is very unlikely to be zero. (The FinanceChart source code is included in the ChartDirector download in ChartDirector\\NetFinanceChart. You can even compile your own FinanceChart class so that you can trace into it.)
To diagnose the problem, is it possible to double check where does the problem occur? You may simply catch the exception and print out the stack trace. This is something like:
try
{
drawChart();
}
catch (Exception e)
{
string errMsg = e.Message;
string stackTrace = e.StackTrace;
... output the errMsg and stackTrace as appropriate to your application, such
... as to display to Console, or pop up as a message box or display in some other
... parts in your GUI or save to a text file ....
}
My guess is that the error may be related to the data. Sometimes invalid data can cause exceptions to be thrown. For example, in a FinanceChart, we must have high >= close >= low, volume >= 0, etc.. If the data are invalid, it is not impossible that some technical indicator calculations may throw exceptions.
Regards
Peter Kwan |
Re: ChartDirector with Remote Desktop Control |
Posted by Serron on May-21-2012 20:17 |
|
Hi Peter,
Thanks for the suggestions.
I tried your suggestion and now I got the result that would be able to be duplicated.
I try 5 times and the issue is able to be duplicated.
Try1:
1)Start an Window App
2)Minimize the Window before ChartDirector draws a FinanceChart.
3)Draw a FinanceChart by a timer or thread.
4)Maximize the Window App and check the error message.
There will be a "Attempt to divide by zero" error catch by Exception routine.
StackTrace:
ChartDirector.FinanceChart.a(Axis A_0)
ChartDirector.FinanceChart.addIndicator(Int32 height)
ChartDirector.FinanceChart.addMainChart(Int32 height)
Try2:
1)Start an Window App
2)Maximize the Window App (don't Minimize the Window).
3)Draw a FinanceChart by a timer or thread.
There is no error always.
Can you confirm this issue?
Since my Windows APP is automated run in the background. |
Re: ChartDirector with Remote Desktop Control |
Posted by Peter Kwan on May-21-2012 23:55 |
|
Hi Serron,
In theory, the FinanceChart should behave exactly the same way no matter your Window is minimize or not. It is because the FinanceChart class does not use the Window at all and does not do anything that depends on the state of the Window.
For your case, it seems very likely that it is cause by invalid data or chart configuration. I suspect your code may be is configuring the chart so that the plot area size is 0. (By default, the FinanceChart left and right margin are both 40 pixels, so a width of 80 pixels will cause the plot area size to become 0.) Is your code behaving differently depending on the Window state? (Is your code configuring the chart size based on the Window size or state?)
If your code is using a variable chart size, may be you can consider not to draw the chart at all if it is too small (as a zero size plot area is not visible anyway), or you may force the chart to be of a certain minimum size (eg. 150 pixels wide).
Please kindly let me know if the above can solve the problem.
Regards
Peter Kwan |
Re: ChartDirector with Remote Desktop Control |
Posted by Serron on May-22-2012 08:12 |
|
Hi Peter,
You are correct, I do change the size while window is re-sizing.
Now, I find where the bug is.
I also modify my code and if there is no update to this thread within 2 days.
This problem should be solved.
thank you. |
|