Skip to the content

Capsid menu

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

The functions of render-charts.ts
FunctionLinesComplexityCoveredCRAPMutation
renderCvCharts19 to 431No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
line22 to 281No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
<anonymous:32>32 to 321No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
hrefForYear36 to 362No data: no coverage report in this mapNo data: no coverage report in this mapNo 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),
  };
}