优化内存泄露的问题
This commit is contained in:
@@ -16,10 +16,11 @@ class AreaChart {
|
||||
this.dpr = window.devicePixelRatio || 1;
|
||||
this.padding = { top: 20, right: 16, bottom: 32, left: 56 };
|
||||
|
||||
this.currentMaxVal = 0;
|
||||
this.prevMaxVal = 0;
|
||||
this.currentMaxVal = 0;
|
||||
|
||||
this._resize = this.resize.bind(this);
|
||||
// Use debounced resize for performance and safety
|
||||
this._resize = typeof debounce === 'function' ? debounce(this.resize.bind(this), 100) : this.resize.bind(this);
|
||||
window.addEventListener('resize', this._resize);
|
||||
this.resize();
|
||||
}
|
||||
@@ -335,7 +336,8 @@ class MetricChart {
|
||||
this.prevMaxVal = 0;
|
||||
this.currentMaxVal = 0;
|
||||
|
||||
this._resize = this.resize.bind(this);
|
||||
// Use debounced resize for performance and safety
|
||||
this._resize = typeof debounce === 'function' ? debounce(this.resize.bind(this), 100) : this.resize.bind(this);
|
||||
window.addEventListener('resize', this._resize);
|
||||
this.resize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user