今天用折线图出现了这个异常,信息如下:
java.lang.NegativeArraySizeException: -2
at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178)
at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:549)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:278)
at android.view.View.draw(View.java:16193)
at android.view.View.updateDisplayListIfDirty(View.java:15189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3605)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3585)
at android.view.View.updateDisplayListIfDirty(View.java:15149)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:902)
at android.view.Choreographer.doCallbacks(Choreographer.java:714)
at android.view.Choreographer.doFrame(Choreographer.java:648)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:888)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5468)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:671)
NegativeArraySizeException,翻译过来就是不合适的数组长度,一番查找原来是因为数据没有按照x轴排序,在设置数据之前按照x轴排序即可