drawDataLabelWithBackground method
void
drawDataLabelWithBackground(
- CircularChartDataLabelPositioned dataLabelPositioned,
- int index,
- Canvas canvas,
- String dataLabel,
- Offset offset,
- int angle,
- TextStyle style,
- Paint fillPaint,
- Paint strokePaint,
override
Implementation
@override
void drawDataLabelWithBackground(
CircularChartDataLabelPositioned dataLabelPositioned,
int index,
Canvas canvas,
String dataLabel,
Offset offset,
int angle,
TextStyle style,
Paint fillPaint,
Paint strokePaint) {
final TextStyle effectiveTextStyle = parent!.themeData!.textTheme.bodySmall!
.copyWith(color: Colors.black)
.merge(parent!.chartThemeData!.dataLabelTextStyle)
.merge(dataLabelSettings.textStyle);
final CircularChartPoint point = dataLabelPositioned.point!;
if (!point.isVisible || !segments[index].isVisible) {
return;
}
final Rect labelRect = point.labelRect;
canvas.save();
canvas.translate(labelRect.center.dx, labelRect.center.dy);
canvas.rotate((angle * pi) / 180);
canvas.translate(-labelRect.center.dx, -labelRect.center.dy);
if (dataLabelSettings.borderWidth > 0 &&
strokePaint.color != Colors.transparent) {
_drawLabelRect(
strokePaint,
Rect.fromLTRB(
labelRect.left, labelRect.top, labelRect.right, labelRect.bottom),
dataLabelSettings.borderRadius,
canvas);
}
if (fillPaint.color != Colors.transparent) {
_drawLabelRect(
fillPaint,
Rect.fromLTRB(
labelRect.left, labelRect.top, labelRect.right, labelRect.bottom),
dataLabelSettings.borderRadius,
canvas);
}
canvas.restore();
drawDataLabel(
canvas, dataLabel, offset, effectiveTextStyle, dataLabelSettings.angle);
}