Only pass vr for bars, allow source vb in autorange

big_data_lines
Tyler Goodlet 2022-04-04 15:58:06 -04:00
parent 082b02776c
commit 2284e61eda
1 changed files with 23 additions and 7 deletions

View File

@ -37,7 +37,7 @@ from ..log import get_logger
from ._style import _min_points_to_show from ._style import _min_points_to_show
from ._editors import SelectRect from ._editors import SelectRect
from . import _event from . import _event
# from ._ohlc import BarItems from ._ohlc import BarItems
log = get_logger(__name__) log = get_logger(__name__)
@ -809,7 +809,8 @@ class ChartView(ViewBox):
self.setYRange(ylow, yhigh) self.setYRange(ylow, yhigh)
def enable_auto_yrange( def enable_auto_yrange(
vb: ChartView, self,
src_vb: Optional[ChartView] = None,
) -> None: ) -> None:
''' '''
@ -817,7 +818,10 @@ class ChartView(ViewBox):
based on data contents and ``ViewBox`` state. based on data contents and ``ViewBox`` state.
''' '''
vb.sigXRangeChanged.connect(vb._set_yrange) if src_vb is None:
src_vb = self
src_vb.sigXRangeChanged.connect(self._set_yrange)
# TODO: a smarter way to avoid calling this needlessly? # TODO: a smarter way to avoid calling this needlessly?
# 2 things i can think of: # 2 things i can think of:
@ -825,13 +829,13 @@ class ChartView(ViewBox):
# iterate those. # iterate those.
# - only register this when certain downsampleable graphics are # - only register this when certain downsampleable graphics are
# "added to scene". # "added to scene".
vb.sigXRangeChanged.connect(vb.maybe_downsample_graphics) src_vb.sigXRangeChanged.connect(self.maybe_downsample_graphics)
# mouse wheel doesn't emit XRangeChanged # mouse wheel doesn't emit XRangeChanged
vb.sigRangeChangedManually.connect(vb._set_yrange) src_vb.sigRangeChangedManually.connect(self._set_yrange)
# splitter(s) resizing # splitter(s) resizing
vb.sigResized.connect(vb._set_yrange) src_vb.sigResized.connect(self._set_yrange)
def disable_auto_yrange( def disable_auto_yrange(
self, self,
@ -863,9 +867,21 @@ class ChartView(ViewBox):
# graphics = list(self._chart._graphics.values()) # graphics = list(self._chart._graphics.values())
for name, graphics in chart._graphics.items(): for name, graphics in chart._graphics.items():
# TODO: make it so we don't have to do this XD
# if name == 'volume':
# continue
use_vr = False
if isinstance(graphics, BarItems):
use_vr = True
# pass in no array which will read and render from the last # pass in no array which will read and render from the last
# passed array (normally provided by the display loop.) # passed array (normally provided by the display loop.)
chart.update_graphics_from_array(name) chart.update_graphics_from_array(
name,
use_vr=use_vr,
)
# for graphic in graphics: # for graphic in graphics:
# ds_meth = getattr(graphic, 'maybe_downsample', None) # ds_meth = getattr(graphic, 'maybe_downsample', None)