diff --git a/plugins/sentinel/dashboard.html b/plugins/sentinel/dashboard.html index cea2964..29e4fd5 100644 --- a/plugins/sentinel/dashboard.html +++ b/plugins/sentinel/dashboard.html @@ -321,7 +321,16 @@ } grid.appendChild(card); _cardCache[id] = card; - if (isRow && !_chartInstances[id]) { + if (isRow) { + // 销毁旧图表实例 + if (_chartInstances[id]) { + ['cpu','mem','net'].forEach(function(k){ + if (_chartInstances[id][k] && _chartInstances[id][k].canvas) { + var c = _chartInstances[id][k].canvas; + c.getContext('2d').clearRect(0,0,c.width,c.height); + } + }); + } try { _chartInstances[id] = { cpu: null, mem: null, net: null }; if (typeof MiniChart !== 'undefined') { @@ -331,7 +340,6 @@ _chartInstances[id].net = new DualLineChart(id+'-net', '#bb9af7', '#c0a8f0'); } - } catch(e) {} } } @@ -374,7 +382,6 @@ if (charts.cpu) charts.cpu.update(cpuVal); if (charts.mem) charts.mem.update(memVal); if (charts.net) { charts.net.update(net.rx_bytes_sec||0, net.tx_bytes_sec||0); if (charts.net.maxVal < 102400) charts.net.maxVal = 102400; } - } catch(e) {} } // 更新额外指标 var loadEl = card.querySelector('.load-val');