getMarkerPosition method

  1. @override
List<double> getMarkerPosition(
  1. Highlight high
)
override

Returns the actual position in pixels of the MarkerView for the given Highlight object.

@param high @return

Implementation

@override
List<double> getMarkerPosition(Highlight high) {
  MPPointF center = getCenterCircleBox();
  double r = getRadius();

  double off = r / 10 * 3.6;

  if (isDrawHoleEnabled()) {
    off = (r - (r / 100 * getHoleRadius())) / 2;
  }

  r -= off; // offset to keep things inside the chart

  double rotationAngle = getRotationAngle();

  int entryIndex = high.x!.toInt();

  // offset needed to center the drawn text in the slice
  double offset = _drawAngles[entryIndex]! / 2;

  // calculate the text position
  double x = (r *
          cos(((rotationAngle + _absoluteAngles[entryIndex]! - offset) *
                  animator!.getPhaseY()) /
              180 *
              pi) +
      center.x);
  double y = (r *
          sin((rotationAngle + _absoluteAngles[entryIndex]! - offset) *
              animator!.getPhaseY() /
              180 *
              pi) +
      center.y);

  MPPointF.recycleInstance(center);
  return List.empty(growable: true)
    ..add(x)
    ..add(y);
}