You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.3 KiB

{% 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 %}