drawData method

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

Draws every visible data set onto c. Does nothing while the chart has no size.

When the transparent ring is clipped to the slices, it first opens a layer over the chart, which drawExtras closes after the hole (see the class documentation).

Implementation

@override
void drawData(ui.Canvas c) {
  final width = kotlinFloatToInt(viewPortHandler.chartWidth);
  final height = kotlinFloatToInt(viewPortHandler.chartHeight);

  _layerSaveCount = null;
  if (width <= 0 || height <= 0) {
    _canDraw = false;
    return;
  }
  _canDraw = true;

  if (_isTransparentCircleClipped) {
    _layerSaveCount = c.getSaveCount();
    c.saveLayer(
      ui.Rect.fromLTWH(0, 0, width.toDouble(), height.toDouble()),
      ui.Paint(),
    );
  }

  final pieData = chart.data;
  if (pieData == null) return;

  for (final set in pieData.dataSets) {
    if (set.isVisible && set.entryCount > 0) drawDataSet(c, set);
  }
}