From 6aa49318386f29c76f2a8dd39430c2104b908def Mon Sep 17 00:00:00 2001 From: Viet Pham Date: Fri, 24 Aug 2018 20:57:51 -0700 Subject: [PATCH 1/3] fixed bug where charts stop updating after 60 seconds, bump version to 1.4.1 --- lib/views/chartView.js | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/views/chartView.js b/lib/views/chartView.js index 1ae9dda..4b05667 100644 --- a/lib/views/chartView.js +++ b/lib/views/chartView.js @@ -48,6 +48,8 @@ module.exports = function (screen, chart, chartData, table, hashes, refresh) { if (data[0].x.length > 60) { // maximum length data[0].x.shift() data[1].x.shift() + data[0].y.shift() + data[1].y.shift() } data[0].x.unshift('-'+data[0].x.length) data[1].x.unshift('-'+data[1].x.length) diff --git a/package.json b/package.json index 45e8d4b..f5ce3bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utorrent-console", - "version": "1.4.0", + "version": "1.4.1", "description": "Manage your uTorrent from console", "main": "./bin/utorrent-console", "scripts": { From d426c8acfd6ca202a7f009e079ae629f7219fdde Mon Sep 17 00:00:00 2001 From: Viet Pham Date: Fri, 24 Aug 2018 21:24:54 -0700 Subject: [PATCH 2/3] made it a little more efficient, no need to shift and unshift the x array when it hits the max length --- lib/views/chartView.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/views/chartView.js b/lib/views/chartView.js index 4b05667..2d490e2 100644 --- a/lib/views/chartView.js +++ b/lib/views/chartView.js @@ -46,13 +46,12 @@ module.exports = function (screen, chart, chartData, table, hashes, refresh) { data[1].x.unshift('0') } else { //following records if (data[0].x.length > 60) { // maximum length - data[0].x.shift() - data[1].x.shift() data[0].y.shift() data[1].y.shift() - } - data[0].x.unshift('-'+data[0].x.length) - data[1].x.unshift('-'+data[1].x.length) + } else { + data[0].x.unshift('-'+data[0].x.length) + data[1].x.unshift('-'+data[1].x.length) + } } data[0].y.push(currentRecord['downloadspeedBytesSec']/1000) data[1].y.push(currentRecord['uploadspeedBytesSec']/1000) From 2156ac0fe2f8e1b3b5fa08d0abca9d4c86558888 Mon Sep 17 00:00:00 2001 From: Viet Pham Date: Sat, 25 Aug 2018 13:50:21 -0700 Subject: [PATCH 3/3] chart now show graph with 61 points on the x axis so it does not do weird shifting --- lib/views/chartView.js | 17 +++++++++++++---- package.json | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/views/chartView.js b/lib/views/chartView.js index 2d490e2..6650f52 100644 --- a/lib/views/chartView.js +++ b/lib/views/chartView.js @@ -41,9 +41,18 @@ module.exports = function (screen, chart, chartData, table, hashes, refresh) { ] } if (currentRecord) { - if (data[0].x.length == 0) { //first record - data[0].x.unshift('0') - data[1].x.unshift('0') + if (data[0].x.length == 0) { // empty array + for ( var i = 0; i < 61; i++) { // initiate the array + if (data[0].x.length == 0) { + data[0].x.unshift('0') + data[1].x.unshift('0') + } else { + data[0].x.unshift('-'+data[0].x.length) + data[1].x.unshift('-'+data[1].x.length) + } + data[0].y.unshift(0) //inserting blank data to upload and download + data[1].y.unshift(0) + } } else { //following records if (data[0].x.length > 60) { // maximum length data[0].y.shift() @@ -51,7 +60,7 @@ module.exports = function (screen, chart, chartData, table, hashes, refresh) { } else { data[0].x.unshift('-'+data[0].x.length) data[1].x.unshift('-'+data[1].x.length) - } + } } data[0].y.push(currentRecord['downloadspeedBytesSec']/1000) data[1].y.push(currentRecord['uploadspeedBytesSec']/1000) diff --git a/package.json b/package.json index f5ce3bc..c9731c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utorrent-console", - "version": "1.4.1", + "version": "1.4.2", "description": "Manage your uTorrent from console", "main": "./bin/utorrent-console", "scripts": {