diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index ad415031..cb696257 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -133,7 +133,7 @@ class Curve(pg.GraphicsObject): # self.last_step_pen = pg.mkPen(hcolor(color), width=2) self.last_step_pen = pg.mkPen(pen, width=2) - self._last_line = QLineF() + self._last_line: QLineF = QLineF() # flat-top style histogram-like discrete curve # self._step_mode: bool = step_mode @@ -182,6 +182,13 @@ class Curve(pg.GraphicsObject): else: return 0 + def x_last(self) -> float: + ''' + Return the last most x value of the last line segment. + + ''' + return self._last_line.x2() + def px_width(self) -> float: vb = self.getViewBox() diff --git a/piker/ui/_ohlc.py b/piker/ui/_ohlc.py index 9a37bbfa..a7e36146 100644 --- a/piker/ui/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -114,12 +114,20 @@ class BarItems(pg.GraphicsObject): self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache) self.path = QPainterPath() - self._last_bar_lines: Optional[tuple[QLineF, ...]] = None + + self._last_bar_lines: tuple[QLineF, ...] | None = None def x_uppx(self) -> int: # we expect the downsample curve report this. return 0 + def x_last(self) -> float: + ''' + Return the last most x value of the close line segment. + + ''' + return self._last_bar_lines[-1].x2() + # Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect def boundingRect(self): # profiler = Profiler(