From ea8450568207f41baf4219eb6c3a3e659e5e39ce Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 24 Jan 2023 12:46:09 -0500 Subject: [PATCH] Don't scale overlays on linked from display loop In the (incrementally updated) display loop we have range logic that is incrementally updated in real-time by streams, as such we don't really need to update all linked chart's (for any given, currently updated chart) y-ranges on calls of each separate (sub-)chart's `ChartView.interact_graphics_cycle()`. In practise there are plenty of cases where resizing in one chart (say the vlm fsps sub-plot) requires a y-range re-calc but not in the OHLC price chart. Therefore we always avoid doing more resizing then necessary despite it resulting in potentially more method call overhead (which will later be justified by better leveraging incrementally updated `Viz.maxmin()` and `media_from_range()` calcs). --- piker/ui/_display.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/piker/ui/_display.py b/piker/ui/_display.py index b1af26f5..72b0d76d 100644 --- a/piker/ui/_display.py +++ b/piker/ui/_display.py @@ -261,8 +261,8 @@ async def increment_history_view( profiler('`hist Viz.update_graphics()` call') if liv: - # hist_viz.plot.vb._set_yrange(viz=hist_viz) hist_viz.plot.vb.interact_graphics_cycle( + do_linked_charts=False, # do_overlay_scaling=False, ) profiler('hist chart yrange view') @@ -586,7 +586,6 @@ def graphics_update_cycle( or trigger_all ): chart.increment_view(datums=append_diff) - # main_viz.plot.vb._set_yrange(viz=main_viz) # NOTE: since vlm and ohlc charts are axis linked now we don't # need the double increment request? @@ -722,16 +721,14 @@ def graphics_update_cycle( # yr = (mn, mx) main_vb.interact_graphics_cycle( # do_overlay_scaling=False, + do_linked_charts=False, ) # TODO: we should probably scale # the view margin based on the size # of the true range? This way you can # slap in orders outside the current # L1 (only) book range. - # main_vb._set_yrange( - # yrange=yr - # # range_margin=0.1, - # ) + profiler('main vb y-autorange') # SLOW CHART resize case @@ -854,9 +851,15 @@ def graphics_update_cycle( mx_vlm_in_view != varz['last_mx_vlm'] ): varz['last_mx_vlm'] = mx_vlm_in_view + + # TODO: incr maxmin update as pass into below.. # vlm_yr = (0, mx_vlm_in_view * 1.375) - # vlm_chart.view._set_yrange(yrange=vlm_yr) - # profiler('`vlm_chart.view._set_yrange()`') + + main_vlm_viz.plot.vb.interact_graphics_cycle( + # do_overlay_scaling=False, + do_linked_charts=False, + ) + profiler('`vlm_chart.view.interact_graphics_cycle()`') # update all downstream FSPs for curve_name, viz in vlm_vizs.items(): @@ -884,10 +887,10 @@ def graphics_update_cycle( # resizing from last quote?) # XXX: without this we get completely # mangled/empty vlm display subchart.. - # fvb = viz.plot.vb - # fvb._set_yrange( - # viz=viz, - # ) + fvb = viz.plot.vb + fvb.interact_graphics_cycle( + do_linked_charts=False, + ) profiler(f'vlm `Viz[{viz.name}].plot.vb._set_yrange()`') # even if we're downsampled bigly