populateDataSource method

  1. @override
void populateDataSource([
  1. List<ChartValueMapper<T, num>>? yPaths,
  2. List<List<num>>? chaoticYLists,
  3. List<List<num>>? yLists,
  4. List<ChartValueMapper<T, Object>>? fPaths,
  5. List<List<Object?>>? chaoticFLists,
  6. List<List<Object?>>? fLists,
])
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,
]) {
  _resetDataHolders();
  if (dataSource == null ||
      dataSource!.isEmpty ||
      super.yValueMapper == null) {
    return;
  }

  final int length = dataSource!.length;
  for (int i = 0; i < length; i++) {
    final T current = dataSource![i];
    final num? yValue = super.yValueMapper!(current, i);
    // TODO(Natrayansf): Handle null properly.
    if (yValue == null || yValue.isNaN) {
      _yRawValues.add(0);
    } else {
      _yRawValues.add(yValue);
    }
  }

  // Calculate the actual Histogram [X] and [Y] values.
  _calculateStandardDeviation(_histogramXValues, _histogramYValues);

  _xCount = _histogramXValues.length;
  // Invoke custom [_histogramXValueMapper] method.
  xValueMapper = _histogramXValueMapper;

  super.populateDataSource(
      yPaths, chaoticYLists, yLists, fPaths, chaoticFLists, fLists);
  populateChartPoints();
}