drawAxes method

void drawAxes(
  1. Canvas canvas,
  2. Size size,
  3. double minX,
  4. double maxX,
  5. double minY,
  6. double maxY,
)

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 on
  • size - The size of the chart area
  • minX, 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.75)
    ..strokeWidth = 1.5
    ..style = PaintingStyle.stroke
    ..strokeCap = StrokeCap.round;

  // X-axis (bottom) - enhanced with subtle shadow effect
  canvas.drawLine(
    Offset(0, size.height),
    Offset(size.width, size.height),
    axisPaint,
  );

  // Y-axis (left) - enhanced
  canvas.drawLine(const Offset(0, 0), Offset(0, size.height), axisPaint);

  // Add subtle axis highlights for depth
  final highlightPaint = Paint()
    ..color = Colors.white.withValues(alpha: 0.3)
    ..strokeWidth = 0.5
    ..style = PaintingStyle.stroke;

  canvas.drawLine(
    Offset(0, size.height - 0.5),
    Offset(size.width, size.height - 0.5),
    highlightPaint,
  );
}