Skip to content

Scorecard

The <wt-scorecard> custom element renders a complete session analysis report — header, stat badges, narrative summary, origin bar, analysis grid, and interactive detail panels with embedded charts.

Select a session below to see the scorecard — click any category preview to view its full chart and metrics.

import { WtScorecard } from 'writetrack/viz';
// Register the custom element (once, at app startup)
WtScorecard.register();
<wt-scorecard id="scorecard"></wt-scorecard>
// Feed data from a tracker session
const report = await tracker.getSessionReport();
document.querySelector('#scorecard').setData(report);

Or use the data attribute for declarative usage:

<wt-scorecard data='{"data": ..., "analysis": ...}'></wt-scorecard>
AttributeTypeDefaultDescription
themestringauto"light" or "dark". Overrides ancestor data-theme and prefers-color-scheme.
sharebooleanfalseShow share button and make QR code clickable.
downloadbooleanfalseShow download button.
datastringundefinedJSON-serialized SessionReport. Alternative to setData().
compactbooleanfalseCompact/sparkline rendering mode.
labelstringundefinedCustom aria-label for accessibility.

Boolean attributes are set by presence: <wt-scorecard share download>.

setData(data: SessionReport): void

Set session data and trigger a full re-render. Accepts a SessionReport containing both raw capture data and WASM analysis.

const report = await tracker.getSessionReport();
scorecard.setData(report);
getData(): SessionReport | null

Retrieve the current session data, or null if no data has been set.

static register(): void

Register the <wt-scorecard> custom element with the browser. Call once before creating elements.

Fired when the share button or QR code is clicked.

scorecard.addEventListener('wt-share', (e) => {
const { report } = e.detail;
// Generate shareable link, copy to clipboard, etc.
});

Detail: { report: SessionReport } Bubbles: true | Composed: true

Fired when the download button is clicked.

scorecard.addEventListener('wt-download', (e) => {
const { report } = e.detail;
// Trigger file download, export to PDF, etc.
});

Detail: { report: SessionReport } Bubbles: true | Composed: true

Fired when rendering completes. Useful for measuring render performance or triggering post-render actions.

Detail: none Bubbles: false

The scorecard respects theme in this priority order:

  1. theme attribute<wt-scorecard theme="dark">
  2. Ancestor data-theme<div data-theme="dark"><wt-scorecard></div>
  3. prefers-color-scheme — System preference

Override these on the wt-scorecard element or an ancestor to customize the look.

PropertyDescription
--wt-scorecard-bgMain background
--wt-scorecard-bg-cardCell card background
--wt-scorecard-bg-card-hoverCard hover state
--wt-scorecard-bg-card-flaggedFlagged cell background
--wt-scorecard-bg-detailDetail panel background
--wt-scorecard-textPrimary text
--wt-scorecard-text-secondarySecondary text
--wt-scorecard-text-tertiaryTertiary/muted text
--wt-scorecard-borderBorder color
--wt-scorecard-border-heavyHeavy border
--wt-scorecard-status-clearPass/clear status
--wt-scorecard-status-flaggedFlagged/fail status
PropertyDescription
--wt-scorecard-chart-lineChart line color
--wt-scorecard-chart-accentChart accent color
--wt-scorecard-chart-flaggedChart flagged color
--wt-scorecard-chart-tertiaryChart tertiary color
--wt-scorecard-chart-cyanChart cyan (paste) color
PropertyDescription
--wt-scorecard-font-displayDisplay font (titles, headers)
--wt-scorecard-font-dataData/code font
--wt-scorecard-font-bodyBody text font
wt-scorecard {
--wt-scorecard-bg: #0a0a0a;
--wt-scorecard-font-display: 'Inter', sans-serif;
--wt-scorecard-status-clear: #22c55e;
}