Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoomAndCenterAnimated not centering on x value #4334

Open
a-bresler opened this issue Dec 5, 2018 · 7 comments
Open

zoomAndCenterAnimated not centering on x value #4334

a-bresler opened this issue Dec 5, 2018 · 7 comments

Comments

@a-bresler
Copy link

I'm trying to use the method zoomAndCenterAnimated on a line graph, but the result I get, no matter the x-value entered, is the graph zooming and centering on the very first data point.

I've tried implementing on the sample project with a simple y = x straight line graph and no matter which x;y value I choose to center on it still zooms in and centers on the first data point.

@fullmoon6661
Copy link

I got same issue, any work around?

@lpbas
Copy link

lpbas commented Jun 11, 2019

It happens to me as well, on the latest release of the library. Always zooms in at the first data point on the X axis.

@a-bresler
Copy link
Author

a-bresler commented Jun 11, 2019

I did figure it out but never posted a solution.

In AnimatedZoomJob.getInstance(...) the zoomCenter variables are never set. The parameters are passed but nothing is done to it.

If @PhilJay wants I can fork and push a request, but here's the fixed method so long:

public static AnimatedZoomJob getInstance(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) 
{

        AnimatedZoomJob result = pool.get();
        result.mViewPortHandler = viewPortHandler;
        result.xValue = scaleX;
        result.yValue = scaleY;
        result.mTrans = trans;
        result.view = v;
        result.xOrigin = xOrigin;
        result.yOrigin = yOrigin;
        result.yAxis = axis;
        result.xAxisRange = xAxisRange;
        result.resetAnimator();
        result.animator.setDuration(duration);
        result.zoomCenterX = zoomCenterX;
        result.zoomCenterY = zoomCenterY;
        result.zoomOriginX = zoomOriginX;
        result.zoomOriginY = zoomOriginY;
        return result;
    }

@lpbas
Copy link

lpbas commented Jun 11, 2019

Thanks for posting the fix here!

He hasn't merged any pull requests for the past 2 months, but I'm sure he will do so when he finds the time. Plus all of us will appreciate if you do!

mstniy added a commit to mstniy/MPAndroidChart that referenced this issue Apr 4, 2020
@ghost
Copy link

ghost commented Nov 16, 2021

I've encountering the same issue, is the fix closed with merge?

SimonJackler added a commit to SimonJackler/MPAndroidChart that referenced this issue Dec 18, 2023
…n coordinates.

In static method AnimatedZoomJob:getInstance added the assignment of the parameters zoomCenterX, zoomCenterY, zoomOriginX, zoomOriginY.
@SimonJackler
Copy link

Five years later and still the same issue. I created a PR with the fix @a-bresler suggested. Hopefully it gets merged.

hannesa2 pushed a commit to AppDevNext/AndroidChart that referenced this issue Feb 1, 2024
…n coordinates.

In static method AnimatedZoomJob:getInstance added the assignment of the parameters zoomCenterX, zoomCenterY, zoomOriginX, zoomOriginY.
hannesa2 added a commit to AppDevNext/AndroidChart that referenced this issue Feb 1, 2024
…nterAnimated

Fixes zoomAndCenterAnimated did not center on coordinates
@hannesa2
Copy link
Contributor

hannesa2 commented Feb 1, 2024

Five years later and still the same issue. I created a PR with the fix @a-bresler suggested. Hopefully it gets merged.

While you wait for a merge (the last was 3 years ago), I merged it here already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants