paintBackground method

  1. @override
void paintBackground(
  1. Context context
)
override

Implementation

@override
void paintBackground(Context context) {
  if (!divisions) {
    return;
  }

  final grid = Chart.of(context).grid as CartesianGrid;

  switch (direction) {
    case Axis.horizontal:
      for (final num x in values.sublist(_marginStart > 0 ? 0 : 1)) {
        final p = toChart(x);
        context.canvas.drawLine(p, grid.gridBox.top, p, grid.gridBox.bottom);
      }
      break;

    case Axis.vertical:
      for (final num y in values.sublist(_marginStart > 0 ? 0 : 1)) {
        final p = toChart(y);
        context.canvas.drawLine(grid.gridBox.left, p, grid.gridBox.right, p);
      }

      break;
  }

  if (divisionsDashed) {
    context.canvas.setLineDashPattern(<int>[4, 2]);
  }

  context.canvas
    ..setStrokeColor(divisionsColor)
    ..setLineWidth(divisionsWidth)
    ..setLineJoin(PdfLineJoin.miter)
    ..strokePath();

  if (divisionsDashed) {
    context.canvas.setLineDashPattern();
  }
}