SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

Hi,

Is it possible to require two finger touch to pan the chart horizontally? I have a line chart with a rollover modifier so I don’t want to pan when I am moving the rollover modifier.

Version
3.0.1.4266
  • You must to post comments
0
0

Hi Erika,

Unfortunately we don’t support such behavior out of the box, but you can implement it by creating custom RolloverModifier and ZoomPanMovifiers which won’t interrupt each other:

class CustomRolloverModifier extends RolloverModifier {
    @Override
    public void onTouch(ModifierTouchEventArgs args) {
        final int pointerCount = args.e.getPointerCount();
        if(pointerCount == 1)
            super.onTouch(args);
        else if(pointerCount == 2) // remove rollover if 2 fingers
            clearAll();
    }
}

class CustomZoomPanModifier extends ZoomPanModifier {
    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float xDelta, float yDelta) {
        if(e2.getPointerCount() == 2) // process scroll only if there were two fingers
            return super.onScroll(e1, e2, xDelta, yDelta);

        return false;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        if(e2.getPointerCount() == 2) // process fling only if there were two fingers
            return super.onFling(e1, e2, velocityX, velocityY); 

        return false;
    }
}

Then add them into chart:

final ZoomPanModifier zoomPanModifier = new CustomZoomPanModifier();
zoomPanModifier.setReceiveHandledEvents(true);

final RolloverModifier rolloverModifier = new CustomRolloverModifier();

Collections.addAll(surface.getChartModifiers(),  sciChartBuilder.newModifierGroup().withModifier(rolloverModifier).withModifier(zoomPanModifier).build());

Is this suitable for your needs?

Best regards,
Yura

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.