calculateEmptyPointValue method

  1. @override
void calculateEmptyPointValue(
  1. int pointIndex,
  2. ChartPoint currentPoint, [
  3. CircularSeriesRenderer? seriesRenderer
])
override

To calculate empty point values

Implementation

@override
void calculateEmptyPointValue(
    int pointIndex, ChartPoint<dynamic> currentPoint,
    [CircularSeriesRenderer? seriesRenderer]) {
  final EmptyPointSettings empty = emptyPointSettings;
  final List<ChartPoint<dynamic>>? dataPoints = seriesRenderer?._dataPoints;
  final int pointLength = dataPoints!.length;
  final ChartPoint<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;
      case EmptyPointMode.drop:
      case EmptyPointMode.gap:
        point.isEmpty = true;
        point.isVisible = false;
        break;
    }
  }
}