From 6b50de5e356ebdee7748bdacfe7aca4c361b8b1f Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Sun, 31 Dec 2023 18:41:54 +0100 Subject: [PATCH] Fix opacity calculation on chrome --- nummi/history/templates/history/plot.html | 3 +-- nummi/main/templatetags/main_extras.py | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nummi/history/templates/history/plot.html b/nummi/history/templates/history/plot.html index 1f0d858..399bc4e 100644 --- a/nummi/history/templates/history/plot.html +++ b/nummi/history/templates/history/plot.html @@ -102,8 +102,7 @@ {% endif %} {% if m %} - + style="opacity: {% opacity m.sum history.years_max %}"> {% else %} {% endif %} diff --git a/nummi/main/templatetags/main_extras.py b/nummi/main/templatetags/main_extras.py index a85d8db..670bda9 100644 --- a/nummi/main/templatetags/main_extras.py +++ b/nummi/main/templatetags/main_extras.py @@ -1,3 +1,5 @@ +import math + from django import template from django.templatetags.static import static from django.utils import formats @@ -67,3 +69,8 @@ def css(href): return mark_safe( f"""""" ) + + +@register.simple_tag +def opacity(v, vmax): + return f"{math.sin(math.fabs(v/vmax)*math.pi/2):.2f}"