Disconnect signals in `ChartView.disable_auto_yrange()`

Allows for removing resize callbacks for a flow/overlay that you wish to
remove from view (eg. unit volume after dollar volume is up) and thus
less general interaction callback overhead for any plot you don't wish
to show or resize.

Further,
- drop the `autoscale_linked_plots` block for now since with
  multi-view-box overlays each register their own vb resize slots
- pull the graphics object from the chart's `Flow` map inside
  `.maybe_downsample_graphics()`
big_data_lines
Tyler Goodlet 2022-04-07 10:58:09 -04:00
parent ca283660de
commit 454cd7920d
1 changed files with 39 additions and 23 deletions

View File

@ -780,21 +780,21 @@ class ChartView(ViewBox):
# TODO: maybe should be a method on the # TODO: maybe should be a method on the
# chart widget/item? # chart widget/item?
# if False: # if False:
if autoscale_linked_plots: # if autoscale_linked_plots:
# avoid recursion by sibling plots # # avoid recursion by sibling plots
linked = self.linkedsplits # linked = self.linkedsplits
plots = list(linked.subplots.copy().values()) # plots = list(linked.subplots.copy().values())
main = linked.chart # main = linked.chart
if main: # if main:
plots.append(main) # plots.append(main)
for chart in plots: # for chart in plots:
if chart and not chart._static_yrange: # if chart and not chart._static_yrange:
chart.cv._set_yrange( # chart.cv._set_yrange(
bars_range=br, # bars_range=br,
autoscale_linked_plots=False, # autoscale_linked_plots=False,
) # )
profiler('autoscaled linked plots') # profiler('autoscaled linked plots')
if set_range: if set_range:
@ -839,8 +839,17 @@ class ChartView(ViewBox):
if src_vb is None: if src_vb is None:
src_vb = self src_vb = self
# such that when a linked chart changes its range
# this local view is also automatically changed and
# resized to data.
src_vb.sigXRangeChanged.connect(self._set_yrange) src_vb.sigXRangeChanged.connect(self._set_yrange)
# splitter(s) resizing
src_vb.sigResized.connect(self._set_yrange)
# mouse wheel doesn't emit XRangeChanged
src_vb.sigRangeChangedManually.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:
# - register downsample-able graphics specially and only # - register downsample-able graphics specially and only
@ -851,17 +860,24 @@ class ChartView(ViewBox):
self.maybe_downsample_graphics self.maybe_downsample_graphics
) )
# mouse wheel doesn't emit XRangeChanged
src_vb.sigRangeChangedManually.connect(self._set_yrange)
# splitter(s) resizing
src_vb.sigResized.connect(self._set_yrange)
def disable_auto_yrange( def disable_auto_yrange(
self, self,
) -> None: ) -> None:
self._chart._static_yrange = 'axis' # self._chart._static_yrange = 'axis'
self.sigXRangeChanged.disconnect(
self._set_yrange,
)
self.sigResized.disconnect(
self._set_yrange,
)
self.sigRangeChangedManually.disconnect(
self.maybe_downsample_graphics
)
self.sigRangeChangedManually.disconnect(
self._set_yrange,
)
def x_uppx(self) -> float: def x_uppx(self) -> float:
''' '''
@ -907,8 +923,8 @@ class ChartView(ViewBox):
linked = self.linkedsplits linked = self.linkedsplits
plots = linked.subplots | {chart.name: chart} plots = linked.subplots | {chart.name: chart}
for chart_name, chart in plots.items(): for chart_name, chart in plots.items():
for name, graphics in chart._graphics.items(): for name, flow in chart._flows.items():
# print(f'maybe ds chart:{name} graphic:{name}') graphics = flow.graphics
use_vr = False use_vr = False
if isinstance(graphics, BarItems): if isinstance(graphics, BarItems):