drawDataSets method

  1. @visibleForTesting
void drawDataSets(
  1. CanvasWrapper canvasWrapper,
  2. PaintHolder<RadarChartData> holder
)

Implementation

@visibleForTesting
void drawDataSets(
  CanvasWrapper canvasWrapper,
  PaintHolder<RadarChartData> holder,
) {
  final data = holder.data;
  // we will use dataSetsPosition to draw the graphs
  dataSetsPosition ??= calculateDataSetsPosition(canvasWrapper.size, holder);
  dataSetsPosition!.asMap().forEach((index, dataSetOffset) {
    final graph = data.dataSets[index];
    _graphPaint
      ..color = graph.fillColor
      ..style = PaintingStyle.fill;

    _graphBorderPaint
      ..color = graph.borderColor
      ..style = PaintingStyle.stroke
      ..strokeWidth = graph.borderWidth;

    _graphPointPaint
      ..color = _graphBorderPaint.color
      ..style = PaintingStyle.fill;

    final path = Path();

    final firstOffset = Offset(
      dataSetOffset.entriesOffset.first.dx,
      dataSetOffset.entriesOffset.first.dy,
    );

    path.moveTo(firstOffset.dx, firstOffset.dy);

    canvasWrapper.drawCircle(
      firstOffset,
      graph.entryRadius,
      _graphPointPaint,
    );
    dataSetOffset.entriesOffset.asMap().forEach((index, pointOffset) {
      if (index == 0) return;

      path.lineTo(pointOffset.dx, pointOffset.dy);

      canvasWrapper.drawCircle(
        pointOffset,
        graph.entryRadius,
        _graphPointPaint,
      );
    });

    path.close();
    canvasWrapper
      ..drawPath(path, _graphPaint)
      ..drawPath(path, _graphBorderPaint);
  });
}