calculateEmptyPointValue method

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

To calculate empty point value for the specific mode

Implementation

@override
void calculateEmptyPointValue(
    int pointIndex, CartesianChartPoint<dynamic> currentPoint,
    [CartesianSeriesRenderer? seriesRenderer]) {
  final int pointLength = seriesRenderer!._dataPoints.length - 1;
  final String _seriesType = seriesRenderer._seriesType;
  final CartesianChartPoint<dynamic> prevPoint = seriesRenderer._dataPoints[
      seriesRenderer._dataPoints.length >= 2 ? pointLength - 1 : pointLength];
  if (_seriesType.contains('range') ||
          _seriesType.contains('hilo') ||
          _seriesType == 'candle'
      ? _seriesType == 'hiloopenclose' || _seriesType == 'candle'
          ? (currentPoint.low == null ||
              currentPoint.high == null ||
              currentPoint.open == null ||
              currentPoint.close == null)
          : (currentPoint.low == null || currentPoint.high == null)
      : currentPoint.y == null) {
    switch (seriesRenderer._series.emptyPointSettings.mode) {
      case EmptyPointMode.zero:
        currentPoint.isEmpty = true;
        if (_seriesType.contains('range') ||
            _seriesType.contains('hilo') ||
            _seriesType.contains('candle')) {
          currentPoint.high = 0;
          currentPoint.low = 0;
          if (_seriesType == 'hiloopenclose' || _seriesType == 'candle') {
            currentPoint.open = 0;
            currentPoint.close = 0;
          }
        } else {
          currentPoint.y = 0;
        }
        break;

      case EmptyPointMode.average:
        if (seriesRenderer is XyDataSeriesRenderer) {
          _calculateAverageModeValue(
              pointIndex, pointLength, currentPoint, prevPoint);
        }
        currentPoint.isEmpty = true;
        break;

      case EmptyPointMode.gap:
        if (_seriesType == 'scatter' ||
            _seriesType == 'column' ||
            _seriesType == 'bar' ||
            _seriesType == 'bubble' ||
            _seriesType == 'splinearea' ||
            _seriesType == 'rangecolumn' ||
            _seriesType.contains('hilo') ||
            _seriesType.contains('candle') ||
            _seriesType == 'rangearea' ||
            _seriesType.contains('stacked')) {
          currentPoint.y = pointIndex != 0 &&
                  (!_seriesType.contains('stackedcolumn') &&
                      !_seriesType.contains('stackedbar'))
              ? prevPoint.y
              : 0;
          currentPoint.open = 0;
          currentPoint.close = 0;
          currentPoint.isVisible = false;
        } else if (_seriesType.contains('line') ||
            _seriesType == 'area' ||
            _seriesType == 'steparea') {
          if (_seriesType == 'splinerangearea') {
            // ignore: prefer_if_null_operators
            currentPoint.low = currentPoint.low == null
                ? pointIndex != 0
                    ? prevPoint.low ?? 0
                    : 0
                : currentPoint.low;
            // ignore: prefer_if_null_operators
            currentPoint.high = currentPoint.high == null
                ? pointIndex != 0
                    ? prevPoint.high ?? 0
                    : 0
                : currentPoint.high;
          } else {
            currentPoint.y = pointIndex != 0 ? prevPoint.y : 0;
          }
        }
        currentPoint.isGap = true;
        break;
      case EmptyPointMode.drop:
        if (_seriesType == 'splinerangearea') {
          // ignore: prefer_if_null_operators
          currentPoint.low = currentPoint.low == null
              ? pointIndex != 0
                  ? prevPoint.low ?? 0
                  : 0
              : currentPoint.low;
          // ignore: prefer_if_null_operators
          currentPoint.high = currentPoint.high == null
              ? pointIndex != 0
                  ? prevPoint.high ?? 0
                  : 0
              : currentPoint.high;
        }
        currentPoint.y = pointIndex != 0 &&
                (_seriesType != 'area' &&
                    _seriesType != 'splinearea' &&
                    _seriesType != 'splinerangearea' &&
                    _seriesType != 'steparea' &&
                    !_seriesType.contains('stackedcolumn') &&
                    !_seriesType.contains('stackedbar'))
            ? prevPoint.y
            : 0;
        currentPoint.isDrop = true;
        currentPoint.isVisible = false;
        break;
      default:
        currentPoint.y = 0;
        break;
    }
  }
}