]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Fix type errors when drawing bar graph
authorMichal Sojka <coffee@rtime.felk.cvut.cz>
Tue, 7 Aug 2018 13:03:09 +0000 (15:03 +0200)
committerMichal Sojka <coffee@rtime.felk.cvut.cz>
Tue, 7 Aug 2018 13:03:09 +0000 (15:03 +0200)
DB returns strings as day numbers, but matplotlib seems to want integers.

app.py

diff --git a/app.py b/app.py
index 5f6552d64bf7a4db52d8ed7ee64b27de8764efb5..f5a247e08f8e9997399fe9472a41a6f0ab60f33e 100644 (file)
--- a/app.py
+++ b/app.py
@@ -90,7 +90,7 @@ def coffee_graph_history():
         days, counts = zip(*hist)
     fig = plt.figure()
     ax = fig.add_subplot(111)
-    ax.bar(days, counts)
+    ax.bar(range(len(days)), counts)
     ax.set_title("Your week")
     fig.savefig(b, format="svg", bbox_inches="tight")
     b.seek(0)