Correct implementation of FormatValueLabel?

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

NielsUll
Posts: 19
Joined: Thu Jan 19, 2017 8:23 am

Correct implementation of FormatValueLabel?

Post by NielsUll » Tue Mar 14, 2017 2:40 pm

Hi!

I need to implement a FormatValueLabel handler, since we need values displayed with SI suffixes for kilo, milli, giga etc - e.g. "23.451m" instead of "0,023451" or "2,3451E-2".

However, I cannot figure out how many decimals to show? I tried to use FormatValueLabelEventArgs.Axis.MajorDiv,
but that seems to just return (max-min)/Axis.MajorDivCount? And this make me generate numbers with way too few digits, especially when zooming?
How can I find out what the numerical distance between labels are, so I can generate a sufficient number of digits?

The built in formatting seems to do it nicely, but doesn't fit our requirements?
Or is there another way to do this?

ArctionKestutis
Posts: 400
Joined: Mon Mar 14, 2016 9:22 am

Re: Correct implementation of FormatValueLabel?

Post by ArctionKestutis » Tue Mar 14, 2017 3:25 pm

Hi,

There is Axis.Units property tree. You could make it visible and have any text. Would it be useful in this case?

NielsUll
Posts: 19
Joined: Thu Jan 19, 2017 8:23 am

Re: Correct implementation of FormatValueLabel?

Post by NielsUll » Tue Mar 14, 2017 4:36 pm

I assume this would require us to rescale all the actual values?

That would be a bit impractical - the user might start with a plot from [-2;2] but then zoom in to see [-0.150 ; 0.150] - we need to show the labels as e.g. -150m, -100m, -50m, 0, 50m, 100m, 150m

So I don't think that would work?

User avatar
ArctionPasi
Posts: 1366
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: Correct implementation of FormatValueLabel?

Post by ArctionPasi » Tue Mar 14, 2017 7:14 pm

Hello, you could also utilize axis.GetMajorTicks() to learn the tick positions. Use that info to format the labels. Note that GetMajorTicks returns the latest rendered positions.

Using CustomAxisTicks is the "ultimate" way to do it, you get explicit control of positions of ticks, and formatting of labels as you can enter any text in the CustomAxisTicks. Remember to set axis.AutoFormatLabels =false, otherwise automatic formatting takes over.
LightningChart Support Team, PT

NielsUll
Posts: 19
Joined: Thu Jan 19, 2017 8:23 am

Re: Correct implementation of FormatValueLabel?

Post by NielsUll » Wed Mar 15, 2017 8:25 am

Thank you - just what I needed!