Return xy data from `Curve.draw_last_datum()` methods

incremental_update_paths
Tyler Goodlet 2022-06-03 16:44:04 -04:00
parent a66934a49d
commit e5f96391e3
2 changed files with 23 additions and 10 deletions

View File

@ -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,

View File

@ -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']