diff --git a/nummi/history/templates/history/plot.html b/nummi/history/templates/history/plot.html index 6ef6804..bd7c2e6 100644 --- a/nummi/history/templates/history/plot.html +++ b/nummi/history/templates/history/plot.html @@ -2,6 +2,43 @@ {% load history_extras %} {% load transaction_extras %} {% load i18n %} +
+ + + + {% if not year %} + + {% endif %} + {% calendar_head %} + + + + {% regroup history.data by month.year as years_list %} + {% for y, y_data in years_list reversed %} + + {% if not year %} + + {% endif %} + {% for m in y_data %} + {% if forloop.parentloop.last and forloop.first %} + {% empty_calendar_cells_start m.month.month %} + {% endif %} + {% if m %} + + {% else %} + + {% endif %} + {% if forloop.parentloop.first and forloop.last %} + {% empty_calendar_cells_end m.month.month %} + {% endif %} + {% endfor %} + + {% endfor %} + +
{% translate "Year" %}
{% year_url y %}{% up_down_icon m.sum %}
+
@@ -47,40 +84,3 @@
-
- - - - {% if not year %} - - {% endif %} - {% calendar_head %} - - - - {% regroup history.data by month.year as years_list %} - {% for y, y_data in years_list reversed %} - - {% if not year %} - - {% endif %} - {% for m in y_data %} - {% if forloop.parentloop.last and forloop.first %} - {% empty_calendar_cells_start m.month.month %} - {% endif %} - {% if m %} - - {% else %} - - {% endif %} - {% if forloop.parentloop.first and forloop.last %} - {% empty_calendar_cells_end m.month.month %} - {% endif %} - {% endfor %} - - {% endfor %} - -
{% translate "Year" %}
{% year_url y %}{% up_down_icon m.sum %}
-
diff --git a/nummi/history/templatetags/history_extras.py b/nummi/history/templatetags/history_extras.py index eaefea3..7a83898 100644 --- a/nummi/history/templatetags/history_extras.py +++ b/nummi/history/templatetags/history_extras.py @@ -9,7 +9,7 @@ register = template.Library() @register.simple_tag def calendar_opacity(v, vmax): - return f"{math.sin(math.fabs(v/vmax)*math.pi/2):.0%}" + return f"{math.sin(min(1, math.fabs(v/vmax))*math.pi/2):.0%}" @register.simple_tag diff --git a/nummi/history/utils.py b/nummi/history/utils.py index 320c10a..3606959 100644 --- a/nummi/history/utils.py +++ b/nummi/history/utils.py @@ -1,6 +1,6 @@ import datetime -from django.db.models import Max, Min, Q, Sum +from django.db.models import Avg, Q, StdDev, Sum from django.db.models.functions import Abs, TruncMonth @@ -38,10 +38,10 @@ def history(transaction_set): "max": { "pm": max( _history.aggregate( - max=Max("sum_p", default=0), - min=-Min("sum_m", default=0), + max=Avg("sum_p", default=0) + StdDev("sum_p", default=0), + min=Avg("sum_m", default=0) - StdDev("sum_m", default=0), ).values(), ), - "sum": _history.aggregate(max=Max(Abs("sum")))["max"], + "sum": _history.aggregate(max=Avg(Abs("sum")) + StdDev(Abs("sum")))["max"], }, } diff --git a/nummi/main/static/main/css/plot.css b/nummi/main/static/main/css/plot.css index 3ec218b..ecc1fdc 100644 --- a/nummi/main/static/main/css/plot.css +++ b/nummi/main/static/main/css/plot.css @@ -82,7 +82,7 @@ table.full-width col.bar { .calendar { overflow-x: auto; - margin-top: var(--gap); + margin-bottom: var(--gap); font-feature-settings: var(--num); table {