Skip to content

Summary Statistics

Compact components for embedding session stats at a glance. Two kinds: a sparkline that shows typing speed over time, and pill badges that surface key metrics from a session analysis. Both are designed for inline use – drop them into dashboards, sidebars, or summary views.

Compact typing speed chart with no axes or labels – designed for inline use.

import { Sparkline } from 'writetrack/viz';
Sparkline.register();
document.querySelector('wt-sparkline').setData(tracker.getData());
<wt-sparkline style="width: 200px; height: 40px;"></wt-sparkline>

Note that sparkline consumes raw WriteTrackDataSchema from getData(), not analysis data.

Programmatic factory:

const sparkline = Sparkline.create(containerElement, tracker.getData());

Default sizing: 200×40px. Override with inline styles or CSS custom properties.

Pill badges that surface a single metric from a session analysis. Each badge shows a label and a color-coded value – green for clear, red for flagged, grey for neutral.

import { WtBadge } from 'writetrack/viz';
WtBadge.register();
const analysis = await tracker.getAnalysis();
document.querySelectorAll('wt-badge').forEach((el) => el.setData(analysis));

Total keystrokes divided by final text length. Values above 1.0× reflect natural revision and editing work (backspaces, corrections, rewording). Below 1.0× suggests content arrived via paste or programmatic insertion rather than typing. Status: clear when ≥ 1.0, flag when < 1.0.

<wt-badge metric="effort-ratio"></wt-badge>

The single largest paste event as a percentage of final text length. High values indicate bulk content insertion. Always neutral status.

<wt-badge metric="largest-paste"></wt-badge>

Breakdown of deletion activity into two categories. “Typo” corrections happen at the text frontier – fixing what was just typed. “Revision” corrections happen earlier in the document – reworking prior text. The split reveals whether editing is reactive (fixing typos) or deliberate (revising ideas). Always neutral status.

<wt-badge metric="corrections"></wt-badge>

Number of times the user switched focus away from the writing surface. Always neutral status.

<wt-badge metric="tab-aways"></wt-badge>
AttributeTypeDefaultDescription
metricstring(required)Which metric to display: effort-ratio, largest-paste, corrections, tab-aways
themestringauto"light" or "dark". Overrides ancestor data-theme and prefers-color-scheme.
datastringundefinedJSON-serialized SessionAnalysis. Alternative to setData().
labelstringundefinedCustom aria-label for accessibility.

Standalone data extraction for use without the web component:

import { extractStatBadges } from 'writetrack/viz';
const badges = extractStatBadges(analysis);
// Returns: StatBadge[] – each with label, value, status, metric

Badge theming variables:

PropertyDescription
--wt-color-clearClear status background
--wt-color-flagFlag status background
--wt-color-borderBadge border, neutral bg
--wt-color-textNeutral value text color
--wt-color-text-mutedLabel text color
--wt-font-dataValue font
--wt-font-uiLabel font