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?
pg_exts_fork
Tyler Goodlet 2022-10-31 14:13:02 -04:00
parent b524ea5c22
commit be24473fb4
3 changed files with 20 additions and 7 deletions

View File

@ -78,6 +78,8 @@ async def _async_main(
""" """
from . import _display from . import _display
from ._pg_overrides import _do_overrides
_do_overrides()
godwidget = main_widget godwidget = main_widget

View File

@ -73,6 +73,8 @@ from .._profile import pg_profile_enabled, ms_slower_then
from ._overlay import PlotItemOverlay from ._overlay import PlotItemOverlay
from ._flows import Flow from ._flows import Flow
from ._search import SearchWidget from ._search import SearchWidget
from . import _pg_overrides as pgo
from .._profile import Profiler
if TYPE_CHECKING: if TYPE_CHECKING:
from ._display import DisplayState from ._display import DisplayState
@ -831,6 +833,7 @@ class ChartPlotWidget(pg.PlotWidget):
static_yrange: Optional[tuple[float, float]] = None, static_yrange: Optional[tuple[float, float]] = None,
parent=None,
**kwargs, **kwargs,
): ):
''' '''
@ -848,12 +851,15 @@ class ChartPlotWidget(pg.PlotWidget):
# source of our custom interactions # source of our custom interactions
self.cv = cv = self.mk_vb(name) self.cv = cv = self.mk_vb(name)
pi = pgo.PlotItem(viewBox=cv, **kwargs)
super().__init__( super().__init__(
background=hcolor(view_color), background=hcolor(view_color),
viewBox=cv, viewBox=cv,
# parent=None, # parent=None,
# plotItem=None, # plotItem=None,
# antialias=True, # antialias=True,
parent=parent,
plotItem=pi,
**kwargs **kwargs
) )
# give viewbox as reference to chart # give viewbox as reference to chart
@ -1144,7 +1150,7 @@ class ChartPlotWidget(pg.PlotWidget):
axis_side: str = 'right', axis_side: str = 'right',
axis_kwargs: dict = {}, axis_kwargs: dict = {},
) -> pg.PlotItem: ) -> pgo.PlotItem:
# Custom viewbox impl # Custom viewbox impl
cv = self.mk_vb(name) cv = self.mk_vb(name)
@ -1153,13 +1159,14 @@ class ChartPlotWidget(pg.PlotWidget):
allowed_sides = {'left', 'right'} allowed_sides = {'left', 'right'}
if axis_side not in allowed_sides: if axis_side not in allowed_sides:
raise ValueError(f'``axis_side``` must be in {allowed_sides}') raise ValueError(f'``axis_side``` must be in {allowed_sides}')
yaxis = PriceAxis( yaxis = PriceAxis(
orientation=axis_side, orientation=axis_side,
linkedsplits=self.linked, linkedsplits=self.linked,
**axis_kwargs, **axis_kwargs,
) )
pi = pg.PlotItem( pi = pgo.PlotItem(
parent=self.plotItem, parent=self.plotItem,
name=name, name=name,
enableMenu=False, enableMenu=False,
@ -1246,7 +1253,7 @@ class ChartPlotWidget(pg.PlotWidget):
# TODO: this probably needs its own method? # TODO: this probably needs its own method?
if overlay: if overlay:
if isinstance(overlay, pg.PlotItem): if isinstance(overlay, pgo.PlotItem):
if overlay not in self.pi_overlay.overlays: if overlay not in self.pi_overlay.overlays:
raise RuntimeError( raise RuntimeError(
f'{overlay} must be from `.plotitem_overlay()`' f'{overlay} must be from `.plotitem_overlay()`'
@ -1405,7 +1412,7 @@ class ChartPlotWidget(pg.PlotWidget):
If ``bars_range`` is provided use that range. If ``bars_range`` is provided use that range.
''' '''
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'`{str(self)}.maxmin(name={name})`: `{self.name}`', msg=f'`{str(self)}.maxmin(name={name})`: `{self.name}`',
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),
ms_threshold=ms_slower_then, ms_threshold=ms_slower_then,

View File

@ -59,6 +59,7 @@ from ..fsp._volume import (
flow_rates, flow_rates,
) )
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -190,7 +191,7 @@ async def open_fsp_actor_cluster(
from tractor._clustering import open_actor_cluster from tractor._clustering import open_actor_cluster
# profiler = pg.debug.Profiler( # profiler = Profiler(
# delayed=False, # delayed=False,
# disabled=False # disabled=False
# ) # )
@ -212,7 +213,7 @@ async def run_fsp_ui(
target: Fsp, target: Fsp,
conf: dict[str, dict], conf: dict[str, dict],
loglevel: str, loglevel: str,
# profiler: pg.debug.Profiler, # profiler: Profiler,
# _quote_throttle_rate: int = 58, # _quote_throttle_rate: int = 58,
) -> None: ) -> None:
@ -746,6 +747,8 @@ async def open_vlm_displays(
}, },
) )
dvlm_pi.hideAxis('left')
dvlm_pi.hideAxis('bottom')
# all to be overlayed curve names # all to be overlayed curve names
fields = [ fields = [
'dolla_vlm', 'dolla_vlm',
@ -878,6 +881,7 @@ async def open_vlm_displays(
# keep both regular and dark vlm in view # keep both regular and dark vlm in view
names=trade_rate_fields, names=trade_rate_fields,
) )
tr_pi.hideAxis('bottom')
chart_curves( chart_curves(
trade_rate_fields, trade_rate_fields,
@ -951,7 +955,7 @@ async def start_fsp_displays(
# }, # },
# }, # },
} }
profiler = pg.debug.Profiler( profiler = Profiler(
delayed=False, delayed=False,
disabled=False disabled=False
) )