From 412c9ee6cf13615a36597348034f08299eebc92f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 22 Feb 2022 15:08:41 -0500 Subject: [PATCH] Support view increment with a steps size --- piker/ui/_chart.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 6048ca42..2a3689a3 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -818,11 +818,18 @@ class ChartPlotWidget(pg.PlotWidget): def default_view( self, index: int = -1, - ) -> None: - """Set the view box to the "default" startup view of the scene. - """ - xlast = self._arrays[self.name][index]['index'] + ) -> None: + ''' + Set the view box to the "default" startup view of the scene. + + ''' + try: + xlast = self._arrays[self.name][index]['index'] + except IndexError: + log.warning(f'array for {self.name} not loaded yet?') + return + begin = xlast - _bars_to_left_in_follow_mode end = xlast + _bars_from_right_in_follow_mode @@ -840,6 +847,8 @@ class ChartPlotWidget(pg.PlotWidget): def increment_view( self, + steps: int = 1, + ) -> None: """ Increment the data view one step to the right thus "following" @@ -848,8 +857,8 @@ class ChartPlotWidget(pg.PlotWidget): """ l, r = self.view_range() self.view.setXRange( - min=l + 1, - max=r + 1, + min=l + steps, + max=r + steps, # TODO: holy shit, wtf dude... why tf would this not be 0 by # default... speechless. @@ -858,7 +867,6 @@ class ChartPlotWidget(pg.PlotWidget): def draw_ohlc( self, - name: str, data: np.ndarray,