dataLabelPosition method
Offset
dataLabelPosition(
- ChartElementParentData current,
- ChartDataLabelAlignment alignment,
- Size size
override
Implementation
@override
Offset dataLabelPosition(
ChartElementParentData current,
ChartDataLabelAlignment alignment,
Size size,
) {
final EdgeInsets margin = dataLabelSettings.margin;
double translationX = 0.0;
double translationY = 0.0;
switch (alignment) {
case ChartDataLabelAlignment.auto:
case ChartDataLabelAlignment.middle:
if (isTransposed) {
translationX = -margin.left - size.width / 2;
translationY = -margin.top;
} else {
translationX = -margin.left;
translationY = -margin.top - size.height / 2;
}
return translateTransform(
current.x!, current.y!, translationX, translationY);
case ChartDataLabelAlignment.outer:
case ChartDataLabelAlignment.top:
final BubbleSegment<T, D> segment =
segments[current.dataPointIndex] as BubbleSegment<T, D>;
translationX = -margin.left;
translationY = -(segment.radius +
dataLabelPadding +
size.height +
margin.vertical);
return translateTransform(
current.x!, current.y!, translationX, translationY);
case ChartDataLabelAlignment.bottom:
final BubbleSegment<T, D> segment =
segments[current.dataPointIndex] as BubbleSegment<T, D>;
translationX = -margin.left;
translationY = segment.radius + dataLabelPadding;
return translateTransform(
current.x!, current.y!, translationX, translationY);
}
}