transformValues method

  1. @override
void transformValues()
override

Transforms the x and y values to screen coordinates.

Implementation

@override
void transformValues() {
  fillPath.reset();

  double degree = _degree * animationFactor;
  final double angle = calculateAngle(
      series.animationFactor == 1, series.startAngle, series.endAngle);
  final double startAngle = lerpDouble(
      _priorEndAngle.isNaN ? angle : _priorStartAngle,
      _startAngle,
      animationFactor)!;
  final double endAngle = _priorEndAngle.isNaN
      ? startAngle + degree
      : lerpDouble(_priorEndAngle, _endAngle, animationFactor)!;
  degree = _priorEndAngle.isNaN ? degree : endAngle - startAngle;

  // If the startAngle and endAngle value is same, then degree will be 0.
  // Hence no need to render segments.
  if (!isVisible && degree == 0) {
    return;
  }

  if (series.explode && _isExploded) {
    final double midAngle = (_startAngle + _endAngle) / 2;
    _center = calculateExplodingCenter(
        midAngle, _outerRadius, series.center, series.explodeOffset);
  } else {
    _center = series.center;
  }

  final CornerStyle cornerStyle = series.cornerStyle;
  if (cornerStyle == CornerStyle.bothFlat) {
    fillPath = calculateArcPath(
        _innerRadius, _outerRadius, _center, startAngle, endAngle, degree,
        isAnimate: true);
  } else {
    final num angleDeviation =
        findAngleDeviation(_innerRadius, _outerRadius, 360);
    final double actualStartAngle = (cornerStyle == CornerStyle.startCurve ||
            cornerStyle == CornerStyle.bothCurve)
        ? (startAngle + angleDeviation)
        : startAngle;
    final double actualEndAngle = (cornerStyle == CornerStyle.endCurve ||
            cornerStyle == CornerStyle.bothCurve)
        ? (endAngle - angleDeviation)
        : endAngle;

    fillPath = calculateRoundedCornerArcPath(cornerStyle, _innerRadius,
        _outerRadius, _center, actualStartAngle, actualEndAngle);
  }
}