fix: defer startPolling until all NVD3 charts initialized
nv.addGraph uses setTimeout internally, so chart models may not exist yet when the first WebSocket response arrives. Moved startPolling() into the last nv.addGraph callback to guarantee charts are ready before data flows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
3e3f908c9e
commit
7ea16d4677
1 file changed
+4
-3
@@ -99,6 +99,10 @@ function ServerInfoPage(params, container) {
|
||||
d3.select('#chart-players').datum([]).call(playersChart);
|
||||
|
||||
window._playersChart = playersChart;
|
||||
|
||||
// All charts ready — start polling data
|
||||
if (Rcon.isConnected()) startPolling();
|
||||
else { var _c = function () { startPolling(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); }
|
||||
});
|
||||
|
||||
// ---- Data polling ----
|
||||
@@ -183,9 +187,6 @@ function ServerInfoPage(params, container) {
|
||||
pollTimer = setInterval(refresh, 1000);
|
||||
}
|
||||
|
||||
if (Rcon.isConnected()) startPolling();
|
||||
else { var _c = function () { startPolling(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); }
|
||||
|
||||
return function cleanup() {
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
window._perfChart = null;
|
||||
|
||||
Reference in new issue
Block a user