aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArseniy Movshev <dodoradio@outlook.com>2023-07-20 16:43:50 +0100
committerdodoradio <dodoradio@outlook.com>2023-07-20 19:17:49 +0100
commitf298c6bc220ea19a4bca9fdc4a44a7799d695b25 (patch)
tree0f685636570e4785912bb99b995f1eedf51693e0 /src
parenta4275a238f2a913923ee5b09edecba9c89ee4df1 (diff)
Use VerticalLabels in BarGraph
Currently the width of the labels isn't dynamic as it was before. This will need fixing.
Diffstat (limited to 'src')
-rw-r--r--src/graphs/BarGraph.qml18
-rw-r--r--src/stepCounter/StepCounterPreview.qml8
2 files changed, 3 insertions, 23 deletions
diff --git a/src/graphs/BarGraph.qml b/src/graphs/BarGraph.qml
index 2a16e97..1c869d7 100644
--- a/src/graphs/BarGraph.qml
+++ b/src/graphs/BarGraph.qml
@@ -25,33 +25,21 @@ Item {
property var valuesArr: []
property var labelsArr: []
property var maxValue: 0
- property var divisionsInterval: 0
- property var divisionsCount: 0
property real indicatorLineHeight: 0
function dataLoadingDone() {
barsRepeater.model = valuesArr.length
labelsRepeater.model = labelsArr.length
}
- Item { // labels column
+ VerticalLabels { // labels column
id: markerParent
- width: childrenRect.width
height: parent.height
+ width: parent.height*0.1
anchors {
left: parent.left
top: barsRow.top
bottom: barsRow.bottom
}
- Repeater {
- model: barGraph.divisionsCount
- delegate: Label {
- width: implicitWidth
- property var value: barGraph.divisionsInterval*index
- text: value > 1000 ? value/1000 + "k" : value
- font.pixelSize: Dims.w(5)
- y: parent.height - parent.height*barGraph.divisionsInterval*index/barGraph.maxValue - height/2
- verticalAlignment: Text.AlignVCenter
- }
- }
+ endValue: barGraph.maxValue
}
Rectangle { // indicator line
id: indicatorLine
diff --git a/src/stepCounter/StepCounterPreview.qml b/src/stepCounter/StepCounterPreview.qml
index ed9a999..2a152f0 100644
--- a/src/stepCounter/StepCounterPreview.qml
+++ b/src/stepCounter/StepCounterPreview.qml
@@ -70,14 +70,6 @@ Column {
labelsArr.push(weekday[currDate.getDay()])
}
}
-
- //this code figures out graph scaling
- var powTen = Math.floor(Math.log10(maxValue))
- divisionsInterval = Math.pow(10,powTen)
- console.log(Math.floor(maxValue/divisionsInterval))
- maxValue = divisionsInterval*Math.floor(maxValue/divisionsInterval) + (divisionsInterval/5)*Math.ceil((maxValue%divisionsInterval)/(divisionsInterval/5))
- divisionsCount = Math.floor(maxValue/divisionsInterval) + 1
- console.log(maxValue,divisionsInterval,divisionsCount)
dataLoadingDone()
}
indicatorLineHeight: loggerSettings.stepGoalEnabled ? loggerSettings.stepGoalTarget : 0