1
This commit is contained in:
parent
55202f959b
commit
f8128ff327
@ -1532,7 +1532,8 @@
|
||||
dailyReturns: [],
|
||||
loadingReturns: false,
|
||||
balanceChart: null,
|
||||
returnsChart: null
|
||||
returnsChart: null,
|
||||
_renderingCharts: false // 防止重复渲染标志
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@ -1923,8 +1924,22 @@
|
||||
|
||||
// 渲染图表
|
||||
renderCharts() {
|
||||
this.renderBalanceChart();
|
||||
this.renderReturnsChart();
|
||||
// 防止重复渲染
|
||||
if (this._renderingCharts) {
|
||||
console.log('Charts already rendering, skipping...');
|
||||
return;
|
||||
}
|
||||
this._renderingCharts = true;
|
||||
|
||||
try {
|
||||
this.renderBalanceChart();
|
||||
this.renderReturnsChart();
|
||||
} finally {
|
||||
// 延迟重置标志,确保渲染完成
|
||||
setTimeout(() => {
|
||||
this._renderingCharts = false;
|
||||
}, 200);
|
||||
}
|
||||
},
|
||||
|
||||
// 渲染净值曲线图
|
||||
@ -1935,6 +1950,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查 canvas 是否可见(offsetParent 不为 null 表示元素可见)
|
||||
if (!canvas.offsetParent) {
|
||||
console.warn('balanceChart canvas is not visible');
|
||||
return;
|
||||
}
|
||||
|
||||
// 销毁已存在的图表
|
||||
if (this.balanceChart) {
|
||||
this.balanceChart.destroy();
|
||||
@ -1943,7 +1964,7 @@
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
console.warn('Cannot get 2d context');
|
||||
console.warn('Cannot get 2d context for balanceChart');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2038,6 +2059,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查 canvas 是否可见
|
||||
if (!canvas.offsetParent) {
|
||||
console.warn('returnsChart canvas is not visible');
|
||||
return;
|
||||
}
|
||||
|
||||
// 销毁已存在的图表
|
||||
if (this.returnsChart) {
|
||||
this.returnsChart.destroy();
|
||||
@ -2046,7 +2073,7 @@
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
console.warn('Cannot get 2d context');
|
||||
console.warn('Cannot get 2d context for returnsChart');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user