calculateLabelPosition method

  1. @protected
ArcLabelPosition calculateLabelPosition(
  1. TextElement labelElement,
  2. TextStyle labelStyle,
  3. int insideArcWidth,
  4. int outsideArcWidth,
  5. ArcRendererElement arcRendererelement,
  6. ArcLabelPosition labelPosition,
)

Implementation

@protected
ArcLabelPosition calculateLabelPosition(
    TextElement labelElement,
    TextStyle labelStyle,
    int insideArcWidth,
    int outsideArcWidth,
    ArcRendererElement arcRendererelement,
    ArcLabelPosition labelPosition) {
  if (labelPosition == ArcLabelPosition.auto) {
    // For auto, first try to fit the text inside the arc.
    labelElement.textStyle = labelStyle;

    // A label fits if the space inside the arc is >= outside arc or if the
    // length of the text fits and the space. This is because if the arc has
    // more space than the outside, it makes more sense to place the label
    // inside the arc, even if the entire label does not fit.
    return (insideArcWidth >= outsideArcWidth ||
            labelElement.measurement.horizontalSliceWidth < insideArcWidth)
        ? ArcLabelPosition.inside
        : ArcLabelPosition.outside;
  } else {
    return labelPosition;
  }
}