Page 1 of 1

Zero is not zero

Posted: Thu Jun 25, 2015 1:44 pm
by jrvdboom
Sometimes an axis doesn't show zero where it should. See Y axis in the attachment. Reproducable by zooming in and panning around a little.

Re: Zero is not zero

Posted: Fri Jun 26, 2015 10:23 am
by ArctionJari
This is most likely result of Double value rounding inaccuracy. In normal life that value (1.7E-24) is zero but 0.0000...0017 is not exactly zero when it is parsed to string.

You can however parse the values yourself if you know how accurate values you need. Just subscribe to axis' FormatValueLabel and use e.g. Math.Round to round values with required fractional digit count.

Re: Zero is not zero

Posted: Fri Jun 26, 2015 11:06 am
by jrvdboom
It's definitely double inaccuracy, but caused by the fact that the labels are calculated from one side of the axis to the other. If you start labelling a 0, zero would actually be 0 no matter the zoom level/padding. Another solution might determine the step value between the labels (you probably already do that!) and if the calculated value is less than the step, replace the value with 0.

In my opinion it's a bug that can easily be fixed and not something I, as a user, must workaround with subscribing to FormatValueLabel and rounding myself.