drawChart method

void drawChart(
  1. Canvas canvas
)

Implementation

void drawChart(Canvas canvas) {
  if (getValues().isEmpty) {
    return;
  }
  canvas.save();
  canvas.translate(scrollX, 0);
  for (int i = 0, len = getValues().length; i < len; i++) {
    double value = getValues()[i];
    if (value != 0) {
      double y = valueToY(value);
      double x = indexToX(i) * scale;
      Color color;
      PaintingStyle style;
      BarStyle barStyle = transformBarStyle(values[i]);
      if (barStyle == BarStyle.lower) {
        color = lowerColor;
        style = lowerStyle;
      } else if (barStyle == BarStyle.upper) {
        color = upperColor;
        style = upperStyle;
      } else {
        color = fairColor;
        style = fairStyle;
      }
      if (showValueText) {}

      drawHistogram(
        canvas: canvas,
        scale: scale,
        style: style,
        strokeWidth: strokeWidth,
        rect: Rect.fromLTRB(x, y, x + _width * scale, contentHeight),
        color: color,
      );
      if (showValueText) {
        double size = valueTextFontSize;
        if (scale < 1) {
          size = size * scale;
        }
        TextPainter painter = createText(
          text: '$value',
          style: TextStyle(color: color, fontSize: size),
        );

        if (value > 0) {
          y -= painter.height;
        }
        x = x + (_width * scale/2) - painter.width/2;

        painter.paint(canvas, Offset(x, y));
      }
    }
  }

  canvas.restore();
}