onPaint method

  1. @override
void onPaint(
  1. Canvas canvas
)
override

Draws segment in series bounds.

Implementation

@override
void onPaint(Canvas canvas) {
  if (_series.animationDuration > 0 &&
      !_seriesRenderer._chartState!._isLegendToggled) {
    if (!_seriesRenderer._chartState!._widgetNeedUpdate ||
        _seriesRenderer._reAnimate) {
      if (_isTransposed) {
        _lowX = _lowPoint.x;
        _highX = _highPoint.x;
        _centerX = _highX + ((_lowX - _highX) / 2);
        _highX = _centerX + ((_centerX - _highX).abs() * animationFactor);
        _lowX = _centerX - ((_lowX - _centerX).abs() * animationFactor);
        canvas.drawLine(Offset(_lowX, _lowPoint.y),
            Offset(_highX, _highPoint.y), strokePaint!);
      } else {
        _centerY = _high + ((_low - _high) / 2);
        _highY = _centerY - ((_centerY - _high) * animationFactor);
        _lowY = _centerY + ((_low - _centerY) * animationFactor);
        canvas.drawLine(Offset(_lowPoint.x, _highY),
            Offset(_highPoint.x, _lowY), strokePaint!);
      }
    } else {
      _currentSegment =
          _seriesRenderer._segments[currentSegmentIndex!] as HiloSegment;
      _oldSegment = !_seriesRenderer._reAnimate &&
              (_currentSegment._oldSeriesRenderer != null &&
                  _currentSegment._oldSeriesRenderer!._segments.isNotEmpty &&
                  _currentSegment._oldSeriesRenderer!._segments[0]
                      is HiloSegment &&
                  _currentSegment._oldSeriesRenderer!._segments.length - 1 >=
                      currentSegmentIndex!)
          ? _currentSegment._oldSeriesRenderer!
              ._segments[currentSegmentIndex!] as HiloSegment?
          : null;
      _animateHiloSeries(
          _isTransposed,
          _lowPoint,
          _highPoint,
          _oldSegment?._lowPoint,
          _oldSegment?._highPoint,
          animationFactor,
          strokePaint!,
          canvas,
          _seriesRenderer);
    }
  } else {
    if (_series.dashArray[0] != 0 && _series.dashArray[1] != 0) {
      _path = Path();
      _path.moveTo(_lowPoint.x, _high);
      _path.lineTo(_highPoint.x, _low);
      _drawDashedLine(canvas, _series.dashArray, strokePaint!, _path);
    } else {
      canvas.drawLine(Offset(_lowPoint.x, _high), Offset(_highPoint.x, _low),
          strokePaint!);
    }
  }
}