feat: 定投

This commit is contained in:
hzm
2026-02-25 22:33:06 +08:00
parent 5f12e9d900
commit f5edd7bbf8
12 changed files with 869 additions and 143 deletions

View File

@@ -311,7 +311,15 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans
const textW = ctx.measureText(text).width;
const w = textW + paddingH * 2;
const h = 18;
const left = x - w / 2;
// 计算原始 left并对左右边界做收缩避免在最右/最左侧被裁剪
const chartLeft = chart.scales.x.left;
const chartRight = chart.scales.x.right;
let left = x - w / 2;
if (left < chartLeft) left = chartLeft;
if (left + w > chartRight) left = chartRight - w;
const centerX = left + w / 2;
const top = y - 24;
drawRoundRect(left, top, w, h, radius);
@@ -323,7 +331,7 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans
ctx.fillStyle = textColor;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(text, x, top + h / 2);
ctx.fillText(text, centerX, top + h / 2);
ctx.restore();
};