Page 1 of 1

ZoomPanOptions with AspectRatio

Posted: Tue Sep 09, 2014 9:45 am
by jrvdboom
I wrote my own routine to scale the axes of a series, so I also have margins for the X axis. Works fine:
noaspect.png
noaspect.png (23.92 KiB) Viewed 9719 times
Now I need the show the same series with an aspect ratio of 1. The calculated axes ranges are the same as for the picture above, but now the series is shown like this:
aspectwrong.png
aspectwrong.png (22.99 KiB) Viewed 9719 times
As you see, the series is cut off because the aspect ratio adjusts the X axis to match the Y axis. Instead I would have expected the range to be increased to show the entire series, like this:
aspectright.png
aspectright.png (23.23 KiB) Viewed 9719 times
Is there a setting I must adjust to get the expected behavior? Or might it be a bug?

Thanks,
Joost

Re: ZoomPanOptions with AspectRatio

Posted: Mon Sep 15, 2014 5:20 am
by ArctionPasi
If graph area (width * aspectratio) < height, Y axis range is set by X range.
If graph area height < (width * aspectratio), X axis range is set by Y range.

It is by design.

Re: ZoomPanOptions with AspectRatio

Posted: Mon Sep 15, 2014 9:45 am
by jrvdboom
The I would like to propose an extension of the design (maybe through an extra setting):

When the min and max of the axes are explicitly set:
- if aspect ratio of axes > aspect ratio of graph, then Y is set by X
- if aspect ratio of axes < aspect ratio of graph, the X is set by Y

(where aspect ratio of axes = (max Y - min Y) / (max X - min X))

Re: ZoomPanOptions with AspectRatio

Posted: Mon Sep 15, 2014 10:08 am
by ArctionPasi
We can't do that unfortunately. There's no telling if the axis Minimum and Maximum properties are set by user or by internal zooming logic, panning, touch events, or SetRange method.

Please make your own logic based on event handlers of the chart. For example, hook into chart.SizeChanged, xAxis and yAxis RangeChanged, Zoomed etc. events, and calculate the new axis ranges based on your needs. If you do that, disable aspect ratio in ZoomPanOptions.

Re: ZoomPanOptions with AspectRatio

Posted: Mon Sep 15, 2014 10:14 am
by jrvdboom
You're right, min and max won't do. But what about the RangeRevertMinimum and RangeRevertMaximum, because those are the min and max I set in my custom logic. I also have ZoomPanOptions.RightToLeftZoomAction set to RevertAxisRanges.