summaryrefslogtreecommitdiff
path: root/src/graphs
diff options
context:
space:
mode:
authordodoradio <dodoradio@outlook.com>2023-08-20 16:32:47 +0100
committerdodoradio <dodoradio@outlook.com>2023-08-20 19:57:01 +0100
commit6ae32dffa9939ee2a8ba1241659a9540dd88496b (patch)
tree36288398b92704740b07c1edfda142a56ec380dd /src/graphs
parent2178972412ecbf4301990e55067575cdd1faf526 (diff)
steps preview: make step goal line change colour with target
we also move the indicator line up in the z stack, as we want the line above the bars. This wasn't obvious before as the elements were all the same colour. The two processing functions, clamp and interpolateColors are probably not optimally placed in the code. These might move.
Diffstat (limited to '')
-rw-r--r--src/graphs/BarGraph.qml12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/graphs/BarGraph.qml b/src/graphs/BarGraph.qml
index 9674832..08415a3 100644
--- a/src/graphs/BarGraph.qml
+++ b/src/graphs/BarGraph.qml
@@ -26,6 +26,7 @@ Item {
property var labelsArr: []
property var maxValue: 0
property real indicatorLineHeight: 0
+ property color indicatorLineColor: "#FFFFFF"
signal barClicked(index: int)
function dataLoadingDone() {
barsRepeater.model = 0
@@ -47,15 +48,16 @@ Item {
Rectangle { // indicator line
id: indicatorLine
height: 1
- z: 1
+ z: 2
width: barsRepeater.count*(barGraph.width-markerParent.width)/Math.max(barGraph.valuesArr.length,3) - height/2
anchors.left: markerParent.right
y: barsRow.height*(1-(barGraph,indicatorLineHeight/barGraph.maxValue))
visible: barGraph.indicatorLineHeight != 0
+ color: barGraph.indicatorLineColor
}
Row { // bars
id: barsRow
- z: 2
+ z: 1
anchors {
left: markerParent.right
top: parent.top
@@ -100,4 +102,10 @@ Item {
}
}
}
+ function interpolateColors(color1, color2, position) {
+ return Qt.rgba(color1.r + (color2.r-color1.r)*position, color1.g+ (color2.g-color1.g)*position, color1.b + (color2.b-color1.b)*position,1)
+ }
+ function clamp(num, min, max) {
+ return Math.min(Math.max(num, min), max)
+ }
}