From 7c732215ecf641c13c2897dffcd891520d59ca59 Mon Sep 17 00:00:00 2001 From: Yury Shuvakin Date: Mon, 28 Nov 2022 06:32:26 +0300 Subject: [PATCH] Fixed point info display on visualization screen. Removed version number from app name --- CUBO-BMS-Tool.pro | 3 +-- qml/Controls/ChartView.qml | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CUBO-BMS-Tool.pro b/CUBO-BMS-Tool.pro index e65b86d..52356ff 100644 --- a/CUBO-BMS-Tool.pro +++ b/CUBO-BMS-Tool.pro @@ -38,8 +38,7 @@ contains(DEFINES, HAS_SERIALPORT) { android: QT += androidextras -android: TARGET = CUBO-BMS-Tool -!android: TARGET = CUBO-BMS-Tool-V$$DT_VERSION +TARGET = CUBO-BMS-Tool TEMPLATE = app diff --git a/qml/Controls/ChartView.qml b/qml/Controls/ChartView.qml index 0fb5961..fabf3ef 100644 --- a/qml/Controls/ChartView.qml +++ b/qml/Controls/ChartView.qml @@ -174,20 +174,26 @@ ChartView { } function updatePointInfo() { - var currentPointVisibility = mouseX >= chart.plotArea.x && mouseX <= chart.plotArea.x + chart.plotArea.width && + let currentPointVisibility = mouseX >= chart.plotArea.x && mouseX <= chart.plotArea.x + chart.plotArea.width && mouseY >= chart.plotArea.y && mouseY <= chart.plotArea.y + chart.plotArea.height currentPointInfo.visible = currentPointVisibility currentPointInfo.x = mouseX + 5 currentPointInfo.y = mouseY - currentPointInfo.height - 5 - var currentX = Math.ceil(mapToValue(Qt.point(mouseX, mouseY), chart.series(selectedSeriesIndex)).x) - var selectedPoint = Qt.point(0, 0) + let currentX = mapToValue(Qt.point(mouseX, mouseY), chart.series(selectedSeriesIndex)).x + let selectedPoint = Qt.point(0, 0) - if (currentX < chart.series(selectedSeriesIndex).count && currentX > 0) { - selectedPoint = chart.series(selectedSeriesIndex).at(currentX) - currentPointInfoLabel.text = selectedPoint.x + " " + infoXMark + ", " + selectedPoint.y + " " + infoYMark - } else { + for(let i = 0; i < chart.series(selectedSeriesIndex).count; ++i) { + let point = chart.series(selectedSeriesIndex).at(i) + if (point.x > currentX || i === chart.series(selectedSeriesIndex).count - 1) { + selectedPoint = chart.series(selectedSeriesIndex).at(i) + currentPointInfoLabel.text = selectedPoint.x + " " + infoXMark + ", " + selectedPoint.y + " " + infoYMark + break + } + } + + if (chart.series(selectedSeriesIndex).count === 0) { currentPointInfo.visible = false }