calculateEmptyPointValue method

  1. @override
void calculateEmptyPointValue(
  1. int pointIndex,
  2. dynamic currentPoint,
  3. dynamic seriesRenderer
)
inherited

To calculate the values of the empty points.

Implementation

@override
void calculateEmptyPointValue(
    int pointIndex, dynamic currentPoint, dynamic seriesRenderer) {
  final List<PointInfo<dynamic>> dataPoints = seriesRenderer.dataPoints;
  final EmptyPointSettings empty = emptyPointSettings;
  final int pointLength = dataPoints.length;
  final PointInfo<dynamic> point = dataPoints[pointIndex];
  if (point.y == null) {
    switch (empty.mode) {
      case EmptyPointMode.average:
        final num previous =
            pointIndex - 1 >= 0 ? dataPoints[pointIndex - 1].y ?? 0 : 0;
        final num next = pointIndex + 1 <= pointLength - 1
            ? dataPoints[pointIndex + 1].y ?? 0
            : 0;
        point.y = (previous + next).abs() / 2;
        point.isVisible = true;
        point.isEmpty = true;
        break;
      case EmptyPointMode.zero:
        point.y = 0;
        point.isVisible = true;
        point.isEmpty = true;
        break;
      // ignore: no_default_cases
      default:
        point.isEmpty = true;
        point.isVisible = false;
        break;
    }
  }
}