From 6ae32dffa9939ee2a8ba1241659a9540dd88496b Mon Sep 17 00:00:00 2001 From: dodoradio Date: Sun, 20 Aug 2023 16:32:47 +0100 Subject: 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. --- src/graphs/BarGraph.qml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/graphs') 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) + } } -- cgit v1.2.3-70-g09d2