renderGridLines method

  1. @override
void renderGridLines(
  1. Canvas c
)
override

Draws the grid lines belonging to the axis.

@param c

Implementation

@override
void renderGridLines(Canvas c) {
  if (!_xAxis!.drawGridLines || !_xAxis!.enabled) return;

  c.save();
  c.clipRect(getGridClippingRect());

  if (mRenderGridLinesBuffer.length != axis!.entryCount * 2) {
    mRenderGridLinesBuffer =
        List.filled(_xAxis!.entryCount * 2, null, growable: false);
  }
  List<double?> positions = mRenderGridLinesBuffer;

  for (int i = 0; i < positions.length; i += 2) {
    positions[i] = _xAxis!.entries[i ~/ 2];
    positions[i + 1] = _xAxis!.entries[i ~/ 2];
  }
  trans!.pointValuesToPixel(positions);

  setupGridPaint();

  Path gridLinePath = mRenderGridLinesPath;
  gridLinePath.reset();

  for (int i = 0; i < positions.length; i += 2) {
    drawGridLine(c, positions[i]!, positions[i + 1], gridLinePath);
  }

  c.restore();
}