drawBars method

void drawBars(
  1. Canvas canvas,
  2. Size size,
  3. List<List<int>> values,
  4. List<List<Offset>> xPoints,
  5. List<List<Offset>> yPoints,
  6. List<int> yValues,
)

Implementation

void drawBars(
    Canvas canvas,
    Size size,
    List<List<int>> values,
    List<List<Offset>> xPoints,
    List<List<Offset>> yPoints,
    List<int> yValues) {
  double barWidth = 20;
  for (int j = 0; j < names.length; j++) {
    for (int i = 0; i < values[j].length; i++) {
      var value = values[j][i];
      var pos = yValues.indexOf(value);
      final paint = Paint()
        ..color = colors[j].withOpacity(0.4)
        ..style = PaintingStyle.fill;

      canvas.drawRect(
        Rect.fromLTWH(xPoints[i][2].dx - barWidth / 2, yPoints[pos][2].dy,
            barWidth, size.height - 30 - yPoints[pos][2].dy),
        paint,
      );
    }
  }
}