paint method

  1. @override
void paint(
  1. ChartCanvas canvas,
  2. double animationPercent
)
inherited

Renders the series data on the canvas, using the data generated during the update call.

Implementation

@override
void paint(ChartCanvas canvas, double animationPercent) {
  if (animationPercent == 1.0) {
    _animatedTreeMapRects.removeWhere((_, rect) => rect.animatingOut);
  }

  _animatedTreeMapRects.forEach((_, animatedRect) {
    final element = animatedRect.getCurrentRect(animationPercent);
    final rect = element.boundingRect;

    // canvas.drawRRect is used instead of canvas.drawRect because drawRRect
    // supports FillPatternType.forwardHatch.
    canvas.drawRRect(
      rect,
      fill: element.fillColor,
      fillPattern: element.fillPattern,
      patternStrokeWidthPx: config.patternStrokeWidthPx,
      patternColor: element.patternColor,
      stroke: element.strokeColor,
      strokeWidthPx: element.strokeWidthPx!.toDouble(),
      radius: 0,
      roundTopLeft: false,
      roundTopRight: false,
      roundBottomLeft: false,
      roundBottomRight: false,
    );

    // Paint label.
    labelDecorator?.decorate(element, canvas, graphicsFactory!,
        drawBounds: drawBounds!,
        animationPercent: animationPercent,
        rtl: isRtl,
        // only leaf node could possibly render label vertically.
        renderVertically: element.isLeaf && rect.width < rect.height,
        renderMultiline: element.isLeaf);
  });
}