修改小周期笔无法显示bug
This commit is contained in:
+31
-13
@@ -3891,19 +3891,37 @@
|
||||
}
|
||||
|
||||
// 添加所有笔到图表
|
||||
biLines.forEach(line => {
|
||||
const lineSeries = mainChart.addLineSeries({
|
||||
color: line.color,
|
||||
lineWidth: line.lineWidth,
|
||||
lineStyle: line.lineStyle || 0, // 支持虚线样式
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
});
|
||||
|
||||
lineSeries.setData([
|
||||
{ time: line.startTime, value: line.startPrice },
|
||||
{ time: line.endTime, value: line.endPrice }
|
||||
]);
|
||||
// 1m 等小周期叠加到大周期时,笔数量会非常大;每条笔创建一个 series 会导致主图渲染退化
|
||||
// 这里限制绘制数量,优先保留最新笔,避免把主K线和其他元素“挤没”
|
||||
const MAX_BI_LINE_SERIES = 800;
|
||||
if (biLines.length > MAX_BI_LINE_SERIES) {
|
||||
console.warn(`BI线条过多(${biLines.length}),仅绘制最新 ${MAX_BI_LINE_SERIES} 条以保障主图稳定`);
|
||||
}
|
||||
const linesToDraw = biLines.length > MAX_BI_LINE_SERIES
|
||||
? biLines.slice(-MAX_BI_LINE_SERIES)
|
||||
: biLines;
|
||||
|
||||
linesToDraw.forEach(line => {
|
||||
try {
|
||||
if (!Number.isFinite(line.startTime) || !Number.isFinite(line.endTime)) return;
|
||||
if (!Number.isFinite(line.startPrice) || !Number.isFinite(line.endPrice)) return;
|
||||
if (line.endTime <= line.startTime) return;
|
||||
|
||||
const lineSeries = mainChart.addLineSeries({
|
||||
color: line.color,
|
||||
lineWidth: line.lineWidth,
|
||||
lineStyle: line.lineStyle || 0, // 支持虚线样式
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
});
|
||||
|
||||
lineSeries.setData([
|
||||
{ time: line.startTime, value: line.startPrice },
|
||||
{ time: line.endTime, value: line.endPrice }
|
||||
]);
|
||||
} catch (e) {
|
||||
console.warn('绘制BI线段失败,已跳过单条异常数据:', e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('绘制笔 - 已禁用');
|
||||
|
||||
Reference in New Issue
Block a user