Component: LineChart
Version: v3.0.0-beta1
The LineChart will throw an exception when it is filled with LineData containing a LineDataSet with no entries. As soon as an entry is added upon creation it will not throw the exception.
Is this intented behavior?
Working code:
ArrayList<Entry> data = new ArrayList<>();
data.add(new Entry(0, 0.0f));
throughputDataSet = new LineDataSet(data, "throughput");
Exception throwing code:
ArrayList<Entry> data = new ArrayList<>();
throughputDataSet = new LineDataSet(data, "throughput");
The exception trace:
java.lang.IndexOutOfBoundsException: Invalid index 17, size is 17
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.github.mikephil.charting.formatter.FormattedStringCache$PrimFloat.getFormattedValue(Unknown)
at com.github.mikephil.charting.formatter.DefaultAxisValueFormatter.getFormattedValue(Unknown)
at com.github.mikephil.charting.components.AxisBase.getFormattedLabel(Unknown)
at com.github.mikephil.charting.components.AxisBase.getLongestLabel(Unknown)
at com.github.mikephil.charting.renderer.XAxisRenderer.computeSize(Unknown)
at com.github.mikephil.charting.renderer.XAxisRenderer.computeAxisValues(Unknown)
at com.github.mikephil.charting.renderer.XAxisRenderer.computeAxis(Unknown)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(Unknown)
at android.view.View.draw(View.java:15231)
at android.view.View.updateDisplayListIfDirty(View.java:14167)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.View.draw(View.java:14959)
at android.view.ViewGroup.drawChild(ViewGroup.java:3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.draw(View.java:15234)
at com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:501)
at android.view.View.updateDisplayListIfDirty(View.java:14167)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2530)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
IS this issue solved? It still happens to me with the library version 3.0.2.
It happens the same, in a LineChart if the dataSet has no entries the IndexOutOfBounds exception happens, but if I add at least one entry it doesn't happen.
same issue with empty entries
Most helpful comment
IS this issue solved? It still happens to me with the library version 3.0.2.
It happens the same, in a LineChart if the dataSet has no entries the IndexOutOfBounds exception happens, but if I add at least one entry it doesn't happen.