SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components
Is there an example of building a custom axis using a long or ulong?
So far I’ve tried implementing AxisBase and created necessary types for the given interfaces (IRange, IDeltaCalculator, IAxisDelta). But after implementing the minimum set of pieces, the chart comes up blank.
Also strangely the only two functions that get called on the AxisBase implementation are
IsOfValidType() — This gets called with a DoubleRange rather than my ULongRange.. Somehow a DoubleRange is being introduced, but I can’t see how.
Is there any good documentation/design info out there about how to do this?
I have attached the solution I’ve been working with.
For a bit of context here.
SciChart internally uses Doubles for most computations, for example, converting data-coordinates to pixels, issuing of drawing commands etc… We have to use the highest common denominator for precision throughout (which is Double-64bit) despite data storage being generic. Making generic axis is out of the question since Xaml hates generics on types. Making a custom axis is also out of the question since more parts in SciChart rely on DateTime-Double conversion, such as Coordinate Calculation, Drawing Commands and more.
When converting from DateTime -> Double it is possible to lose some precision. This is because DateTime has 64-bit precision for all values allowing down to 100ns increment, whereas Double only has 52-bits mantissa and 11 bits exponent, plus 1 bit sign. Going from 64-bit to 52 means that if you use DateTime in your axis and require 100ns on the time scale, then you will start to experience this precision loss. Sadly there is no Long-Double type in .NET (like C++) and decimal, while 128 bit, does not have the dynamic range of double, so it is unusable.
As a result, we are at an impasse. Unable to solve this problem.
We do have a good workaround however. It is to use NumericAxis and LabelProvider (thanks to Paul Frivold for confirming its use in the field)!
For example, if your data ranges from 1st Jan 2016 – 1st Jan 2017 and you want a scale of 100ns, you can represent the data like this:
Now use LabelProvider to format the labels as a Start Date plus 100*X nanoseconds, where X is the X-value.
The LabelProvider API feeds into both axis labels and tooltips so your users will be unaware you are using whole numbers under the hood.
Let me know if this helps,
Please login first to submit.