clipToViewport method
Clip canvas to the viewport plot area for the duration of body.
Prevents drawing outside the chart bounds (e.g., on axis labels).
Implementation
void clipToViewport(
Canvas canvas,
ChartViewport viewport,
void Function() body,
) {
canvas.save();
canvas.clipRect(viewport.rect);
body();
canvas.restore();
}