Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Endless (?) loop in SimpleLinePlot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

findejs

12 Posts

Posted - 19 Feb 2008 :  13:21:21  Show Profile  Reply with Quote
Lin plot ends up in endless loop if almost constant line should be displayed. Almost constant line means values in displayed line differs in approximately 13th significant digit. E.g. 1.123456789012; 1.123456789013.
The behavior can be reproduced by modifying 'LinePlotSalesVolume' demo:
comment out line:
//y1[i] += y1[i-1] + (5 + i) * (0.75 - ChartSupport.GetRandomDouble());
add line
y1[i] += y1[0] + 1e-13 * (i % 2) * 0.5;
comment out dataset2 from the line:
TimeSimpleDataset [] DatasetArray = {Dataset1 /* , Dataset2 */ };

Note if magic constant 1e-13 is changed to 1e-12 or 1e-14 on my machine (Intel Duo, VS2005 SP1, C#) chart is working correctly.
QC DLL version is 1.6.1.10

quinncurtis

1164 Posts

Posted - 19 Feb 2008 :  14:20:40  Show Profile  Reply with Quote
That's an interesting case. What you have done is to create a situation where the maximum resolution of the double numeric type is exceeded, and simple floating addition no longer works the way you would explect, given infinite precision. The y-axis that is created by your example has a range of 100 to 100 + 1e-13, with a tick mark spacing of 5e-15. As the software increments through the tick marks, it calculates (100 + 5e-15) and it always comes back 100. This results in the endless loop.

We don't know of any workaround for plotting the data exactly as is.

The problem is tied to the auto-scaling and auto-axis routines. What type of graph do you expect to see. Are you expecting a y-axis scaled from 0 to 100 + e-13, or a y-axis scaled from 100 to 100 + e-13. The first will show a flat line at 100. The second will show a saw tooth.
Go to Top of Page

findejs

12 Posts

Posted - 20 Feb 2008 :  11:49:05  Show Profile  Reply with Quote
I think there are two rather independent issues:
a) endless loop - I believe it should never happen, for any data
b) displayed line - in my opinion the chart should display as many details as it can, so it should show saw tooth even if tick marks cannot be displayed/calculated

In may particular case I care only about chart reliability, because the 'noisy' constant is result of some numerical algorithm and it can be safely rounded e.g. to float precision, which should prevent the problem.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 20 Feb 2008 :  12:11:33  Show Profile  Reply with Quote
Your points are valid and we will take them into consideration in subsequent revisions of the software.

If you know your data is of this form, the simplest thing to do is to peg the low end of the y-scale to 0.0. This will display the data as if the y-values had 0 range, instead of the 10-13 range you used.

pTransform1.AutoScale(DatasetArray, ChartObj.AUTOAXES_FAR , ChartObj.AUTOAXES_FAR);
if (pTransform1.GetYScale().GetRange() < 10-13)
    pTransform1.ScaleStartY = 0;
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07