drawHistogram method
void
drawHistogram({})
Implementation
void drawHistogram(
{required Canvas canvas,
required PaintingStyle style,
required double strokeWidth,
required double scale,
required Color color,
required Rect rect}) {
_paint.style = style;
_paint.color = color;
if (style == PaintingStyle.fill) {
_paint.strokeWidth = strokeWidth;
canvas.drawRect(rect, _paint);
} else {
if (rect.width + _paint.strokeWidth * 2 > strokeWidth) {
double sc = rect.width / (rect.width + _paint.strokeWidth * 2);
strokeWidth = strokeWidth.clamp(0, strokeWidth * sc);
}
/// 上下横线
_paint.strokeWidth = strokeWidth;
canvas.drawLine(rect.topLeft, rect.topRight, _paint);
canvas.drawLine(rect.bottomLeft, rect.bottomRight, _paint);
/// 左右横线
canvas.drawLine(rect.topLeft, rect.bottomLeft, _paint);
canvas.drawLine(rect.topRight, rect.bottomRight, _paint);
}
}