From be24473fb402c70e2130297668310f82c12d4204 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 31 Oct 2022 14:13:02 -0400 Subject: [PATCH] Adjust remaining chart internals to pg extensions Mainly this involves instantiating our overriden `PlotItem` in a few places and tweaking type annots. A further detail is that inside the fsp sub-chart creation code we hide some axes for overlays in the flows subchart; these were previously somehow hidden implicitly? --- piker/ui/_app.py | 2 ++ piker/ui/_chart.py | 15 +++++++++++---- piker/ui/_fsp.py | 10 +++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/piker/ui/_app.py b/piker/ui/_app.py index c99e2866..a31fd2da 100644 --- a/piker/ui/_app.py +++ b/piker/ui/_app.py @@ -78,6 +78,8 @@ async def _async_main( """ from . import _display + from ._pg_overrides import _do_overrides + _do_overrides() godwidget = main_widget diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index e0b92b56..f9aa4bec 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -73,6 +73,8 @@ from .._profile import pg_profile_enabled, ms_slower_then from ._overlay import PlotItemOverlay from ._flows import Flow from ._search import SearchWidget +from . import _pg_overrides as pgo +from .._profile import Profiler if TYPE_CHECKING: from ._display import DisplayState @@ -831,6 +833,7 @@ class ChartPlotWidget(pg.PlotWidget): static_yrange: Optional[tuple[float, float]] = None, + parent=None, **kwargs, ): ''' @@ -848,12 +851,15 @@ class ChartPlotWidget(pg.PlotWidget): # source of our custom interactions self.cv = cv = self.mk_vb(name) + pi = pgo.PlotItem(viewBox=cv, **kwargs) super().__init__( background=hcolor(view_color), viewBox=cv, # parent=None, # plotItem=None, # antialias=True, + parent=parent, + plotItem=pi, **kwargs ) # give viewbox as reference to chart @@ -1144,7 +1150,7 @@ class ChartPlotWidget(pg.PlotWidget): axis_side: str = 'right', axis_kwargs: dict = {}, - ) -> pg.PlotItem: + ) -> pgo.PlotItem: # Custom viewbox impl cv = self.mk_vb(name) @@ -1153,13 +1159,14 @@ class ChartPlotWidget(pg.PlotWidget): allowed_sides = {'left', 'right'} if axis_side not in allowed_sides: raise ValueError(f'``axis_side``` must be in {allowed_sides}') + yaxis = PriceAxis( orientation=axis_side, linkedsplits=self.linked, **axis_kwargs, ) - pi = pg.PlotItem( + pi = pgo.PlotItem( parent=self.plotItem, name=name, enableMenu=False, @@ -1246,7 +1253,7 @@ class ChartPlotWidget(pg.PlotWidget): # TODO: this probably needs its own method? if overlay: - if isinstance(overlay, pg.PlotItem): + if isinstance(overlay, pgo.PlotItem): if overlay not in self.pi_overlay.overlays: raise RuntimeError( f'{overlay} must be from `.plotitem_overlay()`' @@ -1405,7 +1412,7 @@ class ChartPlotWidget(pg.PlotWidget): If ``bars_range`` is provided use that range. ''' - profiler = pg.debug.Profiler( + profiler = Profiler( msg=f'`{str(self)}.maxmin(name={name})`: `{self.name}`', disabled=not pg_profile_enabled(), ms_threshold=ms_slower_then, diff --git a/piker/ui/_fsp.py b/piker/ui/_fsp.py index 3fa73504..94859efa 100644 --- a/piker/ui/_fsp.py +++ b/piker/ui/_fsp.py @@ -59,6 +59,7 @@ from ..fsp._volume import ( flow_rates, ) from ..log import get_logger +from .._profile import Profiler log = get_logger(__name__) @@ -190,7 +191,7 @@ async def open_fsp_actor_cluster( from tractor._clustering import open_actor_cluster - # profiler = pg.debug.Profiler( + # profiler = Profiler( # delayed=False, # disabled=False # ) @@ -212,7 +213,7 @@ async def run_fsp_ui( target: Fsp, conf: dict[str, dict], loglevel: str, - # profiler: pg.debug.Profiler, + # profiler: Profiler, # _quote_throttle_rate: int = 58, ) -> None: @@ -746,6 +747,8 @@ async def open_vlm_displays( }, ) + dvlm_pi.hideAxis('left') + dvlm_pi.hideAxis('bottom') # all to be overlayed curve names fields = [ 'dolla_vlm', @@ -878,6 +881,7 @@ async def open_vlm_displays( # keep both regular and dark vlm in view names=trade_rate_fields, ) + tr_pi.hideAxis('bottom') chart_curves( trade_rate_fields, @@ -951,7 +955,7 @@ async def start_fsp_displays( # }, # }, } - profiler = pg.debug.Profiler( + profiler = Profiler( delayed=False, disabled=False )