事件标记线bug修复
This commit is contained in:
@@ -202,12 +202,27 @@ const MiniTimelineChart = React.memo(function MiniTimelineChart({ stockCode, eve
|
|||||||
return h * 60 + m;
|
return h * 60 + m;
|
||||||
};
|
};
|
||||||
const eventMin = parseMinuteTime(eventMinute);
|
const eventMin = parseMinuteTime(eventMinute);
|
||||||
|
|
||||||
|
// 盘前时间定义:15:00之后(上个交易日收盘后)或09:30之前
|
||||||
|
// 盘中时间:09:30 - 15:00
|
||||||
|
const marketOpenMin = 9 * 60 + 30; // 09:30
|
||||||
|
const marketCloseMin = 15 * 60; // 15:00
|
||||||
|
|
||||||
|
// 判断事件是否在盘前(上个交易日15:00之后 或 当天09:30之前)
|
||||||
|
const isPreMarket = eventMin >= marketCloseMin || eventMin < marketOpenMin;
|
||||||
|
|
||||||
let nearestIdx = 0;
|
let nearestIdx = 0;
|
||||||
|
if (isPreMarket) {
|
||||||
|
// 盘前消息:黄线显示在最左侧(开盘位置)
|
||||||
|
nearestIdx = 0;
|
||||||
|
} else {
|
||||||
|
// 盘中消息:找最接近的时间点
|
||||||
for (let i = 1; i < times.length; i++) {
|
for (let i = 1; i < times.length; i++) {
|
||||||
if (Math.abs(parseMinuteTime(times[i]) - eventMin) < Math.abs(parseMinuteTime(times[nearestIdx]) - eventMin)) {
|
if (Math.abs(parseMinuteTime(times[i]) - eventMin) < Math.abs(parseMinuteTime(times[nearestIdx]) - eventMin)) {
|
||||||
nearestIdx = i;
|
nearestIdx = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
eventMarkLineData.push({
|
eventMarkLineData.push({
|
||||||
xAxis: nearestIdx,
|
xAxis: nearestIdx,
|
||||||
lineStyle: { color: '#FFD700', type: 'solid', width: 1.5 },
|
lineStyle: { color: '#FFD700', type: 'solid', width: 1.5 },
|
||||||
|
|||||||
Reference in New Issue
Block a user