15
15
# included in the graph. When additional elements are added to the sparkline and
16
16
# the number of items has exceeded max_items, any excess values are removed from
17
17
# the left of the graph, and new values are added to the right.
18
+ """
19
+ `sparkline`
20
+ ================================================================================
21
+
22
+ Various common shapes for use with displayio - Sparkline!
23
+
24
+
25
+ * Author(s): Kevin Matocha
26
+
27
+ Implementation Notes
28
+ --------------------
29
+
30
+ **Software and Dependencies:**
31
+
32
+ * Adafruit CircuitPython firmware for the supported boards:
33
+ https://github.com/adafruit/circuitpython/releases
34
+
35
+ """
18
36
19
37
import displayio
20
38
from adafruit_display_shapes .line import Line
21
39
22
40
23
41
class Sparkline (displayio .Group ):
24
- # pylint: disable=invalid-name
42
+ # pylint: disable=invalid-name, too-many-arguments
25
43
""" A sparkline graph.
26
44
27
45
: param width: Width of the sparkline graph in pixels
@@ -54,8 +72,12 @@ def __init__(
54
72
self ._spark_list = [] # list containing the values
55
73
self .yMin = yMin # minimum of y-axis (None: autoscale)
56
74
self .yMax = yMax # maximum of y-axis (None: autoscale)
57
- self .yBottom = yMin # yBottom: The actual minimum value of the vertical scale, will be updated if autorange
58
- self .yTop = yMax # yTop: The actual minimum value of the vertical scale, will be updated if autorange
75
+ self .yBottom = yMin
76
+ # yBottom: The actual minimum value of the vertical scale, will be
77
+ # updated if autorange
78
+ self .yTop = yMax
79
+ # yTop: The actual minimum value of the vertical scale, will be
80
+ # updated if autorange
59
81
self ._x = x
60
82
self ._y = y
61
83
@@ -65,7 +87,6 @@ def __init__(
65
87
66
88
def add_value (self , value ):
67
89
""" Add a value to the sparkline.
68
-
69
90
: param value: The value to be added to the sparkline
70
91
"""
71
92
@@ -121,7 +142,7 @@ def update(self):
121
142
len (self ._spark_list ) - 1
122
143
) # this is a float, only make int when plotting the line
123
144
124
- for i in range (len (self )): # remove all items from the current group
145
+ for _ in range (len (self )): # remove all items from the current group
125
146
self .pop ()
126
147
127
148
for count , value in enumerate (self ._spark_list ):
@@ -192,4 +213,7 @@ def update(self):
192
213
last_value = value # store value for the next iteration
193
214
194
215
def values (self ):
216
+ """Returns the values displayed on the sparkline
217
+ """
218
+
195
219
return self ._spark_list
0 commit comments