Skip overlay transform calcs on common-pi curves

If there is a common `PlotItem` used for a set of `Viz`/curves (on
a given view) we don't need to do overlay scaling and thus can also
short circuit the viz iteration loop early.
storage_cli
Tyler Goodlet 2023-02-08 18:22:07 -05:00
parent 45368ff19d
commit 2b075c7644
1 changed files with 44 additions and 38 deletions

View File

@ -1088,12 +1088,19 @@ class ChartView(ViewBox):
profiler(f'{viz.name}@{chart_name} common pi sort') profiler(f'{viz.name}@{chart_name} common pi sort')
# non-overlay group case
if not viz.is_ohlc:
pi.vb._set_yrange(yrange=yrange)
profiler(
f'{viz.name}@{chart_name} simple std `._set_yrange()`'
)
# handle overlay log-linearized group scaling cases # handle overlay log-linearized group scaling cases
# TODO: a better predicate here, likely something # TODO: a better predicate here, likely something
# to do with overlays and their settings.. # to do with overlays and their settings..
if ( # TODO: we probably eventually might want some other
viz.is_ohlc # charts besides OHLC?
): else:
ymn, ymx = yrange ymn, ymx = yrange
# print(f'adding {viz.name} to overlay') # print(f'adding {viz.name} to overlay')
@ -1137,45 +1144,44 @@ class ChartView(ViewBox):
profiler(f'{viz.name}@{chart_name} MINOR curve scale') profiler(f'{viz.name}@{chart_name} MINOR curve scale')
# non-overlay group case # NOTE: if no there were no overlay charts
else: # detected/collected (could be either no group detected or
pi.vb._set_yrange(yrange=yrange) # chart with a single symbol, thus a single viz/overlay)
profiler( # then we ONLY set the lone chart's (viz) yrange and short
f'{viz.name}@{chart_name} simple std `._set_yrange()`' # circuit to the next chart in the linked charts loop. IOW
) # there's no reason to go through the overlay dispersion
# scaling in the next loop below when only one curve is
# NOTE: if no overlay group scaling is wanted by caller, or # detected.
# there were no overlay charts detected/collected, (could be
# either no group detected or chart with a single symbol,
# thus a single viz/overlay) then we ONLY set the lone
# chart's (viz) yrange and short circuit to the next chart
# in the linked charts sequence.
if ( if (
len(overlay_table) < 2 not mxmns_by_common_pi
or not overlay_table and len(overlay_table) < 2
): ):
if debug_print: if debug_print:
print(f'ONLY ranging major: {viz.name}') print(f'ONLY ranging major: {viz.name}')
# we're either in `do_overlay_scaling=False` mode out = _maybe_calc_yrange(
# or there is only one curve so we need to pick viz,
# that "only curve". yranges,
if not major_viz: profiler,
major_viz = viz chart_name,
if yranges is not None:
yrange = yranges.get(major_viz) or yrange
assert yrange
print(f'ONLY ranging major: {viz.name}')
major_viz.plot.vb._set_yrange(
yrange=yrange,
) )
profiler(f'{viz.name}@{chart_name} single curve yrange') if out is None:
if not do_linked_charts: continue
return
read_slc, yrange = out
viz.plot.vb._set_yrange(yrange=yrange)
profiler(f'{viz.name}@{chart_name} single curve yrange')
# move to next chart in linked set since
# no overlay transforming is needed.
continue
elif (
mxmns_by_common_pi
and not major_viz
):
# move to next chart in linked set since
# no overlay transforming is needed.
continue continue
profiler(f'<{chart_name}>.interact_graphics_cycle({name})') profiler(f'<{chart_name}>.interact_graphics_cycle({name})')
@ -1394,6 +1400,9 @@ class ChartView(ViewBox):
# if vrs[1][0] > major_mn: # if vrs[1][0] > major_mn:
# breakpoint() # breakpoint()
if not do_linked_charts:
return
profiler.finish() profiler.finish()
@ -1407,8 +1416,6 @@ def _maybe_calc_yrange(
if not viz.render: if not viz.render:
return return
# # print(f'skipping {flow.name}')
# continue
# pass in no array which will read and render from the last # pass in no array which will read and render from the last
# passed array (normally provided by the display loop.) # passed array (normally provided by the display loop.)
@ -1416,7 +1423,6 @@ def _maybe_calc_yrange(
if not in_view: if not in_view:
return return
# continue
profiler(f'{viz.name}@{chart_name} `Viz.update_graphics()`') profiler(f'{viz.name}@{chart_name} `Viz.update_graphics()`')