From 2ffe276304907601a56ecfb8d4520a503a082c1c Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 21 Feb 2021 21:03:34 +0100 Subject: [PATCH] Make prettier --- mood/statistics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mood/statistics.py b/mood/statistics.py index 6f2b442..ea719d1 100644 --- a/mood/statistics.py +++ b/mood/statistics.py @@ -6,7 +6,7 @@ from django.utils import timezone from bokeh.models import HoverTool from dateutil.relativedelta import relativedelta -from .models import Status +from .models import Status, Mood def moodstats(user, mindate=None, maxdate=None, days=7): hv.extension('bokeh') @@ -27,6 +27,7 @@ def moodstats(user, mindate=None, maxdate=None, days=7): pointdict = {"date": [], "value": [], "color": []} + for status in Status.objects.filter(user=user, timestamp__gte=mindate, timestamp__lte=maxdate): if status.mood: pointdict["date"].append(status.timestamp) @@ -47,8 +48,10 @@ def moodstats(user, mindate=None, maxdate=None, days=7): line = hv.Curve(pointtuples) + maxy = Mood.objects.filter(user=user).latest("value").value + 1 + output = points * line - output.opts(tools=["xwheel_zoom"], ylim=(0, 5)) + output.opts(tools=["xwheel_zoom"], ylim=(0, maxy)) return output