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:
2023-01-28 17:04:01 +01:00
parent 6619fbbbb6
commit c62bbb8ef4
2 changed files with 12 additions and 8 deletions

View File

@ -2,7 +2,8 @@ import enum
import csv
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):
@ -50,6 +51,14 @@ class ProfileHandler(QObject):
self.profileChanged.emit(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):
assert self.state == ProfileState.STOPPED