From 5f9566e26df38450fc85388a272546a6b54f2e18 Mon Sep 17 00:00:00 2001 From: wangziqi Date: Fri, 7 Aug 2026 16:38:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E4=BF=AE=E6=AD=A3=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E6=88=90=E7=BB=A9=E8=B6=8B=E5=8A=BF=E5=9B=BE=20y=20?= =?UTF-8?q?=E8=BD=B4=E5=9D=90=E6=A0=87=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/src/archive/archive-report.exam.spec.ts | 14 ++++++++++++++ apps/server/src/archive/archive-report.exam.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 apps/server/src/archive/archive-report.exam.spec.ts diff --git a/apps/server/src/archive/archive-report.exam.spec.ts b/apps/server/src/archive/archive-report.exam.spec.ts new file mode 100644 index 0000000..8ae3c69 --- /dev/null +++ b/apps/server/src/archive/archive-report.exam.spec.ts @@ -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"'); + }); +}); diff --git a/apps/server/src/archive/archive-report.exam.ts b/apps/server/src/archive/archive-report.exam.ts index f099c5d..47da985 100644 --- a/apps/server/src/archive/archive-report.exam.ts +++ b/apps/server/src/archive/archive-report.exam.ts @@ -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 += `${val.toFixed(0)}`; + yLabels += `${val.toFixed(0)}`; if (i > 0) { yLabels += ``; }