calculateLabelPosition method

  1. @override
ArcLabelPosition calculateLabelPosition(
  1. TextElement labelElement,
  2. TextStyle labelStyle,
  3. int insideArcWidth,
  4. int outsideArcWidth,
  5. ArcRendererElement<D> arcRendererElement,
  6. ArcLabelPosition labelPosition,
)
override

Implementation

@override
ArcLabelPosition calculateLabelPosition(
  TextElement labelElement,
  TextStyle labelStyle,
  int insideArcWidth,
  int outsideArcWidth,
  ArcRendererElement<D> arcRendererElement,
  ArcLabelPosition labelPosition,
) {
  assert(arcRendererElement is SunburstArcRendererElement);

  final sunburstArcRendererElement =
      arcRendererElement as SunburstArcRendererElement<D>;

  if (sunburstArcRendererElement.isOuterMostRing ?? false) {
    return super.calculateLabelPosition(
      labelElement,
      labelStyle,
      insideArcWidth,
      outsideArcWidth,
      arcRendererElement,
      outerRingArcLabelPosition,
    );
  } else if (arcRendererElement.isLeaf == true) {
    return super.calculateLabelPosition(
      labelElement,
      labelStyle,
      insideArcWidth,
      outsideArcWidth,
      arcRendererElement,
      innerRingLeafArcLabelPosition,
    );
  } else {
    /// TODO: Improve label handling for sunburst chart. When a
    /// more sophisticated collision detection is in place, we can draw the
    /// label for inner arc outside when it doesn't collide with outer arcs.

    // Force label for arc on the inner ring inside.
    return ArcLabelPosition.inside;
  }
}