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

NullPointerException when chart tries to highlight in bar chart #1535

Closed
daveamol opened this issue Mar 2, 2016 · 2 comments
Closed

NullPointerException when chart tries to highlight in bar chart #1535

daveamol opened this issue Mar 2, 2016 · 2 comments

Comments

@daveamol
Copy link

daveamol commented Mar 2, 2016

Process: com..... , PID: 23804
java.lang.NullPointerException: Attempt to read from null array
at com.github.mikephil.charting.highlight.BarHighlighter.getStackedHighlight(BarHighlighter.java:108)
at com.github.mikephil.charting.highlight.BarHighlighter.getHighlight(BarHighlighter.java:37)
at com.github.mikephil.charting.charts.BarChart.getHighlightByTouchPoint(BarChart.java:97)
at com.github.mikephil.charting.listener.BarLineChartTouchListener.performHighlightDrag(BarLineChartTouchListener.java:382)
at com.github.mikephil.charting.listener.BarLineChartTouchListener.onTouch(BarLineChartTouchListener.java:157)
 at com.github.mikephil.charting.charts.BarLineChartBase.onTouchEvent(BarLineChartBase.java:663)
 at android.view.View.dispatchTouchEvent(View.java:8388)
 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2424)
 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2158)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
 at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
 at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2314)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1692)
at android.app.Activity.dispatchTouchEvent(Activity.java:2739)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2275)
at android.view.View.dispatchPointerEvent(View.java:8578)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4021)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3887)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5701)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5675)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5646)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootI

This happens If a bar entry is added with no Y values. Basically I supplied an empty array to a bar entry. When the graph tries to highlight the corresponding bar for it the activity crashes.

Since the graph accepts empty bar entries, then it should just try not to highlight an empty entry I assume but instead it crashes. Is there a way I can work around this other than just disabling the highlighting feature ?

@PhilJay
Copy link
Owner

PhilJay commented Mar 2, 2016

Yes you can work around this, just don't add an empty array.

Anyways, I will try to fix it.

@PhilJay PhilJay closed this as completed Mar 2, 2016
PhilJay added a commit that referenced this issue Mar 2, 2016
@dGorod
Copy link

dGorod commented Sep 9, 2016

@PhilJay the same situation happens with LineChart :( (version 3.0.0-beta)

regas99 pushed a commit to regas99/MPAndroidChart that referenced this issue Apr 1, 2019
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

3 participants