Skip to content

Commit 1857b97

Browse files
committed
recalculate min/max after pop
1 parent 780fe1b commit 1857b97

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_display_shapes/sparkline.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ def add_value(self, value: float, update: bool = True) -> None:
127127
if (
128128
len(self._spark_list) >= self._max_items
129129
): # if list is full, remove the first item
130-
self._spark_list.pop(0)
130+
first = self._spark_list.pop(0)
131+
# check if boundaries have to be updated
132+
if self.y_min is None and first == self.y_bottom:
133+
self.y_bottom = min(self._spark_list)
134+
if self.y_max is None and first == self.y_top:
135+
self.y_top = max(self._spark_list)
131136
self._redraw = True
132137
self._spark_list.append(value)
133138

0 commit comments

Comments
 (0)