summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphs/BarGraph.qml12
-rw-r--r--src/stepCounter/StepCounterPreview.qml1
-rw-r--r--src/stepCounter/StepsDetailPage.qml1
3 files changed, 12 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)
+ }
}
diff --git a/src/stepCounter/StepCounterPreview.qml b/src/stepCounter/StepCounterPreview.qml
index 9042dd7..823f739 100644
--- a/src/stepCounter/StepCounterPreview.qml
+++ b/src/stepCounter/StepCounterPreview.qml
@@ -83,6 +83,7 @@ MouseArea {
dataLoadingDone()
}
indicatorLineHeight: loggerSettings.stepGoalEnabled ? loggerSettings.stepGoalTarget : 0
+ indicatorLineColor: interpolateColors(Qt.rgba(1,0,0,1),Qt.rgba(0.06,1,0.11,1),clamp(stepsDataLoader.todayTotal/loggerSettings.stepGoalTarget,0,1))
onBarClicked: (index)=> {
var d = new Date()
d.setDate(d.getDate() - valuesArr.length + 1 + index)
diff --git a/src/stepCounter/StepsDetailPage.qml b/src/stepCounter/StepsDetailPage.qml
index 7949a2f..2862eea 100644
--- a/src/stepCounter/StepsDetailPage.qml
+++ b/src/stepCounter/StepsDetailPage.qml
@@ -91,6 +91,7 @@ Item {
}
}
}
+ indicatorLineColor = interpolateColors(Qt.rgba(1,0,0,1),Qt.rgba(0.06,1,0.11,1),clamp(stepsDataLoader.getTotalForDate(stepsLineGraph.startTime)/loggerSettings.stepGoalTarget,0,1))
dataLoadingDone()
}
indicatorLineHeight: loggerSettings.stepGoalEnabled ? loggerSettings.stepGoalTarget : 0