From 6b65a0c998d9fadc5820ef5b5d6d1b79858f6b7f Mon Sep 17 00:00:00 2001 From: loganhz Date: Thu, 14 Mar 2019 09:37:08 +0800 Subject: [PATCH] Fix graph oom issue https://github.com/rancher/rancher/issues/18883 --- .../addon/components/graph-area/component.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/shared/addon/components/graph-area/component.js b/lib/shared/addon/components/graph-area/component.js index 5fed4378d..4ff2a3593 100644 --- a/lib/shared/addon/components/graph-area/component.js +++ b/lib/shared/addon/components/graph-area/component.js @@ -105,6 +105,7 @@ export default Component.extend(ThrottledResize, { const chart = get(this, 'chart'); if ( chart ) { + chart.clear(); chart.dispose(); } }, @@ -153,10 +154,10 @@ export default Component.extend(ThrottledResize, { set(this, 'chart', chart); chart.showLoading(LOADING_PARAMS); - this.draw(); + this.draw(false); }, - draw() { + draw(update = true) { const chart = get(this, 'chart'); if ( !chart ) { @@ -247,7 +248,16 @@ export default Component.extend(ThrottledResize, { option.yAxis.max = minMax; } - chart.setOption(option, true); + let newOptions; + + if ( update ) { + newOptions = { series }; + } else { + newOptions = option; + } + + chart.clear(); + chart.setOption(newOptions, true); chart.hideLoading(); },