paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size,
  3. ChartContext context
)
override

Implementation

@override
void paint(Canvas canvas, Size size, ChartContext context) {
  final crosshair = context.crosshairPosition;
  if (crosshair != null) {
    final paint = context.paintCache.get(
      key: 'crosshair',
      color: context.theme.crosshairColor,
    );
    final bounds = context.bounds;
    canvas.drawLine(
      Offset(crosshair.dx, bounds.top),
      Offset(crosshair.dx, bounds.bottom),
      paint,
    );
    canvas.drawLine(
      Offset(bounds.left, crosshair.dy),
      Offset(bounds.right, crosshair.dy),
      paint,
    );
  }

  final selected = context.selectedHit;
  if (selected != null) {
    final paint = context.paintCache.fill(
      'selection',
      context.theme.selectionColor,
    );
    canvas.drawRect(selected.region.bounds.inflate(4), paint);
  }
}