fix: 折线图最右侧x轴展示问题
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" standalone="no"?>
|
<?xml version="1.0" standalone="no"?>
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1770335913293" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1562" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1770335913293" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1562" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
|
||||||
<path d="M512 85.333333C276.266667 85.333333 85.333333 276.266667 85.333333 512a426.410667 426.410667 0 0 0 291.754667 404.821333c21.333333 3.712 29.312-9.088 29.312-20.309333 0-10.112-0.554667-43.690667-0.554667-79.445333-107.178667 19.754667-134.912-26.112-143.445333-50.133334-4.821333-12.288-25.6-50.133333-43.733333-60.288-14.933333-7.978667-36.266667-27.733333-0.554667-28.245333 33.621333-0.554667 57.6 30.933333 65.621333 43.733333 38.4 64.512 99.754667 46.378667 124.245334 35.2 3.754667-27.733333 14.933333-46.378667 27.221333-57.045333-94.933333-10.666667-194.133333-47.488-194.133333-210.688 0-46.421333 16.512-84.778667 43.733333-114.688-4.266667-10.666667-19.2-54.4 4.266667-113.066667 0 0 35.712-11.178667 117.333333 43.776a395.946667 395.946667 0 0 1 106.666667-14.421333c36.266667 0 72.533333 4.778667 106.666666 14.378667 81.578667-55.466667 117.333333-43.690667 117.333334-43.690667 23.466667 58.666667 8.533333 102.4 4.266666 113.066667 27.178667 29.866667 43.733333 67.712 43.733334 114.645333 0 163.754667-99.712 200.021333-194.645334 210.688 15.445333 13.312 28.8 38.912 28.8 78.933333 0 57.045333-0.554667 102.912-0.554666 117.333334 0 11.178667 8.021333 24.490667 29.354666 20.224A427.349333 427.349333 0 0 0 938.666667 512c0-235.733333-190.933333-426.666667-426.666667-426.666667z" fill="#000000" p-id="1563"></path>
|
<path d="M512 85.333333C276.266667 85.333333 85.333333 276.266667 85.333333 512a426.410667 426.410667 0 0 0 291.754667 404.821333c21.333333 3.712 29.312-9.088 29.312-20.309333 0-10.112-0.554667-43.690667-0.554667-79.445333-107.178667 19.754667-134.912-26.112-143.445333-50.133334-4.821333-12.288-25.6-50.133333-43.733333-60.288-14.933333-7.978667-36.266667-27.733333-0.554667-28.245333 33.621333-0.554667 57.6 30.933333 65.621333 43.733333 38.4 64.512 99.754667 46.378667 124.245334 35.2 3.754667-27.733333 14.933333-46.378667 27.221333-57.045333-94.933333-10.666667-194.133333-47.488-194.133333-210.688 0-46.421333 16.512-84.778667 43.733333-114.688-4.266667-10.666667-19.2-54.4 4.266667-113.066667 0 0 35.712-11.178667 117.333333 43.776a395.946667 395.946667 0 0 1 106.666667-14.421333c36.266667 0 72.533333 4.778667 106.666666 14.378667 81.578667-55.466667 117.333333-43.690667 117.333334-43.690667 23.466667 58.666667 8.533333 102.4 4.266666 113.066667 27.178667 29.866667 43.733333 67.712 43.733334 114.645333 0 163.754667-99.712 200.021333-194.645334 210.688 15.445333 13.312 28.8 38.912 28.8 78.933333 0 57.045333-0.554667 102.912-0.554666 117.333334 0 11.178667 8.021333 24.490667 29.354666 20.224A427.349333 427.349333 0 0 0 938.666667 512c0-235.733333-190.933333-426.666667-426.666667-426.666667z" fill="#ffffff" p-id="1563"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -193,10 +193,16 @@ export default function FundIntradayChart({ series = [], referenceNav }) {
|
|||||||
if (labels && index in labels) {
|
if (labels && index in labels) {
|
||||||
const timeStr = String(labels[index]);
|
const timeStr = String(labels[index]);
|
||||||
const tw = ctx.measureText(timeStr).width + 8;
|
const tw = ctx.measureText(timeStr).width + 8;
|
||||||
|
const chartLeft = chart.scales.x.left;
|
||||||
|
const chartRight = chart.scales.x.right;
|
||||||
|
let labelLeft = x - tw / 2;
|
||||||
|
if (labelLeft < chartLeft) labelLeft = chartLeft;
|
||||||
|
if (labelLeft + tw > chartRight) labelLeft = chartRight - tw;
|
||||||
|
const labelCenterX = labelLeft + tw / 2;
|
||||||
ctx.fillStyle = prim;
|
ctx.fillStyle = prim;
|
||||||
ctx.fillRect(x - tw / 2, bottomY, tw, 16);
|
ctx.fillRect(labelLeft, bottomY, tw, 16);
|
||||||
ctx.fillStyle = bgText;
|
ctx.fillStyle = bgText;
|
||||||
ctx.fillText(timeStr, x, bottomY + 8);
|
ctx.fillText(timeStr, labelCenterX, bottomY + 8);
|
||||||
}
|
}
|
||||||
if (data && index in data) {
|
if (data && index in data) {
|
||||||
const val = data[index];
|
const val = data[index];
|
||||||
|
|||||||
@@ -397,12 +397,18 @@ export default function FundTrendChart({ code, isExpanded, onToggleExpand, trans
|
|||||||
const value = datasets[datasetIndex].data[index];
|
const value = datasets[datasetIndex].data[index];
|
||||||
|
|
||||||
if (dateStr !== undefined && value !== undefined) {
|
if (dateStr !== undefined && value !== undefined) {
|
||||||
// X axis label (date)
|
// X axis label (date) with boundary clamping
|
||||||
const textWidth = ctx.measureText(dateStr).width + 8;
|
const textWidth = ctx.measureText(dateStr).width + 8;
|
||||||
|
const chartLeft = chart.scales.x.left;
|
||||||
|
const chartRight = chart.scales.x.right;
|
||||||
|
let labelLeft = x - textWidth / 2;
|
||||||
|
if (labelLeft < chartLeft) labelLeft = chartLeft;
|
||||||
|
if (labelLeft + textWidth > chartRight) labelLeft = chartRight - textWidth;
|
||||||
|
const labelCenterX = labelLeft + textWidth / 2;
|
||||||
ctx.fillStyle = primaryColor;
|
ctx.fillStyle = primaryColor;
|
||||||
ctx.fillRect(x - textWidth / 2, bottomY, textWidth, 16);
|
ctx.fillRect(labelLeft, bottomY, textWidth, 16);
|
||||||
ctx.fillStyle = '#0f172a'; // --background
|
ctx.fillStyle = '#0f172a'; // --background
|
||||||
ctx.fillText(dateStr, x, bottomY + 8);
|
ctx.fillText(dateStr, labelCenterX, bottomY + 8);
|
||||||
|
|
||||||
// Y axis label (value)
|
// Y axis label (value)
|
||||||
const valueStr = (typeof value === 'number' ? value.toFixed(2) : value) + '%';
|
const valueStr = (typeof value === 'number' ? value.toFixed(2) : value) + '%';
|
||||||
|
|||||||
@@ -1070,10 +1070,10 @@ input[type="number"] {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 2px;
|
padding: 1.5px;
|
||||||
background: conic-gradient(
|
background: conic-gradient(
|
||||||
var(--accent) 0deg,
|
var(--primary) 0deg,
|
||||||
var(--accent) calc(var(--progress) * 360deg),
|
var(--primary) calc(var(--progress) * 360deg),
|
||||||
var(--border) calc(var(--progress) * 360deg)
|
var(--border) calc(var(--progress) * 360deg)
|
||||||
);
|
);
|
||||||
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user