Mpandroidchart: How to clear / reset chart zoom?

Created on 16 Sep 2014  路  7Comments  路  Source: PhilJay/MPAndroidChart

Hi Phil,

Probably I missed something, but
is there any way to clear chart Zoom factor?

Use case:

  1. display chart with mChart.setData(...)
  2. user zoom in with pinch zoom gesture
  3. now, when displaying another one data with mChart.setData(...), user expects that new Chart will be displayed with default zoom scale factor

Looks like no way to achieve this behavior right now without re-initialization mChart.
Thanks in advance!

Most helpful comment

Yes, there is. You can call fitScreen().

Regards,
Phil

All 7 comments

Yes, there is. You can call fitScreen().

Regards,
Phil

You save my day! Works like a charm, thank you!
Closing it now

I have tried FitScreen() after zooming graph by double tap,but its doing nothing in my case instead of restoring the graph to initial zoom state.Please help.

fitScreen() not work as expected in my case. Sometimes it works & sometimes not.

I have a button which executes the lineChart.fitScreen() after clicking on it. But when I scroll and click on button immediately, nothing happens. How can I provide more priority to fitScreen() method over scrolling effect ??

Same as others - fitScreen() does not always work - sometimes working and sometimes not - even after calling invalidate(). Also tried resetZoom()

fitScreen() for Barchart works for me

chart.setFitBars(true)
chart.fitScreen()
chart.invalidate()
Was this page helpful?
0 / 5 - 0 ratings