Fix opacity calculation on chrome

This commit is contained in:
Edgar P. Burkhart 2023-12-31 18:41:54 +01:00
parent e4e0f56be0
commit 6b50de5e35
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 8 additions and 2 deletions

View file

@ -102,8 +102,7 @@
{% endif %}
{% if m %}
<td class="{% if m.sum > 0 %}p{% else %}m{% endif %}"
style="opacity: calc( sin( abs({% widthratio m.sum history.years_max 100 %}) / 400 * 1turn ) )">
</td>
style="opacity: {% opacity m.sum history.years_max %}"></td>
{% else %}
<td></td>
{% endif %}

View file

@ -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"""<link rel="stylesheet" href="{static(href)}" type="text/css">"""
)
@register.simple_tag
def opacity(v, vmax):
return f"{math.sin(math.fabs(v/vmax)*math.pi/2):.2f}"