From 9fc46fd40d0eb3117d39a98c2d4187bb891dd32a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 22 Jul 2021 11:42:12 -0400 Subject: [PATCH] Drop all `ChartPlotWidget._lc` remap to `.linked --- piker/data/_source.py | 2 +- piker/ui/_chart.py | 14 ++++++-------- piker/ui/_editors.py | 4 ++-- piker/ui/_label.py | 3 --- piker/ui/_lines.py | 4 +--- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/piker/data/_source.py b/piker/data/_source.py index 23524426..bcfc6025 100644 --- a/piker/data/_source.py +++ b/piker/data/_source.py @@ -1,5 +1,5 @@ # piker: trading gear for hackers -# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0) +# Copyright (C) 2018-present Tyler Goodlet (in stewardship for piker0) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 41647481..9704aa8e 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -287,7 +287,6 @@ class LinkedSplits(QtWidgets.QWidget): self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.splitter) - # state tracker? self._symbol: Symbol = None @property @@ -491,7 +490,6 @@ class ChartPlotWidget(pg.PlotWidget): **kwargs ) self.name = name - self._lc = linkedsplits self.linked = linkedsplits # scene-local placeholder for book graphics @@ -733,7 +731,7 @@ class ChartPlotWidget(pg.PlotWidget): # if the sticky is for our symbol # use the tick size precision for display - sym = self._lc.symbol + sym = self.linked.symbol if name == sym.key: digits = sym.digits() else: @@ -983,7 +981,7 @@ async def chart_from_quotes( last, volume = ohlcv.array[-1][['close', 'volume']] - symbol = chart._lc.symbol + symbol = chart.linked.symbol l1 = L1Labels( chart, @@ -1001,7 +999,7 @@ async def chart_from_quotes( # levels this might be dark volume we need to # present differently? - tick_size = chart._lc.symbol.tick_size + tick_size = chart.linked.symbol.tick_size tick_margin = 2 * tick_size last_ask = last_bid = last_clear = time.time() @@ -1010,7 +1008,7 @@ async def chart_from_quotes( async for quotes in stream: # chart isn't actively shown so just skip render cycle - if chart._lc.isHidden(): + if chart.linked.isHidden(): continue for sym, quote in quotes.items(): @@ -1300,7 +1298,7 @@ async def run_fsp( value = array[fsp_func_name][-1] last_val_sticky.update_from_data(-1, value) - chart._lc.focus() + chart.linked.focus() # works also for overlays in which case data is looked up from # internal chart array set.... @@ -1335,7 +1333,7 @@ async def run_fsp( async for value in stream: # chart isn't actively shown so just skip render cycle - if chart._lc.isHidden(): + if chart.linked.isHidden(): continue now = time.time() diff --git a/piker/ui/_editors.py b/piker/ui/_editors.py index 1bb9d7e2..5d24a314 100644 --- a/piker/ui/_editors.py +++ b/piker/ui/_editors.py @@ -118,7 +118,7 @@ class LineEditor: chart = cursor.active_plot y = cursor._datum_xy[1] - symbol = chart._lc.symbol + symbol = chart.linked.symbol # add a "staged" cursor-tracking line to view # and cash it in a a var @@ -194,7 +194,7 @@ class LineEditor: if not line: raise RuntimeError("No line is currently staged!?") - sym = chart._lc.symbol + sym = chart.linked.symbol line = order_line( chart, diff --git a/piker/ui/_label.py b/piker/ui/_label.py index f0a0ec31..3ebe6228 100644 --- a/piker/ui/_label.py +++ b/piker/ui/_label.py @@ -210,9 +210,6 @@ class Label: assert s_xy == self.txt.pos() - def orient_on(self, h: str, v: str) -> None: - pass - @property def fmt_str(self) -> str: return self._fmt_str diff --git a/piker/ui/_lines.py b/piker/ui/_lines.py index 2f83ec7f..87d360d9 100644 --- a/piker/ui/_lines.py +++ b/piker/ui/_lines.py @@ -114,9 +114,7 @@ class LevelLine(pg.InfiniteLine): self._on_drag_start = lambda l: None self._on_drag_end = lambda l: None - self._y_incr_mult = 1 / chart._lc._symbol.tick_size - self._last_scene_y: float = 0 - + self._y_incr_mult = 1 / chart.linked.symbol.tick_size self._right_end_sc: float = 0 def txt_offsets(self) -> Tuple[int, int]: