void paint()

in web/github_dataviz/lib/layered_chart.dart [243:330]


  void paint(Canvas canvas, Size size) {
    if (dataToPlot.isEmpty) {
      return;
    }

    if (state.lastSize == null ||
        size.width != state.lastSize!.width ||
        size.height != state.lastSize!.height) {
      print('Building paths, lastsize = ${state.lastSize}');
      state.buildPaths(size, dataToPlot, milestones, numPoints, graphGap,
          margin, capTheta, capSize);
    }
    int m = dataToPlot.length;
    int numWeeks = dataToPlot[0].series.length;
    // How far along to draw
    double totalGap = m * graphGap;
    double xIndent = totalGap / tan(capTheta);
    double dx = xIndent / (m - 1);
    double startX = margin + xIndent;
    double endX = size.width - margin;
    double startY = size.height;
    double endY = startY - (endX - startX) * tan(state.theta);
    // MILESTONES
    {
      for (int i = 0; i < milestones.length; i++) {
        WeekLabel milestone = milestones[i];
        double p = (milestone.weekNum!.toDouble() / numWeeks) + (1 - amount);
        if (p < 1) {
          double x1 = MathUtils.map(p, 0, 1, startX, endX);
          double y1 = MathUtils.map(p, 0, 1, startY, endY);
          double x2 = x1 - xIndent;
          double y2 = y1 - graphGap * (m - 1);
          x1 += dx * 0.5;
          y1 += graphGap * 0.5;
          double textY = y1 + 5;
          double textX = x1 + 5 * tan(capTheta);
          canvas.drawLine(Offset(x1, y1), Offset(x2, y2), milestonePaint);
          canvas.save();
          TextPainter tp = state.milestonePainter[i];
          canvas.translate(textX, textY);
          canvas.skew(tan(capTheta * 1.0), -tan(state.theta));
          canvas.translate(-tp.width / 2, 0);
          tp.paint(canvas, const Offset(0, 0));
          canvas.restore();
        }
      }
    }
    for (int i = m - 1; i >= 0; i--) {
      canvas.save();
      canvas.translate(-dx * i, -graphGap * i);

      {
        // TEXT LABELS
        canvas.save();
        double textPosition = 0.2;
        double textX = MathUtils.map(textPosition, 0, 1, startX, endX);
        double textY = MathUtils.map(textPosition, 0, 1, startY, endY) + 5;
        canvas.translate(textX, textY);
        TextPainter tp = state.labelPainter[i];
        canvas.skew(0, -tan(state.theta));
        canvas.drawRect(
            Rect.fromLTWH(-1, -1, tp.width + 2, tp.height + 2), fillPaint);
        tp.paint(canvas, const Offset(0, 0));
        canvas.restore();
      }

      linePaint.color = capColors[i]!;
      canvas.drawLine(Offset(startX, startY), Offset(endX, endY), linePaint);

      Path clipPath = Path();
      clipPath.moveTo(startX - capSize, startY + 11);
      clipPath.lineTo(endX, endY + 1);
      clipPath.lineTo(endX, endY - state.graphHeight - capSize);
      clipPath.lineTo(startX - capSize, startY - state.graphHeight - capSize);
      clipPath.close();
      canvas.clipPath(clipPath);

      pathPaint.color = colors[i]!;
      capPaint.color = capColors[i]!;
      double offsetX = MathUtils.map(1 - amount, 0, 1, startX, endX);
      double offsetY = MathUtils.map(1 - amount, 0, 1, startY, endY);
      canvas.translate(offsetX - startX, offsetY - startY);
      canvas.drawPath(state.capPaths[i], capPaint);
      canvas.drawPath(state.paths[i], pathPaint);

      canvas.restore();
    }
  }