Having CombineChart with Line and Scatter Chart
Causing below crash when XAxis have 39 items
java.lang.IndexOutOfBoundsException: Invalid index 42, size is 39
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.github.mikephil.charting.renderer.XAxisRenderer.drawLabels(XAxisRenderer.java:157)
at com.github.mikephil.charting.renderer.XAxisRenderer.renderAxisLabels(XAxisRenderer.java:102)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:267)
Show how you add the data and setup the chart.
I think I'm seeing the same issue on MPAndroidChart:v2.2.3.
(This issue does not happen on v2.1.6.)
It seems the issue happens when there is no data at all.
XAxisRenderer.drawLabels()
String label = mXAxis.getValues().get(i);
There is no data, but this line tries to get(0), and causes IndexOutOfBoundsException.
UncaughtException: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.github.mikephil.charting.renderer.XAxisRenderer.drawLabels(Unknown Source)
at com.github.mikephil.charting.renderer.XAxisRenderer.renderAxisLabels(Unknown Source)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(Unknown Source)
This should be fixed in v3.0.0
Can we do something just to fix it meanwhile?
@motis10 @PhilJay @umeshkrpatel
I am wondering if there is a workaround to this bug instead of upgrading library to 3.0.0?
Most helpful comment
This should be fixed in v3.0.0