1
This commit is contained in:
parent
55202f959b
commit
f8128ff327
@ -1532,7 +1532,8 @@
|
|||||||
dailyReturns: [],
|
dailyReturns: [],
|
||||||
loadingReturns: false,
|
loadingReturns: false,
|
||||||
balanceChart: null,
|
balanceChart: null,
|
||||||
returnsChart: null
|
returnsChart: null,
|
||||||
|
_renderingCharts: false // 防止重复渲染标志
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -1923,8 +1924,22 @@
|
|||||||
|
|
||||||
// 渲染图表
|
// 渲染图表
|
||||||
renderCharts() {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查 canvas 是否可见(offsetParent 不为 null 表示元素可见)
|
||||||
|
if (!canvas.offsetParent) {
|
||||||
|
console.warn('balanceChart canvas is not visible');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 销毁已存在的图表
|
// 销毁已存在的图表
|
||||||
if (this.balanceChart) {
|
if (this.balanceChart) {
|
||||||
this.balanceChart.destroy();
|
this.balanceChart.destroy();
|
||||||
@ -1943,7 +1964,7 @@
|
|||||||
|
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
console.warn('Cannot get 2d context');
|
console.warn('Cannot get 2d context for balanceChart');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2038,6 +2059,12 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查 canvas 是否可见
|
||||||
|
if (!canvas.offsetParent) {
|
||||||
|
console.warn('returnsChart canvas is not visible');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 销毁已存在的图表
|
// 销毁已存在的图表
|
||||||
if (this.returnsChart) {
|
if (this.returnsChart) {
|
||||||
this.returnsChart.destroy();
|
this.returnsChart.destroy();
|
||||||
@ -2046,7 +2073,7 @@
|
|||||||
|
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
console.warn('Cannot get 2d context');
|
console.warn('Cannot get 2d context for returnsChart');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user