Make prettier

This commit is contained in:
Kumi 2021-02-21 21:03:34 +01:00
parent c2e384cf7a
commit 2ffe276304

View file

@ -6,7 +6,7 @@ from django.utils import timezone
from bokeh.models import HoverTool from bokeh.models import HoverTool
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from .models import Status from .models import Status, Mood
def moodstats(user, mindate=None, maxdate=None, days=7): def moodstats(user, mindate=None, maxdate=None, days=7):
hv.extension('bokeh') hv.extension('bokeh')
@ -27,6 +27,7 @@ def moodstats(user, mindate=None, maxdate=None, days=7):
pointdict = {"date": [], "value": [], "color": []} pointdict = {"date": [], "value": [], "color": []}
for status in Status.objects.filter(user=user, timestamp__gte=mindate, timestamp__lte=maxdate): for status in Status.objects.filter(user=user, timestamp__gte=mindate, timestamp__lte=maxdate):
if status.mood: if status.mood:
pointdict["date"].append(status.timestamp) pointdict["date"].append(status.timestamp)
@ -47,8 +48,10 @@ def moodstats(user, mindate=None, maxdate=None, days=7):
line = hv.Curve(pointtuples) line = hv.Curve(pointtuples)
maxy = Mood.objects.filter(user=user).latest("value").value + 1
output = points * line output = points * line
output.opts(tools=["xwheel_zoom"], ylim=(0, 5)) output.opts(tools=["xwheel_zoom"], ylim=(0, maxy))
return output return output