diff --git a/hellocharts-library/src/lecho/lib/hellocharts/ChartCalculator.java b/hellocharts-library/src/lecho/lib/hellocharts/ChartCalculator.java index 74e726d5..95774cd6 100644 --- a/hellocharts-library/src/lecho/lib/hellocharts/ChartCalculator.java +++ b/hellocharts-library/src/lecho/lib/hellocharts/ChartCalculator.java @@ -29,7 +29,11 @@ public class ChartCalculator { protected float minViewportWidth; protected float minViewportHeight; - private ViewportChangeListener viewportChangeListener = new DummyVieportChangeListener(); + /** + * Warning! Viewport listener is disabled for all charts beside preview charts to avoid addidtional method calls + * during animations. + */ + protected ViewportChangeListener viewportChangeListener = new DummyVieportChangeListener(); /** * Calculates available width and height. Should be called when chart dimensions or chart data change. @@ -74,8 +78,6 @@ public void constrainViewport(float left, float top, float right, float bottom) currentViewport.top = Math.max(maxViewport.top, top); currentViewport.bottom = Math.max(Utils.nextUpF(top), Math.min(maxViewport.bottom, bottom)); currentViewport.right = Math.max(Utils.nextUpF(left), Math.min(maxViewport.right, right)); - - viewportChangeListener.onViewportChanged(currentViewport); } /** diff --git a/hellocharts-library/src/lecho/lib/hellocharts/DummyVieportChangeListener.java b/hellocharts-library/src/lecho/lib/hellocharts/DummyVieportChangeListener.java index 29cf6f58..79af60ac 100644 --- a/hellocharts-library/src/lecho/lib/hellocharts/DummyVieportChangeListener.java +++ b/hellocharts-library/src/lecho/lib/hellocharts/DummyVieportChangeListener.java @@ -1,7 +1,6 @@ package lecho.lib.hellocharts; import android.graphics.RectF; -import android.util.Log; public class DummyVieportChangeListener implements ViewportChangeListener { diff --git a/hellocharts-library/src/lecho/lib/hellocharts/PreviewChartCalculator.java b/hellocharts-library/src/lecho/lib/hellocharts/PreviewChartCalculator.java index 7c07169a..b6f46b3d 100644 --- a/hellocharts-library/src/lecho/lib/hellocharts/PreviewChartCalculator.java +++ b/hellocharts-library/src/lecho/lib/hellocharts/PreviewChartCalculator.java @@ -22,4 +22,9 @@ public void setVisibleViewport(RectF visibleViewport) { setMaxViewport(visibleViewport); } + public void constrainViewport(float left, float top, float right, float bottom) { + super.constrainViewport(left, top, right, bottom); + viewportChangeListener.onViewportChanged(currentViewport); + } + } \ No newline at end of file