|
4 | 4 | # See the bottom for a code example using the `sparkline` Class.
|
5 | 5 |
|
6 | 6 | # # File: display_shapes_sparkline.py
|
7 |
| -# A sparkline is a scrolling line graph, where any values added to sparkline |
| 7 | +# A sparkline is a scrolling line graph, where any values added to sparkline |
8 | 8 | # using `add_value` are plotted.
|
9 | 9 | #
|
10 |
| -# The `sparkline` class creates an element suitable for adding to the display |
| 10 | +# The `sparkline` class creates an element suitable for adding to the display |
11 | 11 | # using `display.show(mySparkline)` or adding to a `displayio.Group` to be displayed.
|
12 | 12 | #
|
13 |
| -# When creating the sparkline, identify the number of `max_items` that will be |
| 13 | +# When creating the sparkline, identify the number of `max_items` that will be |
14 | 14 | # included in the graph.
|
15 |
| -# When additional elements are added to the sparkline and the number of items |
16 |
| -# has exceeded max_items, any excess values are removed from the left of the |
| 15 | +# When additional elements are added to the sparkline and the number of items |
| 16 | +# has exceeded max_items, any excess values are removed from the left of the |
17 | 17 | # graph, and new values are added to the right.
|
18 | 18 |
|
19 | 19 |
|
|
78 | 78 | display_bus,
|
79 | 79 | width=DISPLAY_WIDTH,
|
80 | 80 | height=DISPLAY_HEIGHT,
|
81 |
| - rotation=180, # The rotation can be adjusted to match your configuration. |
| 81 | + rotation=180, # The rotation can be adjusted to match your configuration. |
82 | 82 | auto_refresh=True,
|
83 | 83 | native_frames_per_second=90,
|
84 | 84 | )
|
|
127 | 127 |
|
128 | 128 |
|
129 | 129 | # Setup the second bitmap and sparkline
|
130 |
| -# mySparkline2 uses a vertical y range between 0 to 1, and will contain a |
| 130 | +# mySparkline2 uses a vertical y range between 0 to 1, and will contain a |
131 | 131 | # maximum of 10 items
|
132 | 132 | #
|
133 | 133 | palette2 = displayio.Palette(1) # color palette used for bitmap2 (one color)
|
|
151 | 151 |
|
152 | 152 | # Setup the third bitmap and third sparkline
|
153 | 153 | # mySparkline3 contains a maximum of 10 items
|
154 |
| -# since yMin and yMax are not specified, mySparkline3 uses autoranging for both |
| 154 | +# since yMin and yMax are not specified, mySparkline3 uses autoranging for both |
155 | 155 | # the top and bottom of the y-axis.
|
156 |
| -# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based |
| 156 | +# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based |
157 | 157 | # on the data in the list.
|
158 |
| -# Note2: You can read back the value of the y-axis limits by using |
| 158 | +# Note2: You can read back the value of the y-axis limits by using |
159 | 159 | # mySparkline3.yBottom or mySparkline3.yTop
|
160 | 160 |
|
161 | 161 |
|
|
197 | 197 | # Create a group to hold the three bitmap TileGrids and the three sparklines and
|
198 | 198 | # append them into the group (myGroup)
|
199 | 199 | #
|
200 |
| -# Note: In cases where display elements will overlap, then the order the elements |
201 |
| -# are added to the group will set which is on top. Latter elements are displayed |
| 200 | +# Note: In cases where display elements will overlap, then the order the elements |
| 201 | +# are added to the group will set which is on top. Latter elements are displayed |
202 | 202 | # on top of former elemtns.
|
203 | 203 | myGroup = displayio.Group(max_size=20)
|
204 | 204 |
|
|
214 | 214 | myGroup.append(textLabel3a)
|
215 | 215 | myGroup.append(textLabel3b)
|
216 | 216 |
|
217 |
| -# Set the display to show myGroup that contains all the bitmap TileGrids and |
| 217 | +# Set the display to show myGroup that contains all the bitmap TileGrids and |
218 | 218 | # sparklines
|
219 | 219 | display.show(myGroup)
|
220 | 220 |
|
|
235 | 235 | # Note: For mySparkline2, the y-axis range is set from 0 to 1.
|
236 | 236 | # With the random values set between -1 and +2, the values will sometimes
|
237 | 237 | # be out of the y-range. This example shows how the fixed y-range (0 to 1)
|
238 |
| - # will "clip" values (it will not display them) that are above or below the |
| 238 | + # will "clip" values (it will not display them) that are above or below the |
239 | 239 | # y-range.
|
240 | 240 | mySparkline2.add_value(random.uniform(-1, 2))
|
241 | 241 |
|
|
0 commit comments