From f9eb8804049b03c2e844cb58750e9ea354ecf0ca Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 18 Jan 2023 13:33:19 -0500 Subject: [PATCH] Backlink subchart views to "main chart" in `.add_plot()` --- piker/ui/_chart.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 87feb4ed..64c091d5 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -629,7 +629,6 @@ class LinkedSplits(QWidget): for axis in axes.values(): axis.pi = cpw.plotItem - cpw.hideAxis('left') cpw.hideAxis('bottom') @@ -743,6 +742,15 @@ class LinkedSplits(QWidget): else: raise ValueError(f"Chart style {style} is currently unsupported") + # NOTE: back-link the new sub-chart to trigger y-autoranging in + # the (ohlc parent) main chart for this linked set. + if self.chart: + main_viz = self.chart.get_viz(self.chart.name) + self.chart.view.enable_auto_yrange( + src_vb=cpw.view, + viz=main_viz, + ) + graphics = viz.graphics data_key = viz.name @@ -1105,15 +1113,6 @@ class ChartPlotWidget(pg.PlotWidget): link_axes=(0,), ) - # connect auto-yrange callbacks *from* this new - # view **to** this parent and likewise *from* the - # main/parent chart back *to* the created overlay. - cv.enable_auto_yrange(src_vb=self.view) - - # makes it so that interaction on the new overlay will reflect - # back on the main chart (which overlay was added to). - self.view.enable_auto_yrange(src_vb=cv) - # add axis title # TODO: do we want this API to still work? # raxis = pi.getAxis('right') @@ -1184,6 +1183,15 @@ class ChartPlotWidget(pg.PlotWidget): # register curve graphics with this viz graphics=graphics, ) + + # connect auto-yrange callbacks *from* this new + # view **to** this parent and likewise *from* the + # main/parent chart back *to* the created overlay. + pi.vb.enable_auto_yrange( + src_vb=self.view, + viz=viz, + ) + pi.viz = viz assert isinstance(viz.shm, ShmArray)