From 8846fafc66911fc7911c6f70664af3147b951113 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Tue, 17 Feb 2026 21:40:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E5=9B=BEy=E8=BD=B4=E4=B8=BA=E7=99=BE=E5=88=86=E6=AF=94?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/FundTrendChart.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/components/FundTrendChart.jsx b/app/components/FundTrendChart.jsx index ca82ab7..88465bc 100644 --- a/app/components/FundTrendChart.jsx +++ b/app/components/FundTrendChart.jsx @@ -89,12 +89,16 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand }) { const lineColor = change >= 0 ? upColor : downColor; const chartData = useMemo(() => { + // Calculate percentage change based on the first data point + const firstValue = data.length > 0 ? data[0].value : 1; + const percentageData = data.map(d => ((d.value - firstValue) / firstValue) * 100); + return { labels: data.map(d => d.date), datasets: [ { - label: '单位净值', - data: data.map(d => d.value), + label: '涨跌幅', + data: percentageData, borderColor: lineColor, backgroundColor: (context) => { const ctx = context.chart.ctx; @@ -154,7 +158,8 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand }) { ticks: { color: '#9ca3af', font: { size: 10 }, - count: 5 + count: 5, + callback: (value) => `${value.toFixed(2)}%` }, border: { display: false } } @@ -240,7 +245,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand }) { ctx.fillText(dateStr, x, bottomY + 8); // Y axis label (value) - const valueStr = typeof value === 'number' ? value.toFixed(4) : value; + const valueStr = (typeof value === 'number' ? value.toFixed(2) : value) + '%'; const valWidth = ctx.measureText(valueStr).width + 8; ctx.fillStyle = primaryColor; ctx.fillRect(rightX - valWidth, y - 8, valWidth, 16);