From 756e6b53fb64b75d3f08014338640f197d354ea1 Mon Sep 17 00:00:00 2001 From: dodoradio Date: Wed, 2 Aug 2023 22:17:32 +0100 Subject: 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 --- src/graphs/TimeLabels.qml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3-70-g09d2