4

When more than some datasets (around 6 or more) to a line graph, we are getting an exception.
This is the detail:

 java.lang.IllegalArgumentException: One or more of the DataSet Entry arrays are longer than the x-values array of this ChartData object.
 at com.github.mikephil.charting.data.ChartData.isLegal(ChartData.java:173)
 at com.github.mikephil.charting.data.ChartData.init(ChartData.java:130)
 at com.github.mikephil.charting.data.ChartData.<init>(ChartData.java:96)
 at com.github.mikephil.charting.data.BarLineScatterCandleData.<init>(BarLineScatterCandleData.java:27)
 at com.github.mikephil.charting.data.LineData.<init>(LineData.java:27)

I am not able to understand the reason why.
I am using MPAndroidChart to plot the graph.
When more data sets are entered, we are getting that exception.

1
  • 1
    The error is quite clear: you have more elements in DataSet than the ones in the x-values. Please post your code if you want others to be able to help you. Commented Aug 4, 2015 at 8:36

1 Answer 1

7

The error is exactly as explained. Heres it visually in case its a language barrier

............................---------------------------
Chart .................|. 1 ... 2 ... 3 ... 4 ... 5 .|
Data Set 1 .........|. a ... b ... c ... d ... e .|
Data Set 2 .........|. a ... b ... c ... d ... e .|
Data Set 3 .........|. a ... b ... c ... d ... e .|
Data Set 4 .........|. a ... b ... c ... d ... e .|
Data Set 5 .........|. a ... b ... c ... d ... e .|
Data Set 6 .........|. a ... b ... c ... d ... e .|
Data Set 7 .........|. a ... b ... c ... d ... e .|... f ... g
............................---------------------------

As you can see the last data set has too many items to fit into the chart so the app does not know how to handle it and throws an error

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.