drawDataLabel method
void
drawDataLabel()
To customize each data labels.
Implementation
void drawDataLabel(
int index,
Canvas canvas,
String dataLabel,
double pointX,
double pointY,
int angle,
TextStyle style,
) {
if (!pointX.isNaN && !pointY.isNaN) {
final TextSpan span = TextSpan(text: dataLabel, style: style);
final TextPainter textPainter = TextPainter(
text: span,
textAlign: TextAlign.center,
textDirection: TextDirection.ltr,
);
textPainter.layout();
canvas.save();
canvas.translate(
pointX + textPainter.width / 2, pointY + textPainter.height / 2);
canvas.rotate(degreeToRadian(angle));
final Offset labelOffset =
Offset(-textPainter.width / 2, -textPainter.height / 2);
textPainter.paint(canvas, labelOffset);
canvas.restore();
}
}