app/lib/cv/render-charts.ts
41 lines and 4 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| renderCvCharts | 19 to 43 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| line | 22 to 28 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| <anonymous:32> | 32 to 32 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| hrefForYear | 36 to 36 | 2 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/lib/cv/charts.ts, app/lib/cv/view.mjs. Imported by app/routes/cv.charts[.json].ts, app/routes/cv.tsx.
Source
import { sparklineSvg, timelineSvg } from "./charts";
import {
sparkData,
sparkLabel,
timelineData,
timelineEmptyText,
timelineLabel,
yearHref,
type CvState,
type Facts,
} from "./view.mjs";
export type CvCharts = { timeline: string; papers: string; grants: string; students: string };
/**
* Every chart on the CV for one filter state, as markup. The route and app/enhance/cv.ts both call
* it, so a shared URL and a live filter draw the same.
*/
export function renderCvCharts(all: Facts[], state: CvState, options: { width?: number } = {}): CvCharts {
const timeline = timelineData(all, state);
const spark = sparkData(all, state);
const line = (what: string, values: number[]) =>
sparklineSvg({
years: spark.years,
values,
selected: spark.selected,
label: sparkLabel(what, spark.years, values),
});
return {
timeline: timelineSvg({
years: timeline.years,
series: timeline.series.map((s) => ({ key: s.key, label: s.label, token: s.token, values: s.values })),
selected: timeline.selected,
label: timelineLabel(timeline),
emptyText: timelineEmptyText(timeline),
hrefForYear: (year) => `/cv${yearHref(state, year) || "?"}`,
width: options.width,
}),
papers: line("publications", spark.papers),
grants: line("grants", spark.grants),
students: line("students in one-year cohorts", spark.students),
};
}