This might be a stupid question. 😀 But I tried several things and nothing seems to work…
I have a chart that has several different datasets that can be switched to. When I apply them and do zoom to extents it changes the Y Axis sometimes 1-15, sometimes 1-20, sometimes 1-25. So the chart zooms in/out, which looks nice.
However I would like to fix the initial zoom to be always be 1-20. If the chart is smaller or bigger than 20; that is fine; I just want the initial viewport to always zoom to be 1-20, when I switch the dataset. They can then zoom in/out or pan using gestures.
Any ideas on what API I need to call to zoom the chart to 1-20. (Please note, this is using a logarithmic scale on the Y-Axis — if it makes any differences).
So what do I need to call/set rather than calling the zoom to extents function.
- You must login to post comments
Hi Nathanael,
I’m not sure how you perform zoom extents in your application, but you just need to set VisibleRange and configure chart to not update it.
- If you use AutoRange.Always just set it to AutoRange.Never for YAxis.
- If you use ZoomExtentsModifier just set Direction = Direction2D.XDirection to disable zoom extents for YAxis
- If you use chart’s zoomExtents() method, then just use overload which affects only XAxis – zoomExtentsX()
Hope this will help you!
Best regards,
Yura
- Yura Khariton answered 3 years ago
- To add to this. Zoom extents, always zooms to the extents of your data, always. I would suggest maybe a custom modifier? Override ChartModifierBase and the double tap gesture and set XAxis/YAxis.VisibleRange. We have loads of examples of custom modifiers for WPF, @Yura do we have one for Android?
- I am currently using ZoomExtents() — However, I’m willing to use whatever works best. I don’t want to STOP zooming on the Y axis — I still want the user to be able to zoom it in and out. What I want to do is when I refresh the data, reset the zoom on the Y axis to be 1-20 again. So basically it would act like the zoomExtents command, but always zoom me to a preset Y Axis? Does that make sense?
- You must login to post comments
Please login first to submit.