I have CategoryDateAxis and whant to setup range limit from series size – 50 to series size + 10
mBottomAxis.setVisibleRangeLimit(new DoubleRange(series.size() - 50d, series.size() + 10d));
mBottomAxis.setVisibleRangeLimitMode(RangeClipMode.MinMax);
And this code works but not as I expected
When I scrol chalt and hits the range limit scroll is stopped BUT chart is zooming in
How to disable zooming when I hits the limit?
- Evgeny Khramov asked 6 years ago
- last edited 6 years ago
- You must login to post comments
Hi Evgeny,
Thanks for your enquiry.
Well this is how scroll is working by default for now. If you need different behavior you can always customize it by creating custom IAxisInteractivityHelper which is responsible for scrolling, zooming functionality of axis. Here is an example which should provide desired behavior:
public static class CustomNumericAxis extends NumericAxis {
public CustomNumericAxis(Context context) {
super(context);
}
@Override
protected IAxisInteractivityHelper createInteractivityHelper(ICoordinateCalculator currentCoordinateCalculator) {
final IAxisInteractivityHelper defaultAxisInteractivityHelper = super.createInteractivityHelper(currentCoordinateCalculator);
return new AxisInteractivityHelperWrapper(defaultAxisInteractivityHelper, this);
}
private static class AxisInteractivityHelperWrapper implements IAxisInteractivityHelper {
private final IAxis axis;
private final IAxisInteractivityHelper axisInteractivityHelper;
public AxisInteractivityHelperWrapper(IAxisInteractivityHelper axisInteractivityHelper, IAxis axis) {
this.axisInteractivityHelper = axisInteractivityHelper;
this.axis = axis;
}
@Override
public void zoom(IRange range, float fromCoord, float toCoord) {
axisInteractivityHelper.zoom(range, fromCoord, toCoord);
}
@Override
public void zoomBy(IRange range, double minFraction, double maxFraction) {
axisInteractivityHelper.zoomBy(range, minFraction, maxFraction);
}
@Override
public void scrollInMinDirection(IRange range, float pixels) {
axisInteractivityHelper.scrollInMinDirection(range, pixels);
axisInteractivityHelper.clipRange(range, axis.getVisibleRangeLimit(), ClipMode.ClipAtExtents);
}
@Override
public void scrollInMaxDirection(IRange range, float pixels) {
axisInteractivityHelper.scrollInMaxDirection(range, pixels);
axisInteractivityHelper.clipRange(range, axis.getVisibleRangeLimit(), ClipMode.ClipAtExtents);
}
@Override
public void scroll(IRange range, float pixels) {
axisInteractivityHelper.scroll(range, pixels);
axisInteractivityHelper.clipRange(range, axis.getVisibleRangeLimit(), ClipMode.ClipAtExtents);
}
@Override
public <T extends Comparable<T>> void clipRange(IRange<T> range, IRange<T> maximumRange, ClipMode clipMode) {
axisInteractivityHelper.clipRange(range, maximumRange, clipMode);
}
}
}
Please try it and let me know if it’s suitable for your needs.
Best regards,
Yura.
- Yura Khariton answered 6 years ago
- You must login to post comments
Hi Evgeny,
I just remembered that I forgot to ask if you have tried to set ClipModeX for ZoomPanModifier:
zoomPanModifier.setClipModeX(ClipMode.ClipAtExtents);
I believe it should provide the same result because by default ZoomPanModifier doesn’t apply any clipping
Best regards,
Yura
- Yura Khariton answered 6 years ago
-
perfect , thank you
- You must login to post comments
Thank you very much for the quick reply
I checked this code and its works as i need
And I will try your second advice
- Evgeny Khramov answered 6 years ago
- You must login to post comments
Second advice works as well
Thank you very much
- Evgeny Khramov answered 6 years ago
- You must login to post comments
Please login first to submit.