setData method

  1. @override
void setData(
  1. int index,
  2. ChartSegment segment
)
override

Implementation

@override
void setData(int index, ChartSegment segment) {
  super.setData(index, segment);

  _startControlXValues.clear();
  _startControlYValues.clear();
  _endControlXValues.clear();
  _endControlYValues.clear();

  final List<num?> yCoefficients = List<num?>.filled(dataCount, 0);
  _yMax = double.negativeInfinity;

  final num x1 = xValues[index];
  final num y1 = nonEmptyYValues[index];
  num x2 = double.nan;
  num y2 = double.nan;

  final int nextIndex = index + 1;
  if (nextIndex < dataCount) {
    x2 = xValues[nextIndex];
    y2 = nonEmptyYValues[nextIndex];
  }

  _buildSplineAreaSegment(
    yCoefficients,
    x1,
    y1,
    nextIndex,
    x2,
    y2,
    nonEmptyYValues,
    _startControlXValues,
    _startControlYValues,
    _endControlXValues,
    _endControlYValues,
  );

  final num bottom = xAxis!.crossesAt ?? max(yAxis!.visibleRange!.minimum, 0);
  segment as SplineAreaSegment<T, D>
    ..series = this
    ..currentSegmentIndex = index
    .._xValues = xValues
    .._yValues = yValues
    .._startControlHighXValues = _startControlXValues
    .._startControlHighYValues = _startControlYValues
    .._endControlHighXValues = _endControlXValues
    .._endControlHighYValues = _endControlYValues
    ..bottom = bottom;
}