fix: 上传与路由校验加固、甘特图时间线修复 #63

Merged
wangziqi merged 6 commits from fix/quick-wins-and-gantt into main 2026-08-07 08:38:47 +00:00
2 changed files with 15 additions and 1 deletions
Showing only changes of commit 5f9566e26d - Show all commits

View File

@@ -0,0 +1,14 @@
import { renderScoreTrendChart } from './archive-report.exam';
describe('renderScoreTrendChart', () => {
it('places the first y-axis label 4px below the top gridline using numeric addition', () => {
const html = renderScoreTrendChart([
{ examType: '文化', score: 60, examDate: '2026-01-01' },
{ examType: '文化', score: 90, examDate: '2026-02-01' },
{ examType: '文化', score: 70, examDate: '2026-03-01' },
] as never);
expect(html).toContain('y="154.0"');
expect(html).not.toContain('y="150.04"');
});
});

View File

@@ -146,7 +146,7 @@ export function renderScoreTrendChart(exams: ExamScore[]): string {
for (let i = 0; i <= ySteps; i++) {
const val = minScore + (scoreRange * i) / ySteps;
const y = scaleY(val);
yLabels += `<text x="${pad.left - 6}" y="${y.toFixed(1) + 4}" text-anchor="end" fill="#667085" font-size="10">${val.toFixed(0)}</text>`;
yLabels += `<text x="${pad.left - 6}" y="${(y + 4).toFixed(1)}" text-anchor="end" fill="#667085" font-size="10">${val.toFixed(0)}</text>`;
if (i > 0) {
yLabels += `<line x1="${pad.left}" y1="${y.toFixed(1)}" x2="${w - pad.right}" y2="${y.toFixed(1)}" stroke="#eaf3fd" stroke-width="1"/>`;
}