diff --git a/index.js b/index.js index 901e82f..7f569fd 100644 --- a/index.js +++ b/index.js @@ -214,12 +214,12 @@ app.get("/BankF", ensureAuthenticated, async function (req, res) { console.log(graphlog); let graphdata = '["transaction", "balance"]'; let currentbal = balance.value; - for (i in graphlog) { + for (i = graphlog.length - 1; i > -1; i--) { if (graphlog[i].from == req.session.user) { - currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount); + currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount); graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]"; } else { - currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount); + currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount); graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]"; } } diff --git a/views/bankf.pug b/views/bankf.pug index 21058ab..7193023 100644 --- a/views/bankf.pug +++ b/views/bankf.pug @@ -71,7 +71,7 @@ block content var options = { title: 'Balance', - hAxis: {title: 'Transaction', minValue: 0, maxValue: 15, direction: -1, textPosition: 'none'}, + hAxis: {title: 'Transaction', minValue: 0, maxValue: 15, direction: 1, textPosition: 'none'}, vAxis: {title: 'Balance', minValue: 0, maxValue: 500}, legend: 'none' };