feat: 定投
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user