luci-mod-status: fix NaN errors in realtime graphs
authorLukasz Baj <[email protected]>
Fri, 16 Apr 2021 17:36:43 +0000 (19:36 +0200)
committerJo-Philipp Wich <[email protected]>
Wed, 9 Jun 2021 09:08:36 +0000 (11:08 +0200)
When I use Realtime Graphs I see following NaN errors:

    Error: <polyline> attribute points: Expected number, "0,298 0,NaN 5,NaN 10,NaN…".
    Error: <polyline> attribute points: Expected number, "0,298 0,NaN 5,NaN 10,NaN…".
    wireless.js?v=git-21.105.40538-2da37c2:19 Error: <polyline> attribute points: Expected number, "0,298 0,NaN 5,NaN 10,NaN…".
    eval @ wireless.js?v=git-21.105.40538-2da37c2:19
    Promise.then (async)
    eval @ wireless.js?v=git-21.105.40538-2da37c2:8
    step @ luci.js?v=git-21.105.40538-2da37c2:91
    start @ luci.js?v=git-21.105.40538-2da37c2:87
    add @ luci.js?v=git-21.105.40538-2da37c2:82
    pollData @ wireless.js?v=git-21.105.40538-2da37c2:7
    render @ wireless.js?v=git-21.105.40538-2da37c2:24
    Promise.then (async)
    __init__ @ luci.js?v=git-21.105.40538-2da37c2:148
    super @ luci.js?v=git-21.105.40538-2da37c2:22
    Anonymous42Class @ luci.js?v=git-21.105.40538-2da37c2:12
    (anonymous) @ luci.js?v=git-21.105.40538-2da37c2:181
    Promise.then (async)
    compileClass @ luci.js?v=git-21.105.40538-2da37c2:177
    Promise.then (async)
    require @ luci.js?v=git-21.105.40538-2da37c2:183
    instantiateView @ ui.js?v=git-21.105.40538-2da37c2:311
    (anonymous) @ wireless:47
    Promise.then (async)
    (anonymous) @ wireless:46

Signed-off-by: Lukasz Baj <[email protected]>
[adjust subject]
Signed-off-by: Jo-Philipp Wich <[email protected]>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/bandwidth.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/connections.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/load.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/wireless.js

index cb7cf8c23d91afaf69ce6d1cd4b9c6c6aa466137..0fbe49c12cd7d87cbd19516f1a6f906e95c4269f 100644 (file)
@@ -209,6 +209,8 @@ return view.extend({
                                                        y = ctx.height - Math.floor(values[i][j] * data_scale);
                                                        //y -= Math.floor(y % (1 / data_scale));
 
+                                                       y = isNaN(y) ? ctx.height : y;
+
                                                        pt += ' ' + x + ',' + y;
                                                }
 
index a87fe53fed9b82d9a576a5f77d1ec6ec9a00f8ea..168bfefdf8673d7c6cf5f585588e45999538a947 100644 (file)
@@ -281,6 +281,8 @@ return view.extend({
                                                        y = ctx.height - Math.floor(values[i][j] * data_scale);
                                                        //y -= Math.floor(y % (1 / data_scale));
 
+                                                       y = isNaN(y) ? ctx.height : y;
+
                                                        pt += ' ' + x + ',' + y;
                                                }
 
index 2766f5d1b5d9128eb46b8a733816d1b28fbb0099..633e43e6c32abc5a8a145faa1347c61f4a05fe3b 100644 (file)
@@ -186,6 +186,8 @@ return view.extend({
                                                        y = ctx.height - Math.floor(values[i][j] * data_scale);
                                                        //y -= Math.floor(y % (1 / data_scale));
 
+                                                       y = isNaN(y) ? ctx.height : y;
+
                                                        pt += ' ' + x + ',' + y;
                                                }
 
index 0fdd3d56e7151ed8bc00366855fd6d29320a662b..8848143c98b53e7bf59082027bdb25976ddffd08 100644 (file)
@@ -202,6 +202,8 @@ return view.extend({
                                                        y = ctx.height - Math.floor(values[i][j] * data_scale);
                                                        //y -= Math.floor(y % (1 / data_scale));
 
+                                                       y = isNaN(y) ? ctx.height : y;
+
                                                        pt += ' ' + x + ',' + y;
                                                }