Ensure we update the volume array, not graphics

Ugh, turns out the wacky `ChartView.maxmin` callback stuff we did (for
determining y-range sizings) currently requires that the volume array
has a "bars in view" result.. so let's make that keep working without
rendering the graphics for the curve (since we're disabling them once
$vlm comes up).
big_data_lines
Tyler Goodlet 2022-04-04 14:43:13 -04:00
parent eeca9eb4c7
commit 27e3d0ef80
1 changed files with 35 additions and 5 deletions

View File

@ -75,6 +75,7 @@ _tick_groups = {
def chart_maxmin(
chart: ChartPlotWidget,
ohlcv_shm: ShmArray,
vlm_chart: Optional[ChartPlotWidget] = None,
) -> tuple[
@ -91,7 +92,8 @@ def chart_maxmin(
# https://arxiv.org/abs/cs/0610046
# https://github.com/lemire/pythonmaxmin
array = chart._arrays[chart.name]
# array = chart._arrays[chart.name]
array = ohlcv_shm.array
ifirst = array[0]['index']
last_bars_range = chart.bars_range()
@ -183,7 +185,12 @@ async def graphics_update_loop(
if vlm_chart:
vlm_sticky = vlm_chart._ysticks['volume']
maxmin = partial(chart_maxmin, chart, vlm_chart)
maxmin = partial(
chart_maxmin,
chart,
ohlcv,
vlm_chart,
)
last_bars_range: tuple[float, float]
(
last_bars_range,
@ -359,6 +366,7 @@ def graphics_update_cycle(
# compute the first available graphic's x-units-per-pixel
xpx = vlm_chart.view.xs_in_px()
# print(f'vlm xpx {xpx}')
in_view = chart.in_view(ohlcv.array)
@ -436,14 +444,30 @@ def graphics_update_cycle(
):
# TODO: make it so this doesn't have to be called
# once the $vlm is up?
vlm_chart.update_graphics_from_array('volume', array)
vlm_chart.update_graphics_from_array(
'volume',
array,
# UGGGh, see ``maxmin()`` impl in `._fsp` for
# the overlayed plotitems... we need a better
# bay to invoke a maxmin per overlay..
render=False,
# XXX: ^^^^ THIS IS SUPER IMPORTANT! ^^^^
# without this, since we disable the
# 'volume' (units) chart after the $vlm starts
# up we need to be sure to enable this
# auto-ranging otherwise there will be no handler
# connected to update accompanying overlay
# graphics..
)
if (
mx_vlm_in_view != vars['last_mx_vlm']
):
# print(f'mx vlm: {last_mx_vlm} -> {mx_vlm_in_view}')
yrange = (0, mx_vlm_in_view * 1.375)
vlm_chart.view._set_yrange(
yrange=(0, mx_vlm_in_view * 1.375)
yrange=yrange,
)
vars['last_mx_vlm'] = mx_vlm_in_view
@ -455,7 +479,10 @@ def graphics_update_cycle(
array_key=curve_name,
)
# is this even doing anything?
flow.plot.vb._set_yrange(
# (pretty sure it's the real-time
# resizing from last quote?)
fvb = flow.plot.vb
fvb._set_yrange(
autoscale_linked_plots=False,
name=curve_name,
)
@ -601,6 +628,9 @@ def graphics_update_cycle(
# run synchronous update on all derived fsp subplots
for name, subchart in ds.linked.subplots.items():
if name == 'volume':
continue
update_fsp_chart(
subchart,
subchart._shm,