diff options
author | dodoradio <dodoradio@outlook.com> | 2023-08-02 22:17:32 +0100 |
---|---|---|
committer | dodoradio <dodoradio@outlook.com> | 2023-08-02 22:35:37 +0100 |
commit | 756e6b53fb64b75d3f08014338640f197d354ea1 (patch) | |
tree | a0617efbf5984693c86fee51fe075360f425b413 /src/graphs | |
parent | 85b85d907d88912314b752e4f75694d145c839d4 (diff) |
Timelabels: format hours/minutes more appropriately
- don't bother rendering hours for every label - this isn't useful information and crowds the screen
- make sure we 0-pad any numbers below 10
Diffstat (limited to '')
-rw-r--r-- | src/graphs/TimeLabels.qml | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/graphs/TimeLabels.qml b/src/graphs/TimeLabels.qml index bebeca5..eebec9e 100644 --- a/src/graphs/TimeLabels.qml +++ b/src/graphs/TimeLabels.qml @@ -47,7 +47,12 @@ Item { var date while (currentTime < endTime) { date = new Date(currentTime*1000) - var value = date.getHours().toString() + ":" + date.getMinutes().toString() + var value + if (date.getMinutes() == 0 | i == 0) { + value = date.getHours() + (date.getMinutes() < 10 ? ":0" + date.getMinutes().toString() : date.getMinutes().toString()) + } else if (date.getMinutes() < 10) { + value = date.getMinutes() < 10 ? ":0" + date.getMinutes().toString() : date.getMinutes().toString() + } var x = (currentTime - startTime) / delta listModel.append({"value": value, "x": x}) currentTime = currentTime + interval @@ -67,7 +72,12 @@ Item { var date while (currentTime < endTime) { date = new Date(currentTime*1000) - var value = date.getHours().toString() + ":" + date.getMinutes().toString() + var value + if (date.getMinutes() == 0 | i == 0) { + value = date.getHours() + (date.getMinutes() < 10 ? ":0" + date.getMinutes().toString() : date.getMinutes().toString()) + } else if (date.getMinutes() < 10) { + value = date.getMinutes() < 10 ? ":0" + date.getMinutes().toString() : date.getMinutes().toString() + } var x = (currentTime - startTime) / delta listModel.append({"value": value, "x": x}) currentTime = currentTime + interval @@ -89,7 +99,12 @@ Item { var date while (currentTime < endTime) { date = new Date(currentTime*1000) - var value = date.getHours().toString() + ":" + date.getMinutes().toString() + var value + if (date.getMinutes() != 0 | interval != 1800) { + value = date.getHours().toString() + "h" + } else { + value = ":" + date.getMinutes() + } var x = (currentTime - startTime) / delta listModel.append({"value": value, "x": x}) currentTime = currentTime + interval |