Skip to content

Commit

Permalink
fix(graph): improve stability of label values
Browse files Browse the repository at this point in the history
Fix #25
  • Loading branch information
orblazer committed Jan 4, 2022
1 parent 45fedbd commit f0c548d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions package/contents/ui/components/SensorGraph.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.kde.quickcharts 1.0 as Charts
import "./" as RMComponents

RMComponents.BaseSensorGraph {
id: chart
id: chart

readonly property alias sensorsModel: sensorsModel

Expand Down Expand Up @@ -54,8 +54,11 @@ RMComponents.BaseSensorGraph {

// Update albel
if (index === 0) { // is first line
firstLineLabel.text = value || '...'
firstLineLabel.visible = true
if (typeof value === 'undefined') {
firstLineLabel.text = '...'
} else {
firstLineLabel.text = value
}
} else if (index === 1) { // is second line
if (typeof value === 'undefined') {
secondLineLabel.text = '...'
Expand Down Expand Up @@ -96,9 +99,8 @@ RMComponents.BaseSensorGraph {
var data = sensorsModel.getData(0)
if (typeof data !== "undefined") {
firstLineLabel.text = data
firstLineLabel.visible = true
} else {
firstLineLabel.visible = false
firstLineLabel.text = '...'
}

// Show second line
Expand All @@ -107,7 +109,8 @@ RMComponents.BaseSensorGraph {
secondLineLabel.text = data
secondLineLabel.visible = sensorsModel.getData(1, Sensors.SensorDataModel.Value) !== 0 || secondLabelWhenZero
} else {
secondLineLabel.visible = false
secondLineLabel.text = '...'
secondLineLabel.visible = secondLabelWhenZero
}

chart.showValueWhenMouseMove()
Expand Down

0 comments on commit f0c548d

Please sign in to comment.