@@ -106,6 +106,7 @@ class MultiSparkline(displayio.TileGrid):
106
106
will scroll to the left.
107
107
"""
108
108
109
+ # pylint: disable=too-many-arguments, too-many-instance-attributes
109
110
def __init__ (
110
111
self ,
111
112
width : int ,
@@ -150,6 +151,8 @@ def __init__(
150
151
151
152
super ().__init__ (self ._bitmap , pixel_shader = self ._palette , x = x , y = y )
152
153
154
+ # pylint: enable=too-many-arguments
155
+
153
156
def clear_values (self ) -> None :
154
157
"""Clears _buffer and removes all lines in the group"""
155
158
self ._bitmap .fill (0 )
@@ -208,11 +211,10 @@ def _xintercept(
208
211
209
212
if slope == 0 and y_1 != horizontal_y : # does not intercept horizontalY
210
213
return None
211
- else :
212
- xint = (
213
- horizontal_y - b
214
- ) / slope # calculate the x-intercept at position y=horizontalY
215
- return int (xint )
214
+ xint = (
215
+ horizontal_y - b
216
+ ) / slope # calculate the x-intercept at position y=horizontalY
217
+ return int (xint )
216
218
217
219
def _add_point (
218
220
self ,
@@ -234,6 +236,7 @@ def _draw(self) -> None:
234
236
for i in range (self ._lines ):
235
237
Polygon .draw (self ._bitmap , self ._points [i ].values (), i + 1 , close = False )
236
238
239
+ # pylint: disable=too-many-locals, too-many-nested-blocks, too-many-branches
237
240
def update_line (self , line : int = None ) -> None :
238
241
"""Update the drawing of the sparkline.
239
242
param int|None line: Line to update. Set to None for updating all (default).
@@ -245,9 +248,9 @@ def update_line(self, line: int = None) -> None:
245
248
lines = [line ]
246
249
247
250
redraw = False
248
- for l in lines :
251
+ for a_line in lines :
249
252
# bail out early if we only have a single point
250
- n_points = self ._buffers [l ].len ()
253
+ n_points = self ._buffers [a_line ].len ()
251
254
if n_points < 2 :
252
255
continue
253
256
@@ -258,21 +261,21 @@ def update_line(self, line: int = None) -> None:
258
261
else :
259
262
xpitch = self ._xpitch
260
263
261
- self ._points [l ].clear () # remove all points
264
+ self ._points [a_line ].clear () # remove all points
262
265
263
- for count , value in enumerate (self ._buffers [l ].values ()):
266
+ for count , value in enumerate (self ._buffers [a_line ].values ()):
264
267
if count == 0 :
265
- self ._add_point (l , 0 , value )
268
+ self ._add_point (a_line , 0 , value )
266
269
else :
267
270
x = int (xpitch * count )
268
271
last_x = int (xpitch * (count - 1 ))
269
- top = self .y_tops [l ]
270
- bottom = self .y_bottoms [l ]
272
+ top = self .y_tops [a_line ]
273
+ bottom = self .y_bottoms [a_line ]
271
274
272
275
if (bottom <= last_value <= top ) and (
273
276
bottom <= value <= top
274
277
): # both points are in range, plot the line
275
- self ._add_point (l , x , value )
278
+ self ._add_point (a_line , x , value )
276
279
277
280
else : # at least one point is out of range, clip one or both ends the line
278
281
if ((last_value > top ) and (value > top )) or (
@@ -312,7 +315,9 @@ def update_line(self, line: int = None) -> None:
312
315
if redraw :
313
316
self ._draw ()
314
317
315
- def values (self , line : int ) -> List [float ]:
318
+ # pylint: enable=too-many-locals, too-many-nested-blocks, too-many-branches
319
+
320
+ def values_of (self , line : int ) -> List [float ]:
316
321
"""Returns the values displayed on the sparkline at given index."""
317
322
318
323
return self ._buffers [line ].values ()
0 commit comments