Pre loader

Disable zooming when hits chart limit

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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?

Version
2.1.0.2210
  • You must to post comments
0
0

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.

  • You must to post comments
0
0

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

  • tran hai
    perfect , thank you
  • You must to post comments
0
0

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

  • You must to post comments
0
0

Second advice works as well
Thank you very much

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies