Zoom & scroll profile chart

This commit is contained in:
Jasper Blanckenburg 2023-01-28 17:51:10 +01:00
parent c62bbb8ef4
commit 23f96c214b

View File

@ -30,15 +30,22 @@ ApplicationWindow {
function onProfileChanged(data) {
profile_handler.fill_series(profileSeries);
axisX.max = data[data.length - 1][0];
var x_max = data[data.length - 1][0];
axisX.max = x_max;
axisX.applyNiceNumbers();
profileView.zoomReset();
}
}
onProfileTimeChanged: {
var old_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
currentTimeSeries.clear()
currentTimeSeries.append(profileTime, 0)
currentTimeSeries.append(profileTime, 100)
var new_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
if (new_x > profileView.plotArea.width / 2) {
profileView.scrollRight(new_x - old_x);
}
}
onBmsErrorChanged: {
@ -63,6 +70,8 @@ ApplicationWindow {
}
}
ChartView {
id: profileView
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: 400
@ -97,6 +106,28 @@ ApplicationWindow {
visible: true
}
}
RowLayout {
Button {
text: "+"
onClicked: {
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width / 2, profileView.plotArea.height);
profileView.zoomIn(r);
}
}
Button {
text: "-"
onClicked: {
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width * 2, profileView.plotArea.height);
profileView.zoomIn(r);
}
}
Button {
text: "Reset zoom"
onClicked: {
profileView.zoomReset();
}
}
}
RowLayout {
Button {
objectName: "start_pause"