drawTrackball function

void drawTrackball(
  1. Canvas canvas, {
  2. required double x,
  3. required double top,
  4. required double bottom,
  5. required Color lineColor,
  6. List<Offset> markers = const [],
  7. List<Color> markerColors = const [],
})

A vertical trackball line at x spanning top..bottom, with optional ring markers (one per series value at the active column) in markerColors.

Implementation

void drawTrackball(
  Canvas canvas, {
  required double x,
  required double top,
  required double bottom,
  required Color lineColor,
  List<Offset> markers = const [],
  List<Color> markerColors = const [],
}) {
  canvas.drawLine(
    Offset(x, top),
    Offset(x, bottom),
    Paint()
      ..color = lineColor
      ..strokeWidth = 1,
  );
  for (var i = 0; i < markers.length; i++) {
    final c = i < markerColors.length ? markerColors[i] : lineColor;
    drawHighlightRing(canvas, markers[i], c, radius: 5);
  }
}