Page 1 of 1

Correct implementation of FormatValueLabel?

Posted: Tue Mar 14, 2017 2:40 pm
by NielsUll
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?

Re: Correct implementation of FormatValueLabel?

Posted: Tue Mar 14, 2017 3:25 pm
by ArctionKestutis
Hi,

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

Re: Correct implementation of FormatValueLabel?

Posted: Tue Mar 14, 2017 4:36 pm
by NielsUll
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?

Re: Correct implementation of FormatValueLabel?

Posted: Tue Mar 14, 2017 7:14 pm
by ArctionPasi
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.

Re: Correct implementation of FormatValueLabel?

Posted: Wed Mar 15, 2017 8:25 am
by NielsUll
Thank you - just what I needed!