BarChart: Fix small bars

This commit is contained in:
2021-03-18 22:16:26 -05:00
parent 8b2285787c
commit 298bf1a538

View File

@@ -90,10 +90,14 @@ class BarChart(
val y = height - footerHeight - barHeight val y = height - footerHeight - barHeight
canvas.setColor(colors[s]) canvas.setColor(colors[s])
val r = round(barWidth * 0.15) val r = round(barWidth * 0.15)
canvas.fillRect(x, y + r, barWidth, barHeight - r) if (2 * r < barHeight) {
canvas.fillRect(x + r, y, barWidth - 2 * r, r) canvas.fillRect(x, y + r, barWidth, barHeight - r)
canvas.fillCircle(x + r, y + r, r) canvas.fillRect(x + r, y, barWidth - 2 * r, r)
canvas.fillCircle(x + barWidth - r, y + r, r) canvas.fillCircle(x + r, y + r, r)
canvas.fillCircle(x + barWidth - r, y + r, r)
} else {
canvas.fillRect(x, y, barWidth, barHeight)
}
canvas.setFontSize(theme.smallTextSize) canvas.setFontSize(theme.smallTextSize)
canvas.setTextAlign(TextAlign.CENTER) canvas.setTextAlign(TextAlign.CENTER)
canvas.setColor(colors[s]) canvas.setColor(colors[s])