fix(server): 修正档案成绩趋势图 y 轴坐标字符串拼接
This commit is contained in:
14
apps/server/src/archive/archive-report.exam.spec.ts
Normal file
14
apps/server/src/archive/archive-report.exam.spec.ts
Normal 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"');
|
||||
});
|
||||
});
|
||||
@@ -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"/>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user