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,
- Adem Hacıoğlu asked 5 years ago
- You must login to post comments
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
- Yura Khariton answered 5 years ago
-
Hi Yuri, Thank you very much your quick answer. It was exaclty what I want. Regards,
- You must login to post comments
Please login first to submit.