Fill chart series in python
QML doesn't have a method for replacing all points at once, which makes it extremely slow when loading large profiles
This commit is contained in:
parent
6619fbbbb6
commit
c62bbb8ef4
@ -2,7 +2,8 @@ import enum
|
|||||||
import csv
|
import csv
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PySide6.QtCore import QObject, Signal, QTimer
|
from PySide6.QtCore import QObject, Signal, Slot, QTimer, QPointF
|
||||||
|
from PySide6.QtCharts import QLineSeries
|
||||||
|
|
||||||
|
|
||||||
class ProfileState(enum.Enum):
|
class ProfileState(enum.Enum):
|
||||||
@ -50,6 +51,14 @@ class ProfileHandler(QObject):
|
|||||||
self.profileChanged.emit(result)
|
self.profileChanged.emit(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Slot(QLineSeries)
|
||||||
|
def fill_series(self, series: QLineSeries):
|
||||||
|
points = []
|
||||||
|
for x, y in self._profile:
|
||||||
|
points.append(QPointF(x, y))
|
||||||
|
series.replace(points)
|
||||||
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
assert self.state == ProfileState.STOPPED
|
assert self.state == ProfileState.STOPPED
|
||||||
|
|
||||||
|
@ -29,13 +29,8 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onProfileChanged(data) {
|
function onProfileChanged(data) {
|
||||||
profileSeries.clear();
|
profile_handler.fill_series(profileSeries);
|
||||||
var last_x = 0;
|
axisX.max = data[data.length - 1][0];
|
||||||
for (var point of data) {
|
|
||||||
profileSeries.append(point[0], point[1]);
|
|
||||||
last_x = point[0];
|
|
||||||
}
|
|
||||||
axisX.max = last_x;
|
|
||||||
axisX.applyNiceNumbers();
|
axisX.applyNiceNumbers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user