From 6b8bf824c652a659131dfbe594bd042c383fc85f Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 19 Jul 2019 16:04:24 +0800 Subject: [PATCH] [Mod] use partial update to improve plotting speed --- vnpy/chart/item.py | 3 +++ vnpy/chart/widget.py | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/vnpy/chart/item.py b/vnpy/chart/item.py index c63adee3..467b9c3e 100644 --- a/vnpy/chart/item.py +++ b/vnpy/chart/item.py @@ -34,6 +34,9 @@ class ChartItem(pg.GraphicsObject): self._rect_area: Tuple[float, float] = None + # Very important! Only redraw the visible part and improve speed a lot. + self.setFlag(self.ItemUsesExtendedStyleOption) + @abstractmethod def _draw_bar_picture(self, ix: int, bar: BarData) -> QtGui.QPicture: """ diff --git a/vnpy/chart/widget.py b/vnpy/chart/widget.py index bf6455fe..53b5da1a 100644 --- a/vnpy/chart/widget.py +++ b/vnpy/chart/widget.py @@ -397,12 +397,7 @@ class ChartCursor(QtCore.QObject): """ Connect mouse move signal to update function. """ - self._proxy = pg.SignalProxy( - self._widget.scene().sigMouseMoved, - delay=0.1, - rateLimit=60, - slot=self._mouse_moved - ) + self._widget.scene().sigMouseMoved.connect(self._mouse_moved) def _mouse_moved(self, evt: tuple) -> None: """ @@ -412,7 +407,7 @@ class ChartCursor(QtCore.QObject): return # First get current mouse point - pos = evt[0] + pos = evt for plot_name, view in self._views.items(): rect = view.sceneBoundingRect()