transformValues method

  1. @override
void transformValues()
override

Transforms the x and y values to screen coordinates.

Implementation

@override
void transformValues() {
  overFilledPath.reset();
  shadowPath.reset();

  double degree = _degree * animationFactor;
  double startAngle = _startAngle;
  double endAngle = _endAngle;
  double innerRadius = _innerRadius;
  double outerRadius = _outerRadius;

  if (!_priorInnerRadius.isNaN && !_priorOuterRadius.isNaN) {
    if (isVisible) {
      innerRadius =
          lerpDouble(_priorInnerRadius, _innerRadius, animationFactor)!;
      outerRadius =
          lerpDouble(_priorOuterRadius, _outerRadius, animationFactor)!;
    } else {
      num sumOfY = series.circularYValues
          .reduce((num value, num element) => value + element.abs());
      sumOfY = sumOfY - series.circularYValues[currentSegmentIndex];
      degree = series.circularYValues[currentSegmentIndex] /
          (series.maximumValue ?? sumOfY);
      degree = degree * fullAngle;
      endAngle = _priorEndAngle;
      innerRadius = _priorInnerRadius +
          ((_priorOuterRadius + _priorInnerRadius) / 2 - _priorInnerRadius) *
              animationFactor;
      outerRadius = _priorOuterRadius -
          (_priorOuterRadius - (_priorOuterRadius + _priorInnerRadius) / 2) *
              animationFactor;
      _innerRadius = innerRadius;
      _outerRadius = outerRadius;
    }
  } else {
    endAngle = startAngle + degree;
  }

  trackPath = calculateArcPath(
      innerRadius, outerRadius, _center, 0, fullAngle, fullAngle,
      isAnimate: true);

  if (_outerRadius > 0 && degree > 0) {
    final num angleDeviation =
        findAngleDeviation(innerRadius, outerRadius, 360);
    final CornerStyle cornerStyle = series.cornerStyle;
    if (cornerStyle == CornerStyle.bothCurve ||
        cornerStyle == CornerStyle.startCurve) {
      startAngle += angleDeviation;
    }

    if (cornerStyle == CornerStyle.bothCurve ||
        cornerStyle == CornerStyle.endCurve) {
      endAngle -= angleDeviation;
    }

    if (degree > 360) {
      yValuePath = calculateRoundedCornerArcPath(
          cornerStyle, innerRadius, outerRadius, _center, 0, fullAngle);
      yValuePath.arcTo(
          Rect.fromCircle(center: _center, radius: outerRadius),
          degreesToRadians(_startAngle),
          degreesToRadians(_endAngle - _startAngle),
          true);
      yValuePath.arcTo(
          Rect.fromCircle(center: _center, radius: innerRadius),
          degreesToRadians(_endAngle),
          degreesToRadians(_startAngle) - degreesToRadians(_endAngle),
          false);
    } else {
      yValuePath = calculateRoundedCornerArcPath(cornerStyle, innerRadius,
          outerRadius, _center, startAngle, endAngle);
    }

    if (degree > 360 && endAngle >= startAngle + 180) {
      _calculateShadowPath(endAngle);
    }
  }
}