populateDataSource method
void
populateDataSource([
- List<
ChartValueMapper< ? yPaths,T, num> > - List<
List< ? chaoticYLists,num> > - List<
List< ? yLists,num> > - List<
ChartValueMapper< ? fPaths,T, Object> > - List<
List< ? chaoticFLists,Object?> > - List<
List< ? fLists,Object?> >
override
Implementation
@override
void populateDataSource([
List<ChartValueMapper<T, num>>? yPaths,
List<List<num>>? chaoticYLists,
List<List<num>>? yLists,
List<ChartValueMapper<T, Object>>? fPaths,
List<List<Object?>>? chaoticFLists,
List<List<Object?>>? fLists,
]) {
_resetDataSourceHolders();
if (dataSource == null ||
dataSource!.isEmpty ||
xValueMapper == null ||
yValueMapper == null) {
_dataCount = _chaoticXValues.length;
return;
}
if (fPaths == null) {
fPaths = <ChartValueMapper<T, Object>>[];
chaoticFLists = <List<Object?>>[];
fLists = <List<Object?>>[];
}
_addPointColorMapper(fPaths, chaoticFLists, fLists);
_addSortValueMapper(fPaths, chaoticFLists, fLists);
final int length = dataSource!.length;
final int fPathLength = fPaths.length;
num previousX = double.negativeInfinity;
num xMinimum = double.infinity;
num xMaximum = double.negativeInfinity;
num yMinimum = double.infinity;
num yMaximum = double.negativeInfinity;
final Function(int, D) preferredXValue = _preferredXValue();
final Function(D?, num) addXValue = _addXValueIntoRawAndChaoticXLists;
for (int i = 0; i < length; i++) {
final T current = dataSource![i];
final D? rawX = xValueMapper!(current, i);
if (rawX == null) {
_xNullPointIndexes.add(i);
continue;
}
final num currentX = preferredXValue(i, rawX);
addXValue(rawX, currentX);
xMinimum = min(xMinimum, currentX);
xMaximum = max(xMaximum, currentX);
if (_hasLinearDataSource) {
_hasLinearDataSource = currentX >= previousX;
}
final List<num?>? yData = yValueMapper!(current, i);
if (yData == null) {
_chaoticYValues.add(<num>[]);
} else {
num minY = double.infinity;
num maxY = double.negativeInfinity;
final List<num> nonNullYValues = <num>[];
final int yLength = yData.length;
for (int j = 0; j < yLength; j++) {
final num? yVal = yData[j];
if (yVal != null && !yVal.isNaN) {
nonNullYValues.add(yVal);
minY = min(minY, yVal);
maxY = max(maxY, yVal);
}
}
nonNullYValues.sort();
_chaoticYValues.add(nonNullYValues);
yMinimum = min(yMinimum, minY);
yMaximum = max(yMaximum, maxY);
}
for (int j = 0; j < fPathLength; j++) {
final ChartValueMapper<T, Object> fPath = fPaths[j];
final Object? fValue = fPath(current, i);
chaoticFLists![j].add(fValue);
}
previousX = currentX;
}
xMin = xMinimum;
xMax = xMaximum;
yMin = yMinimum;
yMax = yMaximum;
_dataCount = _chaoticXValues.length;
_canFindLinearVisibleIndexes = _hasLinearDataSource;
_doSortingIfNeeded(chaoticYLists, yLists, chaoticFLists, fLists);
super._calculateSbsInfo();
populateChartPoints();
_updateXValuesForCategoryTypeAxes();
}