diff --git a/expenses_manager/expenses/templates/expenses/dashboard.html b/expenses_manager/expenses/templates/expenses/dashboard.html
index 360bb7b..d0b4cd0 100644
--- a/expenses_manager/expenses/templates/expenses/dashboard.html
+++ b/expenses_manager/expenses/templates/expenses/dashboard.html
@@ -1,47 +1,77 @@
-
Dashboard
-Gastos por categoría
-
- {% for row in by_category %}
- - {{ row.category__name}} → {{row.total}}
- {% empty %}
- - No hay datos
- {% endfor %}
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/expenses_manager/expenses/views.py b/expenses_manager/expenses/views.py
index 75f40f7..e3c7296 100644
--- a/expenses_manager/expenses/views.py
+++ b/expenses_manager/expenses/views.py
@@ -139,8 +139,15 @@ def dashboard(request):
.distinct()
.order_by('year')
)
+ # Month list
months = list(range(1, 13))
+ # Prepare data fot ploting in chart
+ chart_labels = []
+ chart_totals = []
+ for month_data in by_month_display:
+ chart_labels.append(month_data['month'])
+ chart_totals.append(float(month_data['total']))
# Send the data to the dashboard
return render(request, 'expenses/dashboard.html', {
@@ -150,4 +157,6 @@ def dashboard(request):
'months': months,
'selected_year': year,
'selected_month': month,
+ 'chart_labels': chart_labels,
+ 'chart_data': chart_totals
})
\ No newline at end of file