getDataSetIndexForIndex method
Index of the data set that holds an entry at the given x value.
xIndex is the x value to look for. Returns the data set index, or -1 when there is no data or no entry has
that x value. Every PieEntry has the x value 0 and the lookup rounds to the closest entry, so any xIndex
finds the set once it holds an entry.
Implementation
int getDataSetIndexForIndex(int xIndex) {
final dataSets = data?.dataSets;
if (dataSets == null) return -1;
for (var i = 0; i < dataSets.length; i++) {
if (dataSets[i].getEntryForXValue(xIndex.toDouble(), double.nan) !=
null) {
return i;
}
}
return -1;
}