display details about hovered stats
This commit is contained in:
@@ -148,10 +148,19 @@ tr:hover {
|
|||||||
color: #CC6622;
|
color: #CC6622;
|
||||||
}
|
}
|
||||||
|
|
||||||
#date-panel {
|
#big-stat-panel {
|
||||||
width: 80%;
|
width: 100%;
|
||||||
opacity: 50%;
|
opacity: 50%;
|
||||||
font-size: 1.5em;
|
font-size: 1.4em;
|
||||||
|
height: 1.4em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#small-stat-panel {
|
||||||
|
width: 100%;
|
||||||
|
opacity: 50%;
|
||||||
|
font-size: 0.8em;
|
||||||
|
height: 0.8em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,12 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="main-container flex-col-centering">
|
<div class="main-container flex-col-centering">
|
||||||
{% if daily_stats %}
|
{% if daily_stats %}
|
||||||
<div id="date-panel">-</div>
|
<div id="big-stat-panel"></div>
|
||||||
|
<div id="small-stat-panel"></div>
|
||||||
<div id="graph">
|
<div id="graph">
|
||||||
{% for stat in daily_stats %}
|
{% for stat in daily_stats %}
|
||||||
<div class="graph-bar{% if stat.highlighted %} highlighted{% endif %}"
|
<div class="graph-bar{% if stat.highlighted %} highlighted{% endif %}"
|
||||||
id="graph-bar-{{ stat.id }}"
|
id="graph-bar-{{ stat.id }}">
|
||||||
onmouseover="showGraphBarDate('{{ stat.date|date:"d.m.y" }}')"
|
|
||||||
onmouseleave="clearGraphBarDate()">
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +153,8 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const graph = document.getElementById('graph');
|
const graph = document.getElementById('graph');
|
||||||
const datePanel = document.getElementById('date-panel');
|
const bigStatPanel = document.getElementById('big-stat-panel');
|
||||||
|
const smallStatPanel = document.getElementById('small-stat-panel');
|
||||||
const irrExpCheckbox = document.getElementById('irregular-expenses-checkbox');
|
const irrExpCheckbox = document.getElementById('irregular-expenses-checkbox');
|
||||||
|
|
||||||
{% for stat in daily_stats %}
|
{% for stat in daily_stats %}
|
||||||
@@ -186,14 +186,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showGraphBarDate(dateStr) {
|
|
||||||
datePanel.innerText = dateStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearGraphBarDate() {
|
|
||||||
datePanel.innerText = '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyGraphBarHeights() {
|
function applyGraphBarHeights() {
|
||||||
if (irrExpCheckbox.checked) {
|
if (irrExpCheckbox.checked) {
|
||||||
{% for stat in daily_stats %}
|
{% for stat in daily_stats %}
|
||||||
@@ -212,5 +204,20 @@
|
|||||||
graph.addEventListener('mousemove', (event) => doDragScroll(event));
|
graph.addEventListener('mousemove', (event) => doDragScroll(event));
|
||||||
irrExpCheckbox.addEventListener('change', () => applyGraphBarHeights());
|
irrExpCheckbox.addEventListener('change', () => applyGraphBarHeights());
|
||||||
window.onload = applyGraphBarHeights;
|
window.onload = applyGraphBarHeights;
|
||||||
|
|
||||||
|
{% for stat in daily_stats %}
|
||||||
|
graphBar{{ stat.id }}.addEventListener('mouseover', () => function () {
|
||||||
|
if (irrExpCheckbox.checked) {
|
||||||
|
bigStatPanel.innerText = '{{ stat|stat_header:True }}';
|
||||||
|
} else {
|
||||||
|
bigStatPanel.innerText = '{{ stat|stat_header:False }}';
|
||||||
|
}
|
||||||
|
smallStatPanel.innerText = '{{ stat|stat_details }}';
|
||||||
|
}());
|
||||||
|
graphBar{{ stat.id }}.addEventListener('mouseleave', () => function () {
|
||||||
|
bigStatPanel.innerText = '';
|
||||||
|
smallStatPanel.innerText = '';
|
||||||
|
}());
|
||||||
|
{% endfor %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from django import template
|
from django import template
|
||||||
|
from django.template.defaultfilters import date
|
||||||
|
|
||||||
|
from financeplanner.calc import DailyStat
|
||||||
from financeplanner.utils import format_price
|
from financeplanner.utils import format_price
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@@ -8,3 +10,24 @@ register = template.Library()
|
|||||||
@register.filter(name="euro")
|
@register.filter(name="euro")
|
||||||
def euro(value):
|
def euro(value):
|
||||||
return format_price(value) or "-"
|
return format_price(value) or "-"
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="stat_header")
|
||||||
|
def stat_header(value: DailyStat, irregular):
|
||||||
|
return " | ".join([
|
||||||
|
date(value.date, "d.m.y"),
|
||||||
|
euro(value.resulting_amount_irregular if irregular else value.resulting_amount)
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="stat_details")
|
||||||
|
def stat_details(value: DailyStat):
|
||||||
|
parts = []
|
||||||
|
if value.balance_amount is not None:
|
||||||
|
parts.append(f"Balance: {euro(value.balance_amount)}")
|
||||||
|
for trans in value.actual_transactions:
|
||||||
|
parts.append(f"{trans.subject}: {euro(trans.amount)}")
|
||||||
|
result = " | ".join(parts) or "-"
|
||||||
|
if len(result) > 80:
|
||||||
|
return result[:47] + "..."
|
||||||
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user