Fatal Exception: java.lang.NegativeArraySizeException: -2
Version 3.1.0 pre-release
Fatal Exception: java.lang.NegativeArraySizeException: -2
at androidx.appcompat.widget.TooltipCompat.com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(SourceFile:2178)
at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(SourceFile:549)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(SourceFile:278)
at android.view.View.draw(View.java:17214)
at android.view.View.updateDisplayListIfDirty(View.java:16196)
at android.view.View.draw(View.java:16980)
at android.view.ViewGroup.drawChild(ViewGroup.java:3729)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3515)
at android.view.View.updateDisplayListIfDirty(View.java:16191)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3713)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3693)
at android.view.View.updateDisplayListIfDirty(View.java:16159)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:648)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:654)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:762)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2841)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2649)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2256)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1295)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6400)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:876)
at android.view.Choreographer.doCallbacks(Choreographer.java:688)
at android.view.Choreographer.doFrame(Choreographer.java:623)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:862)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6396)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Can you please give the code that causes this, as I really can't tell what's happened to cause count to be negative. Basically, the max value in your data is actually smaller than the min, causing it to be negative.
I'm certain this isn't the fault of the library, but rather you have done something out of order. Please create a gist of the code that is called before your chart is drawn.
I clearly understand that on your side. But on my side the code is really to long and can't be shared here to understand the logic. But i wonder if this can be solved with a try-catch in the library, because in fact this issue doesn't make any weird change in the chart view but just crash the app. So if this is possible i think will be more easy to just solve for the moment
Understandable, and I agree that this library needs more redundancy checks to reduce this sort of stuff from happening, as right now it's kinda fragile.
Thank you for your support ! This is sometime more important than a bug. Waiting for sulution.
You need to ensure your datas to show are in order or they may cause this issue.
Does anyone know if this bug is fixed?
I solved this bug like this way. The reason of this issue is on data when you are adding. I added the data as reversed because I wanted to use this graph as timeline, which means adding data.add(x, y) as x.reversed order. ex: data.add(Entry(3, 100) data.add(Entry(2, 50) data.add(Entry(1, 150)
It causes the bug because the parameter of the 'x' is up to reversed order By sorting 'x' as ascending order, issue solved ex: data.add(Entry(1, 150) data.add(Entry(2, 50) data.add(Entry(3, 100)
There's no way if this solution doesn't work at all.
Sorry for my bad English :)
look this library MPFreeChart