Skip to content

Commit

Permalink
override isLegal() to check unique X values in Yvals arrayList
Browse files Browse the repository at this point in the history
  • Loading branch information
simplaapliko committed Jul 25, 2015
1 parent d09b039 commit 0f3ff7f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions MPChartLib/src/com/github/mikephil/charting/data/LineData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
* Data object that encapsulates all data associated with a LineChart.
Expand Down Expand Up @@ -44,4 +46,28 @@ private static List<LineDataSet> toList(LineDataSet dataSet) {
sets.add(dataSet);
return sets;
}


// overridden methods

@Override
protected void isLegal() {
if (mDataSets == null)
return;

for (int i = 0; i < mDataSets.size(); i++) {

List<Entry> yVals = mDataSets.get(i).getYVals();
Set<Integer> uniqueX = new TreeSet<Integer>();

for (Entry e : yVals) {
uniqueX.add(e.getXIndex());
}

if (uniqueX.size() > mXVals.size()) {
throw new IllegalArgumentException(
"One or more of the DataSet Entry arrays are longer than the x-values array of this ChartData object.");
}
}
}
}

0 comments on commit 0f3ff7f

Please sign in to comment.