Make prettier

This commit is contained in:
Kumi 2021-02-21 21:03:34 +01:00
parent bbb062ca0e
commit a19c0a2ad1

View file

@ -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