diff options
| author | Benedict Börger <benedict@0xb8000.de> | 2019-06-22 23:56:25 +0200 |
|---|---|---|
| committer | Benedict Börger <benedict@0xb8000.de> | 2019-06-22 23:56:25 +0200 |
| commit | b7a7d1d9512357bb2309fff50afaebd4082f9dd8 (patch) | |
| tree | 69d61fa4142a5ba263743b058b90928e7d3134e9 /templates | |
| parent | eef5efc67b9f0b2eeede9a6d89d2de796634acb7 (diff) | |
[web_frontend][chart] link chart to transactions
when a category in the pie chart is selected load the corresponding transaction
site with the right filter set.
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/chart.html.tera | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/templates/chart.html.tera b/templates/chart.html.tera index 50adbef..acded96 100644 --- a/templates/chart.html.tera +++ b/templates/chart.html.tera @@ -14,7 +14,7 @@ var data = google.visualization.arrayToDataTable([ ['Money spent', 'EUR'], {% for name, value in groups %} - ['{{ name }}', {{ value }}], + ['{{ name }}', {{ value.amount }}], {% endfor %} ]); @@ -26,6 +26,19 @@ var chart = new google.visualization.PieChart(document.getElementById('donutchart')); chart.draw(data, options); + google.visualization.events.addListener(chart, 'select', selectHandler); + + function selectHandler(e) { + var link_data = [ + {% for name, value in groups %} + ['{{ name }}', '{{ value.filter }}' ], + {% endfor %} + ] + var filter = link_data[chart.getSelection()[0].row][1]; + window.location = "http://localhost:8000/transactions/{{ account_name}}?filter=" + filter + "&start={{ date_start}}&end={{ date_end }}" + + } + } </script> <title>Graphic Overview for account {{ account_name }}</title> @@ -82,7 +95,7 @@ %) present in chart </h5> <!-- stack coln charts to compare months --> - <div id="donutchart" style="margin: auto; width: 100%; height: 500px;"></div> + <div id="donutchart" style="margin: auto; width: 100%; height: 700px;"></div> </div> <script src="/static/jquery.min.js"></script> |
