From 107f97eb670520110333fd437408ef4f000f3f55 Mon Sep 17 00:00:00 2001 From: Expand-sys Date: Sun, 6 Jun 2021 13:04:45 +1000 Subject: [PATCH] maybe this is the right way --- index.js | 6 +++--- views/bankf.pug | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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' };