From d3c85bc925ef25faf8f0004fbc22f20fb93a67a5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 27 Feb 2023 17:16:33 -0500 Subject: [PATCH] Back-rescale previous (minor) curves from latest For the "pin to target major/target curve" overlay method, this finally solves the longstanding issue of ensuring that any new minor curve, which requires and increase in the major/target curve y-range, also re-scales all previously scaled minor curves retroactively. Thus we now guarantee that all minor curves are correctly "pinned" to their target/major on their earliest available datum **and** are all kept in view. --- piker/ui/view_mode.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/piker/ui/view_mode.py b/piker/ui/view_mode.py index 73051d06..674a92c3 100644 --- a/piker/ui/view_mode.py +++ b/piker/ui/view_mode.py @@ -651,18 +651,34 @@ def overlay_viewlists( # TODO: rescale all already scaled curves to # new increased range for this side. - # for ( - # view, - # (yref, ymn, ymx) - # ) in scaled.items(): - # pass + for _view in scaled: + _yref, _ymn, _ymx = scaled[_view] + new_ymn = _yref * (1 + r_dn_minor) + + # TODO: is there a faster way to do this + # by mutating state on some object + # instead? + scaled[_view] = (_yref, new_ymn, _ymx) ymx = y_start * (1 + r_major_up_here) if ymx < y_max: + # set the `scaled: dict` entry to ensure + # that this minor curve will be entirely in + # view. ymx = y_max r_up_minor = (ymx - y_start) / y_start + + # adjust the target-major curve's range to + # (log-linearly) include this extra range by + # applying the inverse transform of the + # minor. mx_ymx = y_ref_major * (1 + r_up_minor) + for _view in scaled: + _yref, _ymn, _ymx = scaled[_view] + new_ymx = _yref * (1 + r_up_minor) + scaled[_view] = (_yref, _ymn, new_ymx) + if debug_print: print( f'Minor SCALARS {viz.name}:\n'