Zero is not zero

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
jrvdboom
Posts: 61
Joined: Thu Apr 10, 2014 1:50 pm

Zero is not zero

Post by jrvdboom » Thu Jun 25, 2015 1:44 pm

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.
Attachments
zero-not-zero.png
zero-not-zero.png (83.08 KiB) Viewed 9406 times

ArctionJari

Re: Zero is not zero

Post by ArctionJari » Fri Jun 26, 2015 10:23 am

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.

jrvdboom
Posts: 61
Joined: Thu Apr 10, 2014 1:50 pm

Re: Zero is not zero

Post by jrvdboom » Fri Jun 26, 2015 11:06 am

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.

Post Reply