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,
])
inherited

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,
]) {
  super.populateDataSource(
      yPaths, chaoticYLists, yLists, fPaths, chaoticFLists, fLists);

  if (dataCount < 1) {
    return;
  }

  if (canFindLinearVisibleIndexes) {
    _sortedXValues = xValues;
  } else {
    final List<num?> xValuesCopy = <num?>[...xValues];
    xValuesCopy.sort();
    _sortedXValues = xValuesCopy;
  }

  num minDelta = double.infinity;
  final int length = _sortedXValues.length;
  if (length == 1) {
    DateTime? minDate;
    num? minimumInSeconds;
    if (xAxis is RenderDateTimeAxis) {
      minDate = DateTime.fromMillisecondsSinceEpoch(_sortedXValues[0] as int);
      minDate = minDate.subtract(const Duration(days: 1));
      minimumInSeconds = minDate.millisecondsSinceEpoch;
    }
    final num seriesMin =
        (xAxis is RenderDateTimeAxis && xRange.minimum == xRange.maximum)
            ? minimumInSeconds!
            : xRange.minimum;
    final num minVal = xValues[0] - seriesMin;
    if (minVal != 0) {
      minDelta = min(minDelta, minVal);
    }
  } else {
    for (int i = 0; i < length - 1; i++) {
      final num? current = _sortedXValues[i];
      final num? next = _sortedXValues[i + 1];
      if (current == null || next == null) {
        continue;
      }

      final num delta = (next - current).abs();
      minDelta = min(delta == 0 ? minDelta : delta, minDelta);
    }
  }

  primaryAxisAdjacentDataPointsMinDiff = minDelta.isInfinite ? 1 : minDelta;

  if (this is! WaterfallSeriesRenderer) {
    populateChartPoints();
  }
}