|
|
@ -49,7 +49,6 @@ class BarChart(
|
|
|
|
var barMargin = 3.0
|
|
|
|
var barMargin = 3.0
|
|
|
|
var barWidth = 12.0
|
|
|
|
var barWidth = 12.0
|
|
|
|
var nGridlines = 6
|
|
|
|
var nGridlines = 6
|
|
|
|
var backgroundColor = theme.cardBackgroundColor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val dataColumnWidth: Double
|
|
|
|
override val dataColumnWidth: Double
|
|
|
|
get() = barWidth + barMargin * 2
|
|
|
|
get() = barWidth + barMargin * 2
|
|
|
@ -67,8 +66,8 @@ class BarChart(
|
|
|
|
var maxValue = series.map { it.max()!! }.max()!!
|
|
|
|
var maxValue = series.map { it.max()!! }.max()!!
|
|
|
|
maxValue = max(maxValue, 1.0)
|
|
|
|
maxValue = max(maxValue, 1.0)
|
|
|
|
|
|
|
|
|
|
|
|
canvas.setColor(backgroundColor)
|
|
|
|
canvas.setColor(theme.cardBackgroundColor)
|
|
|
|
canvas.fillRect(0.0, 0.0, width, height)
|
|
|
|
canvas.fill()
|
|
|
|
|
|
|
|
|
|
|
|
fun barGroupOffset(c: Int) = marginLeft + paddingLeft +
|
|
|
|
fun barGroupOffset(c: Int) = marginLeft + paddingLeft +
|
|
|
|
(c) * barGroupWidth
|
|
|
|
(c) * barGroupWidth
|
|
|
@ -97,13 +96,6 @@ class BarChart(
|
|
|
|
canvas.fillCircle(x + barWidth - r, y + r, r)
|
|
|
|
canvas.fillCircle(x + barWidth - r, y + r, r)
|
|
|
|
canvas.setFontSize(theme.smallTextSize)
|
|
|
|
canvas.setFontSize(theme.smallTextSize)
|
|
|
|
canvas.setTextAlign(TextAlign.CENTER)
|
|
|
|
canvas.setTextAlign(TextAlign.CENTER)
|
|
|
|
canvas.setColor(backgroundColor)
|
|
|
|
|
|
|
|
canvas.fillRect(
|
|
|
|
|
|
|
|
x - barMargin,
|
|
|
|
|
|
|
|
y - theme.smallTextSize * 1.25,
|
|
|
|
|
|
|
|
barWidth + 2 * barMargin,
|
|
|
|
|
|
|
|
theme.smallTextSize * 1.0
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
canvas.setColor(colors[s])
|
|
|
|
canvas.setColor(colors[s])
|
|
|
|
canvas.drawText(
|
|
|
|
canvas.drawText(
|
|
|
|
value.toShortString(),
|
|
|
|
value.toShortString(),
|
|
|
@ -119,12 +111,7 @@ class BarChart(
|
|
|
|
fun drawMajorGrid() {
|
|
|
|
fun drawMajorGrid() {
|
|
|
|
canvas.setStrokeWidth(1.0)
|
|
|
|
canvas.setStrokeWidth(1.0)
|
|
|
|
if (nSeries > 1) {
|
|
|
|
if (nSeries > 1) {
|
|
|
|
canvas.setColor(
|
|
|
|
canvas.setColor(theme.lowContrastTextColor.withAlpha(0.5))
|
|
|
|
backgroundColor.blendWith(
|
|
|
|
|
|
|
|
theme.lowContrastTextColor,
|
|
|
|
|
|
|
|
0.5
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
for (c in 0 until nColumns - 1) {
|
|
|
|
for (c in 0 until nColumns - 1) {
|
|
|
|
val x = barGroupOffset(c)
|
|
|
|
val x = barGroupOffset(c)
|
|
|
|
canvas.drawLine(x, paddingTop, x, paddingTop + maxBarHeight)
|
|
|
|
canvas.drawLine(x, paddingTop, x, paddingTop + maxBarHeight)
|
|
|
@ -141,8 +128,6 @@ class BarChart(
|
|
|
|
|
|
|
|
|
|
|
|
fun drawAxis() {
|
|
|
|
fun drawAxis() {
|
|
|
|
val y = paddingTop + maxBarHeight
|
|
|
|
val y = paddingTop + maxBarHeight
|
|
|
|
canvas.setColor(backgroundColor)
|
|
|
|
|
|
|
|
canvas.fillRect(0.0, y, width, height - y)
|
|
|
|
|
|
|
|
canvas.setColor(theme.lowContrastTextColor)
|
|
|
|
canvas.setColor(theme.lowContrastTextColor)
|
|
|
|
canvas.drawLine(0.0, y, width, y)
|
|
|
|
canvas.drawLine(0.0, y, width, y)
|
|
|
|
canvas.setColor(theme.mediumContrastTextColor)
|
|
|
|
canvas.setColor(theme.mediumContrastTextColor)
|
|
|
|