Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set max pinch zoom in MPAndroidChart

I m coding a line chart using MPAndroidChart, my code works without any error but pinch zooming goes to infinity, because of that in some devices CPU has 100%. How can i restrict max pinch zoom?

like image 390
Birgul Ozlem Avatar asked Dec 24 '22 16:12

Birgul Ozlem


1 Answers

The mpandroidhchart developer implemented this in this commit: https://github.com/PhilJay/MPAndroidChart/commit/ba152072a6a7adbf8e9e166904798219c1200172

But I'm still waiting for a new release version. Further, you just need to call

chart.getViewPortHandler().setMaximumScaleX(2f);
chart.getViewPortHandler().setMaximumScaleY(2f);

And this will limit the zoom in factor 2

like image 62
rafaelasguerra Avatar answered Jan 11 '23 14:01

rafaelasguerra