From 048bd8db57800a7afb307ba63c2fb5c3b554788b Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Tue, 24 Feb 2026 23:03:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE2=E7=A7=92=E5=90=8E=E8=87=AA=E5=8A=A8=E5=A4=B1?= =?UTF-8?q?=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/FundTrendChart.jsx | 41 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/app/components/FundTrendChart.jsx b/app/components/FundTrendChart.jsx index 56acd9d..2cefd7c 100644 --- a/app/components/FundTrendChart.jsx +++ b/app/components/FundTrendChart.jsx @@ -238,25 +238,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans // 仅用于桌面端 hover 改变光标,不在这里做 2 秒清除,避免移动端 hover 事件不稳定 }, - onClick: (_event, _elements, chart) => { - const currentChart = chart || chartRef.current; - if (!currentChart) return; - - if (hoverTimeoutRef.current) { - clearTimeout(hoverTimeoutRef.current); - hoverTimeoutRef.current = null; - } - - hoverTimeoutRef.current = setTimeout(() => { - const c = chartRef.current || currentChart; - if (!c) return; - c.setActiveElements([]); - if (c.tooltip) { - c.tooltip.setActiveElements([], { x: 0, y: 0 }); - } - c.update(); - }, 2000); - } + onClick: () => {} }; }, []); @@ -270,6 +252,27 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans const plugins = useMemo(() => [{ id: 'crosshair', + afterEvent: (chart, args) => { + const { event, replay } = args || {}; + if (!event || replay) return; // 忽略动画重放 + + const type = event.type; + if (type === 'mousemove' || type === 'click') { + if (hoverTimeoutRef.current) { + clearTimeout(hoverTimeoutRef.current); + hoverTimeoutRef.current = null; + } + + hoverTimeoutRef.current = setTimeout(() => { + if (!chart) return; + chart.setActiveElements([]); + if (chart.tooltip) { + chart.tooltip.setActiveElements([], { x: 0, y: 0 }); + } + chart.update(); + }, 2000); + } + }, afterDraw: (chart) => { const ctx = chart.ctx; const datasets = chart.data.datasets;