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:
@@ -99,6 +99,10 @@ function ServerInfoPage(params, container) {
|
|||||||
d3.select('#chart-players').datum([]).call(playersChart);
|
d3.select('#chart-players').datum([]).call(playersChart);
|
||||||
|
|
||||||
window._playersChart = 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 ----
|
// ---- Data polling ----
|
||||||
@@ -183,9 +187,6 @@ function ServerInfoPage(params, container) {
|
|||||||
pollTimer = setInterval(refresh, 1000);
|
pollTimer = setInterval(refresh, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Rcon.isConnected()) startPolling();
|
|
||||||
else { var _c = function () { startPolling(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); }
|
|
||||||
|
|
||||||
return function cleanup() {
|
return function cleanup() {
|
||||||
if (pollTimer) clearInterval(pollTimer);
|
if (pollTimer) clearInterval(pollTimer);
|
||||||
window._perfChart = null;
|
window._perfChart = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user