Page 1 of 1

Overriding scaling decisions in YAxis Autofit

Posted: Fri Jan 20, 2017 10:56 am
by NielsUll
Hi!

For some xy graphs, we would like handle scaling in a customized way: The Y minimum should be 0 and the Y maximum should always be rounded up to 10^n, 2*10^n or 5*10^n.
So 0.01, 200 or 5, but not 15 or 3.5 - in this case the axis should go to 20 or 5 respectively.

Now, we can do the computation ourselves, given the max Y value - but is there an easy way to make this be called when AutoFit is used?

Re: Overriding scaling decisions in YAxis Autofit

Posted: Sun Jan 22, 2017 7:34 am
by ArctionPasi
Hello.

You can set chart.ViewXY.ZoomPanOptions.RightToLeftZoomAction = RevertAxisRanges.

When applying zoom-to-fit gesture (default action for right-to-left zooming) it will set X and Y axes ranges from

xAxis.RangeRevertMinimum to xAxis.RangeRevertMaximum

and

yAxis.RangeRevertMinimum to yAxis.RangeRevertMaximum

So, store your preferred scaling values in these properties.

If you want to exclude either axis from range revert, set that axis' RangeRevertEnabled = False.

I hope this helps :)

Re: Overriding scaling decisions in YAxis Autofit

Posted: Mon Jan 23, 2017 7:19 am
by NielsUll
I'm afraid this is not exactly what i was looking for.
Assume we have s graph that's more or less a straight line from 0,0 to 100,100.
Now, the user zooms in on the xrange to see [5;30]. In this case, I want the YAxis to adjust to [0;50].
When he then zooms further into [8;12], I want the YAxis to adjust to [0;20].

Re: Overriding scaling decisions in YAxis Autofit

Posted: Mon Jan 23, 2017 7:53 am
by ArctionPasi
Ok. Please set RangeChanged event handler for the X axis. In the event handler, call yAxis.SetRange with preferred range.