Move axis hiding into `.overlay_plotitem()`

Since we pretty much always want the 'bottom' and any side that is not
declared by the caller move the axis hides into this method. Lets us
drop the same calls in `.ui._fsp` and `._display`.

This also disables the auto-ranging back-linking for now since it
doesn't seem to be working quite yet?
multichartz
Tyler Goodlet 2023-01-21 18:39:41 -05:00
parent 36fb8abe9d
commit 185090f08f
3 changed files with 30 additions and 32 deletions

View File

@ -634,6 +634,7 @@ class LinkedSplits(QWidget):
axis.pi = cpw.plotItem axis.pi = cpw.plotItem
cpw.hideAxis('left') cpw.hideAxis('left')
# cpw.removeAxis('left')
cpw.hideAxis('bottom') cpw.hideAxis('bottom')
if ( if (
@ -750,12 +751,12 @@ class LinkedSplits(QWidget):
# NOTE: back-link the new sub-chart to trigger y-autoranging in # NOTE: back-link the new sub-chart to trigger y-autoranging in
# the (ohlc parent) main chart for this linked set. # the (ohlc parent) main chart for this linked set.
if self.chart: # if self.chart:
main_viz = self.chart.get_viz(self.chart.name) # main_viz = self.chart.get_viz(self.chart.name)
self.chart.view.enable_auto_yrange( # self.chart.view.enable_auto_yrange(
src_vb=cpw.view, # src_vb=cpw.view,
viz=main_viz, # viz=main_viz,
) # )
graphics = viz.graphics graphics = viz.graphics
data_key = viz.name data_key = viz.name
@ -1106,6 +1107,12 @@ class ChartPlotWidget(pg.PlotWidget):
pi.chart_widget = self pi.chart_widget = self
pi.hideButtons() pi.hideButtons()
# hide all axes not named by ``axis_side``
for axname in (
({'bottom'} | allowed_sides) - {axis_side}
):
pi.hideAxis(axname)
# 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(
@ -1209,17 +1216,21 @@ class ChartPlotWidget(pg.PlotWidget):
pi = overlay pi = overlay
if add_sticky: if add_sticky:
axis = pi.getAxis(add_sticky)
if pi.name not in axis._stickies:
if pi is not self.plotItem: if pi is not self.plotItem:
overlay = self.pi_overlay # overlay = self.pi_overlay
assert pi in overlay.overlays # assert pi in overlay.overlays
overlay_axis = overlay.get_axis( overlay = self.pi_overlay
pi, assert pi in overlay.overlays
add_sticky, axis = overlay.get_axis(
) pi,
assert overlay_axis is axis add_sticky,
)
else:
axis = pi.getAxis(add_sticky)
if pi.name not in axis._stickies:
# TODO: UGH! just make this not here! we should # TODO: UGH! just make this not here! we should
# be making the sticky from code which has access # be making the sticky from code which has access

View File

@ -1314,13 +1314,6 @@ async def display_symbol_data(
name=fqsn, name=fqsn,
axis_title=fqsn, axis_title=fqsn,
) )
# only show a singleton bottom-bottom axis by default.
hist_pi.hideAxis('bottom')
# XXX: TODO: THIS WILL CAUSE A GAP ON OVERLAYS,
# i think it needs to be "removed" instead when there
# are none?
hist_pi.hideAxis('left')
hist_viz = hist_chart.draw_curve( hist_viz = hist_chart.draw_curve(
fqsn, fqsn,
@ -1356,9 +1349,6 @@ async def display_symbol_data(
axis_title=fqsn, axis_title=fqsn,
) )
rt_pi.hideAxis('left')
rt_pi.hideAxis('bottom')
rt_viz = rt_chart.draw_curve( rt_viz = rt_chart.draw_curve(
fqsn, fqsn,
ohlcv, ohlcv,

View File

@ -691,7 +691,7 @@ async def open_vlm_displays(
# the axis on the left it's totally not lined up... # the axis on the left it's totally not lined up...
# show volume units value on LHS (for dinkus) # show volume units value on LHS (for dinkus)
# vlm_chart.hideAxis('right') # vlm_chart.hideAxis('right')
# vlm_chart.showAxis('left') vlm_chart.hideAxis('left')
# send back new chart to caller # send back new chart to caller
task_status.started(vlm_chart) task_status.started(vlm_chart)
@ -759,10 +759,6 @@ async def open_vlm_displays(
}, },
) )
# TODO: should this maybe be implicit based on input args to
# `.overlay_plotitem()` above?
dvlm_pi.hideAxis('bottom')
# all to be overlayed curve names # all to be overlayed curve names
dvlm_fields = [ dvlm_fields = [
'dolla_vlm', 'dolla_vlm',
@ -845,6 +841,8 @@ async def open_vlm_displays(
# liquidity events (well at least on low OHLC periods - 1s). # liquidity events (well at least on low OHLC periods - 1s).
vlm_curve.hide() vlm_curve.hide()
vlm_chart.removeItem(vlm_curve) vlm_chart.removeItem(vlm_curve)
# vlm_chart.plotItem.layout.setMinimumWidth(0)
# vlm_chart.removeAxis('left')
vlm_viz = vlm_chart._vizs['volume'] vlm_viz = vlm_chart._vizs['volume']
vlm_viz.render = False vlm_viz.render = False
@ -872,7 +870,6 @@ async def open_vlm_displays(
}, },
) )
tr_pi.hideAxis('bottom')
await started.wait() await started.wait()
chart_curves( chart_curves(