The Wayback Machine - https://web.archive.org/web/20210111193458/https://github.com/PhilJay/MPAndroidChart/issues/5054
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

BarChart crashes if bar has no values #5054

Open
Athameon opened this issue Nov 26, 2020 · 0 comments
Open

BarChart crashes if bar has no values #5054

Athameon opened this issue Nov 26, 2020 · 0 comments

Comments

@Athameon
Copy link

@Athameon Athameon commented Nov 26, 2020

Situation:
I've got a stacked bar chart where each stack has a different amount of entries.
To get the correct colors (All first entries have the same color, all second entries, ...) I created for each x value bar entry an array that is greater than its values eg: new BarEntry(index, [4, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, ...].
The size of the array is the size of the available colors, so each BarEntry y value has the same color.
But if I now click into the empty area where no BarEntry exists, it tries to get an invalid BarChart value.

The problem is in BarHighlighter:getStackedHighlight Line 66: entry.getRanges(); which returns null.

CallStack:
E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to get length of null array
at com.github.mikephil.charting.highlight.BarHighlighter.getStackedHighlight(BarHighlighter.java:68)
at com.github.mikephil.charting.highlight.BarHighlighter.getHighlight(BarHighlighter.java:34)
at com.github.mikephil.charting.charts.BarChart.getHighlightByTouchPoint(BarChart.java:96)
at com.github.mikephil.charting.charts.BarLineChartBase.getDataSetByTouchPoint(BarLineChartBase.java:1371)
at com.github.mikephil.charting.listener.BarLineChartTouchListener.saveTouchStart(BarLineChartTouchListener.java:307)
at com.github.mikephil.charting.listener.BarLineChartTouchListener.onTouch(BarLineChartTouchListener.java:127)
at com.github.mikephil.charting.charts.BarLineChartBase.onTouchEvent(BarLineChartBase.java:581)
at android.view.View.dispatchTouchEvent(View.java:9943)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2663)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2344)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2301)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:411)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1810)
at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:373)
at android.view.View.dispatchPointerEvent(View.java:10163)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4434)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3995)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4052)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6210)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6184)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6145)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6313)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
D/AndroidRuntime: Shutting down VM

@Athameon Athameon mentioned this issue Nov 26, 2020
2 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.