drawGrid static method
Implementation
static void drawGrid(
Canvas canvas,
ChartContext context, {
int tickCount = 5,
}) {
final paint = context.paintCache.get(
key: 'grid',
color: context.theme.gridColor,
strokeWidth: context.theme.gridStrokeWidth,
);
final bounds = context.bounds;
if (context.viewport.width <= 0 || context.viewport.height <= 0) {
return;
}
for (var i = 0; i <= tickCount; i++) {
final t = i / tickCount;
final x = bounds.left + bounds.width * t;
canvas.drawLine(Offset(x, bounds.top), Offset(x, bounds.bottom), paint);
final y = bounds.bottom - bounds.height * t;
canvas.drawLine(Offset(bounds.left, y), Offset(bounds.right, y), paint);
}
}