refactor: translate networth page title

This commit is contained in:
Herculino Trotta
2024-10-14 13:22:40 -03:00
parent 75b78bd2fa
commit 8a61946c16
+98 -97
View File
@@ -6,7 +6,7 @@
{% load static %} {% load static %}
{% load webpack_loader %} {% load webpack_loader %}
{% block title %}Net Worth{% endblock %} {% block title %}{% translate 'Net Worth' %}{% endblock %}
{% block content %} {% block content %}
<div class="container px-md-3 py-3 column-gap-5"> <div class="container px-md-3 py-3 column-gap-5">
@@ -92,111 +92,112 @@
</div> </div>
</div> </div>
<script> <script>
var chartData = JSON.parse('{{ chart_data_currency_json|safe }}'); var chartData = JSON.parse('{{ chart_data_currency_json|safe }}');
var currencies = {{ currencies|safe }}; var currencies = {{ currencies|safe }};
var ctx = document.getElementById('currencyBalanceChart').getContext('2d'); var ctx = document.getElementById('currencyBalanceChart').getContext('2d');
new Chart(ctx, { new Chart(ctx, {
type: 'line', type: 'line',
data: chartData, data: chartData,
options: { options: {
responsive: true, responsive: true,
interaction: { interaction: {
mode: 'index', mode: 'index',
intersect: false, intersect: false,
},
plugins: {
title: {
display: true,
text: '{% translate 'Evolution by currency' %}'
}, },
plugins: { tooltip: {
mode: 'index',
intersect: false
}
},
scales: {
x: {
display: true,
title: { title: {
display: true, display: false,
text: '{% translate 'Evolution by currency' %}'
},
tooltip: {
mode: 'index',
intersect: false
} }
}, },
scales: { ...Object.fromEntries(currencies.map((currency, i) => [
x: { `y${i}`,
{
beginAtZero: true,
type: 'linear',
display: true, display: true,
title: { grid: {
display: false, drawOnChartArea: i === 0,
},
ticks: {
display: false
},
border: {
display: false
} }
}, }
...Object.fromEntries(currencies.map((currency, i) => [ ]))
`y${i}`,
{
beginAtZero: true,
type: 'linear',
display: true,
grid: {
drawOnChartArea: i === 0,
},
ticks: {
display: false
},
border: {
display: false
}
}
]))
}
} }
}); }
</script> });
</script>
<script> <script>
var chartData = JSON.parse('{{ chart_data_accounts_json|safe }}'); var chartData = JSON.parse('{{ chart_data_accounts_json|safe }}');
var accounts = {{ accounts|safe }}; var accounts = {{ accounts|safe }};
var ctx = document.getElementById('accountBalanceChart').getContext('2d'); var ctx = document.getElementById('accountBalanceChart').getContext('2d');
new Chart(ctx, { new Chart(ctx, {
type: 'line', type: 'line',
data: chartData, data: chartData,
options: { options: {
responsive: true, responsive: true,
interaction: { interaction: {
mode: 'index', mode: 'index',
intersect: false, intersect: false,
}, },
stacked: false, stacked: false,
plugins: { plugins: {
title: { title: {
display: true, display: true,
text: '{% translate "Evolution by account" %}' text: '{% translate "Evolution by account" %}'
}, },
tooltip: { tooltip: {
mode: 'index', mode: 'index',
intersect: false intersect: false
} }
}, },
scales: { scales: {
x: { x: {
display: true, display: true,
title: { title: {
display: false, display: false,
} }
}, },
...Object.fromEntries(accounts.map((account, i) => [ ...Object.fromEntries(accounts.map((account, i) => [
`y-axis-${i}`, `y-axis-${i}`,
{ {
type: 'linear', beginAtZero: true,
display: true, type: 'linear',
position: i % 2 === 0 ? 'left' : 'right', display: true,
grid: { position: i % 2 === 0 ? 'left' : 'right',
drawOnChartArea: i === 0, grid: {
}, drawOnChartArea: i === 0,
ticks: { },
display: false ticks: {
}, display: false
border: { },
display: false border: {
} display: false
} }
])) }
} ]))
} }
}); }
</script> });
</script>
{% endblock %} {% endblock %}