diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index 8feb24b9..ac967bf7 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -383,17 +383,16 @@ class Curve(pg.GraphicsObject): x = render_data['index'] y = render_data[array_key] - x_last = x[-1] - y_last = y[-1] - # draw the "current" step graphic segment so it # lines up with the "middle" of the current # (OHLC) sample. self._last_line = QLineF( x[-2], y[-2], - x_last, y_last + x[-1], y[-1], ) + return x, y + # TODO: this should probably be a "downsampled" curve type # that draws a bar-style (but for the px column) last graphics @@ -421,6 +420,7 @@ class FlattenedOHLC(Curve): x[-2], y[-2], x[-1], y[-1] ) + return x, y class StepCurve(Curve): @@ -461,6 +461,7 @@ class StepCurve(Curve): x_last - w, 0, x_last + w, y_last, ) + return x, y def sub_paint( self, diff --git a/piker/ui/_ohlc.py b/piker/ui/_ohlc.py index 0f7ce6f7..dbe4c18e 100644 --- a/piker/ui/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -200,16 +200,26 @@ class BarItems(pg.GraphicsObject): reset: bool, array_key: str, + fields: list[str] = [ + 'index', + 'open', + 'high', + 'low', + 'close', + ], + ) -> None: - last = src_data[-1] + + # relevant fields + ohlc = src_data[fields] + last_row = ohlc[-1:] + + # individual values + last_row = i, o, h, l, last = ohlc[-1] # generate new lines objects for updatable "current bar" - self._last_bar_lines = bar_from_ohlc_row(last) + self._last_bar_lines = bar_from_ohlc_row(last_row) - # last bar update - i, o, h, l, last, v = last[ - ['index', 'open', 'high', 'low', 'close', 'volume'] - ] # assert i == graphics.start_index - 1 # assert i == last_index body, larm, rarm = self._last_bar_lines @@ -236,3 +246,5 @@ class BarItems(pg.GraphicsObject): # removal of the body for a bar index that is now out of # date / from some previous sample. It's weird though # because i've seen it do this to bars i - 3 back? + + return ohlc['index'], ohlc['close']