Pre loader

Sync Multiple Charts same Pinch zoom modifier

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

Hi there,

I’am using your example that name is SyncMultipleChartsFragment.
I want to share pinch zoom modifier all other charts. Your example provides “ModifiersSharedEventsGroup” . When zooming on chart other charts handle this zoom operation. In this case, fingers are just in a chart.
How can I make a finger zoom on 1 chart while the other finger is on a different chart.

Below I’am sharing a video about this problem.
Link of video : https://drive.google.com/file/d/1u42p9-vEQNxPzN56jF3QOjZIVUlOyyXx/view

Thank you very much,
Have a good day,

Version
SciChart_Android_v2.2.0.2324_SDK
  • You must to post comments
0
0

Hi Adem,

Well this isn’t possible because in case from video Android reports it as 2 separated touch events which occurs on two separate Views. In this case ScaleGestureDetector doesn’t recognize gesture because technically there is no scale gesture.

The only way to implement the behavior which you require is to place View which covers desired space, set touch listener for it and redirect its MotionEvents into PinchZoomModifier which is attached to chart.

Here is modified layout with View on top of two charts which should intercept touch events from both charts:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
tools:context=".fragments.SyncMultipleChartsFragment">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.scichart.charting.visuals.SciChartSurface
        android:id="@+id/chart0"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <com.scichart.charting.visuals.SciChartSurface
        android:id="@+id/chart1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" />
</LinearLayout>

<View
    android:layout_width="match_parent"
    android:layout_height="match_parent" android:id="@+id/view" />

</FrameLayout>

Here is modified code of example with code where OnTouchListener implementation manually invokes onTouch() for modifier with its MotionEvent ( I removed some code from example to highlight only sections which were changed ):

public class SyncMultipleChartsFragment extends ExampleBaseFragment implements View.OnTouchListener {

@BindView(R.id.view)
View view;

private PinchZoomModifier pinchZoomModifier;

@Override
protected void initExample() {
    initChart(chart0);
    initChart(chart1);

    pinchZoomModifier = new PinchZoomModifier();

    view.setOnTouchListener(this);

    chart0.getChartModifiers().add(pinchZoomModifier);
}

@Override
public boolean onTouch(View v, MotionEvent event) {
    final ModifierTouchEventArgs args = new ModifierTouchEventArgs();
    args.e = event;

    pinchZoomModifier.onTouch(args);

    return args.isHandled;
}
}

I’m not sure that it’ll work for all cases but hope this will help you!

Best regards,
Yura

  • Adem Hacıoğlu
    Hi Yuri, Thank you very much your quick answer. It was exaclty what I want. Regards,
  • You must to post comments
Showing 1 result
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