-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from TampereHacklab/transaction_overview_data…
…_api2 BankTransaction aggregatedata for graphs
- Loading branch information
Showing
11 changed files
with
251 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2022-10-22 16:02+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
#: www/static/www/graphs.js:25 | ||
msgid "Deposits" | ||
msgstr "Talletukset" | ||
|
||
#: www/static/www/graphs.js:30 | ||
msgid "Withdrawals" | ||
msgstr "Nostot" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
async function renderTransactionsGraph() { | ||
// for now default to fetching 1 year back | ||
let startDate = new Date(); | ||
startDate.setFullYear(startDate.getFullYear() - 1); | ||
const queryParams = { | ||
date__gte: startDate.toISOString().slice(0, 10), | ||
}; | ||
const searchParams = new URLSearchParams(queryParams); | ||
const response = await fetch("/api/v1/banktransactionaggregate/?" + searchParams.toString()); | ||
const data = await response.json(); | ||
let labels = []; | ||
let deposits = []; | ||
let withdrawals = []; | ||
for (i = 0; i < data.length; i++) { | ||
labels.push(data[i].aggregatedate); | ||
deposits.push(data[i].deposits); | ||
withdrawals.push(data[i].withdrawals); | ||
} | ||
new Chart(document.getElementById("transactions"), { | ||
type: "bar", | ||
data: { | ||
labels: labels, | ||
datasets: [ | ||
{ | ||
label: gettext('Deposits'), | ||
data: deposits, | ||
backgroundColor: "#227D7D" | ||
}, | ||
{ | ||
label: gettext('Withdrawals'), | ||
data: withdrawals, | ||
backgroundColor: "#D13838" | ||
}, | ||
], | ||
}, | ||
options: { | ||
legend: { display: true }, | ||
scales: { | ||
x: { | ||
stacked: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
renderTransactionsGraph(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends "www/base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap4 %} | ||
{% load static %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<h1>{% trans 'Statistics' %}</h1> | ||
|
||
<h2>{% trans 'Transactions' %}</h2> | ||
<canvas | ||
id="transactions" | ||
style="display: block; box-sizing: border-box; height: 400px; width: 800px" | ||
width="800" | ||
height="400" | ||
></canvas> | ||
</div> | ||
|
||
<script src="{% static 'www/chartjs/chart.js' %}"></script> | ||
<script src="{% static 'www/graphs.js' %}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters