Mpandroidchart: Scroll and zoom multiple charts simultaneously

Created on 15 Mar 2016  路  2Comments  路  Source: PhilJay/MPAndroidChart

I have a screen with several chartviews on it.

What I need is to when user scrolls/zooms one chart, other charts scroll and zoom also.

I know that on IOS, you can set a scale and translate listener and use refreshWithNewMatrix method to update all views with new scroll/zoom data. But on Android I tried to set ChartGestureListener and invoke this method in onChartScale and onChartTranslate but it only returned my views (that I need to scroll/scale programmatically) to fitscreen.

Please, tell if this feature is supported on Android? Or maybe there is a better way to do this?

Most helpful comment

All 2 comments

In your onChartScale callback, why don't you retrieve the scale/scroll as:

float scaleX = chart.getScaleX();
float scaleY = chart.getScaleY();
float xValue = chart.getViewPortHandler().getContentCenter().x;
float yValue = chart.getViewPortHandler().getContentCenter().y;

and then set the scale/scroll on your other charts using:

otherchart.getViewPortHandler().setZoom( scaleX, scaleY, xValue, yValue );

But seriously, this sort of question belongs to stackoverflow and not here.

Was this page helpful?
0 / 5 - 0 ratings