drawAxes method
Draw axis lines.
Renders the X-axis (bottom) and Y-axis (left) to mark the boundaries of the chart area. Uses a clean, minimal style for professional appearance.
Parameters:
canvas- The canvas to draw onsize- The size of the chart areaminX,maxX,minY,maxY- The data bounds (not used, kept for API consistency)
The axes will only be drawn if showAxis is true and the theme allows axis display.
Example
drawAxes(canvas, chartSize, 0, 100, 0, 50);
Implementation
void drawAxes(
Canvas canvas,
Size size,
double minX,
double maxX,
double minY,
double maxY,
) {
if (!showAxis || !theme.showAxis) return;
// Enhanced axis styling with better visibility
final axisPaint = Paint()
..color = theme.axisColor.withValues(alpha: 0.5)
..strokeWidth = 1.0
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round;
// X-axis (bottom) - Clean solid line
canvas.drawLine(
Offset(0, size.height),
Offset(size.width, size.height),
axisPaint,
);
// Y-axis (left) - Clean solid line
// canvas.drawLine(const Offset(0, 0), Offset(0, size.height), axisPaint);
// Only draw ticks on Y axis for a cleaner look
const yTicks = 5;
final ySpacing = size.height / yTicks;
for (int i = 0; i <= yTicks; i++) {
final y = size.height - (ySpacing * i);
// Small tick mark
canvas.drawLine(Offset(-4, y), Offset(0, y), axisPaint);
}
}