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

drawMarkers() in PieChart's onDraw() is looking for X-Axis, giving NullPointer #1713

Closed
swarajsaaj opened this issue Apr 24, 2016 · 3 comments

Comments

@swarajsaaj
Copy link

While setting a MarkerView for PieChart , I get a runtime exception,

 java.lang.NullPointerException: Attempt to read from field 'float com.github.mikephil.charting.components.AxisBase.mAxisRange' on a null object reference
                                                                                   at com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:673)
                                                                                   at com.github.mikephil.charting.charts.PieChart.onDraw(PieChart.java:136)

After some analysis, I found the Chart class is calculating deltaX from XAxis mXAxis object.
But for a pie chart there is no X-Axis?

Is there something wrong in this?

@PhilJay
Copy link
Owner

PhilJay commented Apr 24, 2016

I think you are using an older version of the library. Could you post the code snippet where this issue occurs in the library?

For me, the code looks like this, which would prevent nullpointer:

            float deltaX = mXAxis != null 
                ? mXAxis.mAxisRange
                : ((mData == null ? 0.f : mData.getXValCount()) - 1.f);

@swarajsaaj
Copy link
Author

Hi Phil,
I am using 2.2.4 (released 24 days ago)
but I see this was fixed 12 days ago
in this commit

@PhilJay
Copy link
Owner

PhilJay commented Apr 25, 2016

Awesome, I will close it then. New release will be out soon.

@PhilJay PhilJay closed this as completed Apr 25, 2016
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

2 participants