MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

2 charts linking/zoom sync

Open igorvlassov opened this issue 9 years ago • 3 comments

Is there some method to synchronize gesture zoom of 2 charts with same x length? Say user zooms first chart and the second is zoomed on the same manner?

igorvlassov avatar Jan 04 '17 07:01 igorvlassov

Hi Igor, Please see my answer to your question on StackOverflow: In short, you would need to adapt/implement your own OnChartGestureListener to co-ordinate between the charts.

http://stackoverflow.com/a/41460255/5241933

drawers avatar Jan 04 '17 09:01 drawers

Dear @drawers Yes, I thought about gesture listener. Something like public void onChartScale(MotionEvent me, float scaleX, float scaleY){ oscChart.zoom(scaleX,scaleY, x, y); } The cuestión is how to find x, y which are coordinates of the center of translation. Will see.

igorvlassov avatar Jan 05 '17 09:01 igorvlassov

I managed with zoom center getting fingers' coords in onChartScale method of gesture listener. @Override public void onChartScale(MotionEvent me, float scaleX, float scaleY) { float xPos = (me.getX(0)+me.getX(1))/2f, yPos = (me.getY(0)+me.getY(1))/2f; chart2.fitScreen(); chart2.zoom(scaleX,scaleY, xPos, yPos); }

igorvlassov avatar Jan 06 '17 07:01 igorvlassov