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()