drawNoDataIcon method

  1. @protected
  2. @override
void drawNoDataIcon(
  1. Canvas canvas,
  2. MutableRect bounds,
  3. ChartPaint paint
)
override

Draws the outline of this chart type that the empty state shows above its text, inside bounds, with paint in noDataIconColor. The default draws three bars; line, pie, radar, scatter and bubble charts draw their own shape.

Implementation

@protected
@override
void drawNoDataIcon(ui.Canvas canvas, MutableRect bounds, ChartPaint paint) {
  paint.style = PaintStyle.STROKE;
  paint.strokeWidth = bounds.height() / 8;
  paint.strokeCap = ui.StrokeCap.round;
  paint.strokeJoin = ui.StrokeJoin.round;
  final inset = paint.strokeWidth / 2;
  final ys = Float32List.fromList([0.8, 0.45, 0.65, 0.15]);
  final path = ui.Path();
  for (var i = 0; i < ys.length; i++) {
    final x =
        bounds.left +
        inset +
        (bounds.width() - 2 * inset) * i / (ys.length - 1);
    final y = bounds.top + inset + (bounds.height() - 2 * inset) * ys[i];
    if (i == 0) {
      path.moveTo(x, y);
    } else {
      path.lineTo(x, y);
    }
  }
  canvas.drawPathP(path, paint);
}