Back link auto-y-ranging to ohlc chart from vlm overlay fsp
parent
490d85aba5
commit
8f3fe8e542
|
@ -814,7 +814,8 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
# a better one?
|
# a better one?
|
||||||
def mk_vb(self, name: str) -> ChartView:
|
def mk_vb(self, name: str) -> ChartView:
|
||||||
cv = ChartView(name)
|
cv = ChartView(name)
|
||||||
cv.linkedsplits = self.linked
|
# link new view to chart's view set
|
||||||
|
cv.linked = self.linked
|
||||||
return cv
|
return cv
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -1179,19 +1180,27 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
)
|
)
|
||||||
pi.hideButtons()
|
pi.hideButtons()
|
||||||
|
|
||||||
# cv.enable_auto_yrange(self.view)
|
|
||||||
cv.enable_auto_yrange()
|
|
||||||
|
|
||||||
# compose this new plot's graphics with the current chart's
|
# compose this new plot's graphics with the current chart's
|
||||||
# existing one but with separate axes as neede and specified.
|
# existing one but with separate axes as neede and specified.
|
||||||
self.pi_overlay.add_plotitem(
|
self.pi_overlay.add_plotitem(
|
||||||
pi,
|
pi,
|
||||||
index=index,
|
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,),
|
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
|
# add axis title
|
||||||
# TODO: do we want this API to still work?
|
# TODO: do we want this API to still work?
|
||||||
# raxis = pi.getAxis('right')
|
# raxis = pi.getAxis('right')
|
||||||
|
|
|
@ -624,6 +624,8 @@ async def open_vlm_displays(
|
||||||
# built-in vlm which we plot ASAP since it's
|
# built-in vlm which we plot ASAP since it's
|
||||||
# usually data provided directly with OHLC history.
|
# usually data provided directly with OHLC history.
|
||||||
shm = ohlcv
|
shm = ohlcv
|
||||||
|
ohlc_chart = linked.chart
|
||||||
|
|
||||||
chart = linked.add_plot(
|
chart = linked.add_plot(
|
||||||
name='volume',
|
name='volume',
|
||||||
shm=shm,
|
shm=shm,
|
||||||
|
@ -639,6 +641,9 @@ async def open_vlm_displays(
|
||||||
# the curve item internals are pretty convoluted.
|
# the curve item internals are pretty convoluted.
|
||||||
style='step',
|
style='step',
|
||||||
)
|
)
|
||||||
|
ohlc_chart.view.enable_auto_yrange(
|
||||||
|
src_vb=chart.view,
|
||||||
|
)
|
||||||
|
|
||||||
# force 0 to always be in view
|
# force 0 to always be in view
|
||||||
def multi_maxmin(
|
def multi_maxmin(
|
||||||
|
|
Loading…
Reference in New Issue