feat(constellations) : add infographic image export
CI / Verify (push) Successful in 1m2s
CI / Build immutable images and deploy (push) Successful in 1m48s

This commit is contained in:
2026-09-03 15:07:22 +07:00 Unverified
parent c0ab204d06
commit fbc4d9d4b2
6 changed files with 219 additions and 6 deletions
+30
View File
@@ -10,3 +10,33 @@ export function imageContentDisposition(displayName: string, fallbackName: strin
);
return `attachment; filename="${fallback}.png"; filename*=UTF-8''${encoded}`;
}
export interface ConstellationChartRow {
level: number;
percent: number;
isGreat: boolean;
widthPercent: number;
}
export function constellationChartRows(
rows: ReadonlyArray<{
level: number;
cumulativePercent: string;
isGreat: boolean;
}>,
): ConstellationChartRow[] {
const values = [
...rows.map((row) => ({
level: row.level,
percent: Number(row.cumulativePercent),
isGreat: row.isGreat,
})),
{ level: 0, percent: 100, isGreat: false },
].sort((left, right) => right.level - left.level);
const maximum = Math.max(100, ...values.map((row) => row.percent));
return values.map((row) => ({
...row,
widthPercent: Math.max(0, Math.min(100, (row.percent / maximum) * 100)),
}));
}