drawDataLabel method

void drawDataLabel(
  1. Canvas canvas,
  2. String text,
  3. Offset point,
  4. TextStyle style,
  5. int angle, [
  6. bool? isRtl,
])

Implementation

void drawDataLabel(
    Canvas canvas, String text, Offset point, TextStyle style, int angle,
    [bool? isRtl]) {
  final int maxLines = getMaxLinesContent(text);
  final TextSpan span = TextSpan(text: text, style: style);
  final TextPainter tp = TextPainter(
      text: span,
      textDirection: (isRtl ?? false) ? TextDirection.rtl : TextDirection.ltr,
      textAlign: TextAlign.center,
      maxLines: maxLines);
  tp.layout();
  canvas.save();
  canvas.translate(point.dx + tp.width / 2, point.dy + tp.height / 2);
  Offset labelOffset = Offset.zero;
  canvas.rotate(degreeToRadian(angle));
  labelOffset = Offset(-tp.width / 2, -tp.height / 2);
  tp.paint(canvas, labelOffset);
  canvas.restore();
}