drawChartText function

void drawChartText(
  1. Canvas canvas,
  2. String text,
  3. Offset at, {
  4. required Color color,
  5. double fontSize = 9,
  6. FontWeight weight = FontWeight.normal,
  7. HAlign h = HAlign.start,
  8. VAlign v = VAlign.top,
})

Draws text anchored at at by h/v. The shared label helper every chart uses (the equivalent of SwiftUI's context.draw(Text…, at:, anchor:)).

Implementation

void drawChartText(
  Canvas canvas,
  String text,
  Offset at, {
  required Color color,
  double fontSize = 9,
  FontWeight weight = FontWeight.normal,
  HAlign h = HAlign.start,
  VAlign v = VAlign.top,
}) {
  final painter = _layoutLabel(text, color, fontSize, weight);
  final dx = ChartText.dx(h, painter.width);
  final dy = ChartText.dy(v, painter.height);
  painter.paint(canvas, Offset(at.dx + dx, at.dy + dy));
}