diff --git a/src/components/StockChart/KLineChartModal.tsx b/src/components/StockChart/KLineChartModal.tsx index e59c0ca7..15741b7d 100644 --- a/src/components/StockChart/KLineChartModal.tsx +++ b/src/components/StockChart/KLineChartModal.tsx @@ -170,6 +170,21 @@ const KLineChartModal: React.FC = ({ d.close >= d.open ? '#ef5350' : '#26a69a' ); + // 提取事件发生日期(YYYY-MM-DD格式) + let eventDateStr: string | null = null; + if (eventTime) { + try { + const eventDate = new Date(eventTime); + const year = eventDate.getFullYear(); + const month = (eventDate.getMonth() + 1).toString().padStart(2, '0'); + const day = eventDate.getDate().toString().padStart(2, '0'); + eventDateStr = `${year}-${month}-${day}`; + console.log('[KLineChartModal] 事件发生日期:', eventDateStr); + } catch (e) { + console.error('[KLineChartModal] 解析事件日期失败:', e); + } + } + // 图表配置 const option: echarts.EChartsOption = { backgroundColor: '#1a1a1a', @@ -346,6 +361,34 @@ const KLineChartModal: React.FC = ({ borderColor: '#ef5350', borderColor0: '#26a69a', }, + markLine: eventDateStr ? { + silent: false, + symbol: 'none', + label: { + show: true, + position: 'insideEndTop', + formatter: '事件发生', + color: '#ffd700', + fontSize: 12, + fontWeight: 'bold', + backgroundColor: 'rgba(0, 0, 0, 0.7)', + padding: [4, 8], + borderRadius: 4, + }, + lineStyle: { + color: '#ffd700', + width: 2, + type: 'solid', + }, + data: [ + { + xAxis: eventDateStr, + label: { + formatter: '⚡ 事件发生', + }, + }, + ], + } : undefined, }, { name: '成交量', diff --git a/src/components/StockChart/TimelineChartModal.tsx b/src/components/StockChart/TimelineChartModal.tsx index 3cb775d8..329ad5df 100644 --- a/src/components/StockChart/TimelineChartModal.tsx +++ b/src/components/StockChart/TimelineChartModal.tsx @@ -172,6 +172,20 @@ const TimelineChartModal: React.FC = ({ d.price >= basePrice ? '#ef5350' : '#26a69a' ); + // 提取事件发生时间(HH:MM格式) + let eventTimeStr: string | null = null; + if (eventTime) { + try { + const eventDate = new Date(eventTime); + const hours = eventDate.getHours().toString().padStart(2, '0'); + const minutes = eventDate.getMinutes().toString().padStart(2, '0'); + eventTimeStr = `${hours}:${minutes}`; + console.log('[TimelineChartModal] 事件发生时间:', eventTimeStr); + } catch (e) { + console.error('[TimelineChartModal] 解析事件时间失败:', e); + } + } + // 图表配置 const option: echarts.EChartsOption = { backgroundColor: '#1a1a1a', @@ -341,6 +355,34 @@ const TimelineChartModal: React.FC = ({ { offset: 1, color: 'rgba(33, 150, 243, 0.05)' }, ]), }, + markLine: eventTimeStr ? { + silent: false, + symbol: 'none', + label: { + show: true, + position: 'insideEndTop', + formatter: '事件发生', + color: '#ffd700', + fontSize: 12, + fontWeight: 'bold', + backgroundColor: 'rgba(0, 0, 0, 0.7)', + padding: [4, 8], + borderRadius: 4, + }, + lineStyle: { + color: '#ffd700', + width: 2, + type: 'solid', + }, + data: [ + { + xAxis: eventTimeStr, + label: { + formatter: '⚡ 事件发生', + }, + }, + ], + } : undefined, }, { name: '均价',