Skip to content

Commit f90a7cb

Browse files
authored
Merge pull request #69 from Karel-Kroeze/main
reduce unnecessary redrawing of lines in `MultiSparkLine.add_values()`
2 parents f975229 + 5b7283e commit f90a7cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_display_shapes/multisparkline.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ def add_values(self, values: List[float], update: bool = True) -> None:
172172
call the update()-method
173173
"""
174174

175+
lines_to_update = []
175176
for i, value in enumerate(values):
176177
if value is not None:
178+
lines_to_update.append(i)
177179
top = self.y_tops[i]
178180
bottom = self.y_bottoms[i]
179181
if (
@@ -195,8 +197,8 @@ def add_values(self, values: List[float], update: bool = True) -> None:
195197
self.y_tops[i] = top
196198
self.y_bottoms[i] = bottom
197199

198-
if update:
199-
self.update_line(i)
200+
if update and lines_to_update:
201+
self.update_line(lines_to_update)
200202

201203
def _add_point(
202204
self,

0 commit comments

Comments
 (0)