{% extends 'base.html' %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="container-xl">
|
|
|
|
<h1 class="app-page-title">Comparativa de gastos</h1>
|
|
|
|
<div class="app-card app-card-notification shadow-sm mb-4">
|
|
<div style="width: 50%; margin: 0 auto;">
|
|
<canvas id="gastosGrafico"></canvas>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
const etiquetas = JSON.parse('{{ etiquetas_json|escapejs }}');
|
|
const datosGastos = JSON.parse('{{ gastos_datos_json|escapejs }}');
|
|
|
|
const ctx = document.getElementById('gastosGrafico').getContext('2d');
|
|
|
|
const gastosGrafico = new Chart(ctx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: etiquetas,
|
|
datasets: [{
|
|
label: 'Gastos',
|
|
data: datosGastos,
|
|
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
|
borderColor: 'rgba(75, 192, 192, 1)',
|
|
borderWidth: 1
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
</div>
|
|
</div>
|
|
|
|
{% endblock %}
|