From 5edaae6d0e768763914bde1d465d8b111d423a44 Mon Sep 17 00:00:00 2001 From: jacques Date: Mon, 4 Nov 2024 22:33:02 -0800 Subject: [PATCH] (chore) Improve colors for the graph --- qml/StatsPage.qml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/qml/StatsPage.qml b/qml/StatsPage.qml index e68f5ba..3c46e26 100644 --- a/qml/StatsPage.qml +++ b/qml/StatsPage.qml @@ -24,6 +24,13 @@ Rectangle { QtObject { id: d + function getBarColor(barHeight) { + let baseBlue = Qt.rgba(0, 0, 0.6, 1); + let lightnessIncrement = Math.min(barHeight * 0.1, 1.0); + + return Qt.darker(baseBlue, 1 - 0.9 * lightnessIncrement); + } + function populateGraphRandomData() { graphData.clear(); @@ -201,17 +208,7 @@ Rectangle { ctx.beginPath(); ctx.rect(xPos, yPos, barWidth, barHeight); - var barColor = "#00c8ff"; - - barHeight = point.score; - - if (barHeight <= 2) { - barColor = themeObject.buttonHardColor; - } else if (barHeight > 2 && barHeight <= 4) { - barColor = themeObject.buttonMediumColor; - } else { - barColor = themeObject.buttonEasyColor; - } + var barColor = d.getBarColor(point.score) ctx.fillStyle = barColor; ctx.fill();