From d751daeb74cf581425f346c4fea65c26aee92f99 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Thu, 19 Mar 2026 22:52:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=9A=E7=BB=A9?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E5=AF=B9=E6=AF=94=E7=BA=BF=E7=9A=84=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/FundTrendChart.jsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/components/FundTrendChart.jsx b/app/components/FundTrendChart.jsx index 9941353..66f94d7 100644 --- a/app/components/FundTrendChart.jsx +++ b/app/components/FundTrendChart.jsx @@ -230,7 +230,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans tension: 0.2, order: 2 }, - ...grandDatasets, + ...(['1y', '3y', 'all'].includes(range) ? [] : grandDatasets), { type: 'line', // Use line type with showLine: false to simulate scatter on Category scale label: '买入', @@ -261,7 +261,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans } ] }; - }, [data, transactions, lineColor, primaryColor, upColor, chartColors, theme, hiddenGrandSeries, percentageData]); + }, [data, transactions, lineColor, primaryColor, upColor, chartColors, theme, hiddenGrandSeries, percentageData, range]); const options = useMemo(() => { const colors = getChartThemeColors(theme); @@ -615,6 +615,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans )} {Array.isArray(data.grandTotalSeries) && + !['1y', '3y', 'all'].includes(range) && data.grandTotalSeries .filter((_, idx) => idx > 0) .map((series, displayIdx) => { @@ -646,7 +647,22 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans } } - const rawPoint = pointsByDate.get(targetDate); + // 注意:Data_grandTotal 某些对比线可能不包含区间最后一天的点。 + // 旧逻辑是对 `targetDate` 做严格匹配,缺点就会得到 `--`。 + // 新逻辑:找不到精确日期时,回退到该对比线在区间内最近的可用日期。 + let rawPoint = pointsByDate.get(targetDate); + if ((rawPoint === undefined || rawPoint === null) && baseValue != null) { + for (let i = currentIndex; i >= 0; i--) { + const d = data[i]; + if (!d) continue; + const v = pointsByDate.get(d.date); + if (typeof v === 'number' && Number.isFinite(v)) { + rawPoint = v; + break; + } + } + } + if (baseValue != null && typeof rawPoint === 'number' && Number.isFinite(rawPoint)) { const normalized = rawPoint - baseValue; valueText = `${normalized.toFixed(2)}%`;