Back link auto-y-ranging to ohlc chart from vlm overlay fsp

pre_multi_feedz
Tyler Goodlet 2022-11-04 16:28:10 -04:00
parent b11dfbb008
commit 7bc67671b6
2 changed files with 19 additions and 5 deletions

View File

@ -814,7 +814,8 @@ class ChartPlotWidget(pg.PlotWidget):
# a better one?
def mk_vb(self, name: str) -> ChartView:
cv = ChartView(name)
cv.linkedsplits = self.linked
# link new view to chart's view set
cv.linked = self.linked
return cv
def __init__(
@ -1179,19 +1180,27 @@ class ChartPlotWidget(pg.PlotWidget):
)
pi.hideButtons()
# cv.enable_auto_yrange(self.view)
cv.enable_auto_yrange()
# compose this new plot's graphics with the current chart's
# existing one but with separate axes as neede and specified.
self.pi_overlay.add_plotitem(
pi,
index=index,
# only link x-axes,
# only link x-axes and
# don't relay any ``ViewBox`` derived event
# handlers since we only care about keeping charts
# x-synced on interaction (at least for now).
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')

View File

@ -624,6 +624,8 @@ async def open_vlm_displays(
# built-in vlm which we plot ASAP since it's
# usually data provided directly with OHLC history.
shm = ohlcv
ohlc_chart = linked.chart
chart = linked.add_plot(
name='volume',
shm=shm,
@ -639,6 +641,9 @@ async def open_vlm_displays(
# the curve item internals are pretty convoluted.
style='step',
)
ohlc_chart.view.enable_auto_yrange(
src_vb=chart.view,
)
# force 0 to always be in view
def multi_maxmin(