Mpandroidchart: IndexOutOfBoundsException with CombineChart

Created on 5 Feb 2016  路  5Comments  路  Source: PhilJay/MPAndroidChart

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)

Most helpful comment

This should be fixed in v3.0.0

All 5 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chathudan picture chathudan  路  3Comments

OnlyInAmerica picture OnlyInAmerica  路  3Comments

Giammaofwar picture Giammaofwar  路  3Comments

DarkHelmet67 picture DarkHelmet67  路  3Comments

SutharRohit picture SutharRohit  路  3Comments