Skip to content

updated for pylint #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions adafruit_display_shapes/sparkline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@
# included in the graph. When additional elements are added to the sparkline and
# the number of items has exceeded max_items, any excess values are removed from
# the left of the graph, and new values are added to the right.
"""
`sparkline`
================================================================================

Various common shapes for use with displayio - Sparkline!


* Author(s): Kevin Matocha

Implementation Notes
--------------------

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases

"""

import displayio
from adafruit_display_shapes.line import Line


class Sparkline(displayio.Group):
# pylint: disable=invalid-name
# pylint: disable=invalid-name, too-many-arguments
""" A sparkline graph.

: param width: Width of the sparkline graph in pixels
Expand Down Expand Up @@ -54,8 +72,12 @@ def __init__(
self._spark_list = [] # list containing the values
self.yMin = yMin # minimum of y-axis (None: autoscale)
self.yMax = yMax # maximum of y-axis (None: autoscale)
self.yBottom = yMin # yBottom: The actual minimum value of the vertical scale, will be updated if autorange
self.yTop = yMax # yTop: The actual minimum value of the vertical scale, will be updated if autorange
self.yBottom = yMin
# yBottom: The actual minimum value of the vertical scale, will be
# updated if autorange
self.yTop = yMax
# yTop: The actual minimum value of the vertical scale, will be
# updated if autorange
self._x = x
self._y = y

Expand All @@ -65,7 +87,6 @@ def __init__(

def add_value(self, value):
""" Add a value to the sparkline.

: param value: The value to be added to the sparkline
"""

Expand Down Expand Up @@ -121,7 +142,7 @@ def update(self):
len(self._spark_list) - 1
) # this is a float, only make int when plotting the line

for i in range(len(self)): # remove all items from the current group
for _ in range(len(self)): # remove all items from the current group
self.pop()

for count, value in enumerate(self._spark_list):
Expand Down Expand Up @@ -192,4 +213,7 @@ def update(self):
last_value = value # store value for the next iteration

def values(self):
"""Returns the values displayed on the sparkline
"""

return self._spark_list