Files
CatoandClaude Opus 5.5 aa1eb85f6c feat(chartkit): LineExplorer — a chart the reader works; numbers shown with every value a link (#5)
* feat(chartkit): LineExplorer — a chart the reader works; numbers shown with every value a link

- @bitbaum/chartkit/explore: LineExplorer ("use client") over LineChart.
  Toggle series (never the last), narrow periods, figures or change since
  the first period; the view is data the app keeps in its URL
  (initial / onViewChange). Every control 44px, every word from the app.
- LineChart `numbers`: the table behind the chart shown behind a
  disclosure, each value a link to its source. Hidden table stays text.
- TableCell can be { text, href }. LineSeries.colour keeps a colour stable.
- Browser test works the explorer at 390/1280, light/dark: toggles,
  range, change from 0, table links, 44px targets, no overflow, audit.

First of Solon's "every number clickable, slice and dice" phases; upstream
so every product gets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(chatkit): the reader's place is where it was when history loads, not a fixed 240px

The Messenger check failed on main every run (325px): loading starts 200px
before the top (the observer's margin), so where the reader stands when the
page arrives varies. Measure the first message before and after the load;
a lost place still fails (it would jump down a whole page, off screen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(chartkit): the explorer's figures/change switch reads as a choice, not as switched off

The unchosen option was drawn muted, like a series switched off. It is a
choice of two: the chosen one is filled, the other reads as any button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(chartkit): LineExplorer defaultView — the app's own start, what Reset returns to

A product that keeps a series off until asked for (a second grey median)
showed Reset on first load. defaultView is the starting view: Reset returns
to it and only a departure from it counts as a change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:41:36 +01:00

34 lines
2.8 KiB
JavaScript

import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
* The frame every chart shares: a `<figure class="ck-chart">`, the drawing,
* the caption, and a visually hidden `<table>` of the same values. Nothing a
* chart says is reachable only by pointing at it. The drawing's decorative
* parts (the SVG, the ticks, the bars) carry `aria-hidden` themselves; the
* anchors in it do not, because a keyboard reaches them and a reader must be
* told what they are.
*/
export function ChartFigure({ kind, caption, table, children, style, numbers, }) {
return (_jsxs("figure", { className: `ck-chart ck-chart-${kind}`, style: style, children: [_jsx("div", { className: "ck-chart-draw", children: children }), _jsx("figcaption", { className: "ck-chart-caption", children: caption }), numbers ? (_jsxs("details", { className: "ck-numbers", children: [_jsx("summary", { className: "ck-numbers-summary", children: numbers }), _jsx(DataTable, { caption: caption, head: table.head, rows: table.rows, visible: true })] })) : (_jsx(DataTable, { caption: caption, head: table.head, rows: table.rows }))] }));
}
/** The values behind a chart, as a table a screen reader walks and a test reads. */
export function DataTable({ caption, head, rows, visible = false, }) {
return (_jsx("div", { className: visible ? "ck-numbers-scroll" : "ck-sr", children: _jsxs("table", { className: "ck-chart-table", children: [_jsx("caption", { children: caption }), _jsx("thead", { children: _jsx("tr", { children: head.map((h) => (_jsx("th", { scope: "col", children: h }, h))) }) }), _jsx("tbody", { children: rows.map((row, i) => (_jsx("tr", { children: row.map((cell, j) => j === 0 ? (_jsx("th", { scope: "row", children: _jsx(Cell, { cell: cell, link: visible }) }, j)) : (_jsx("td", { children: _jsx(Cell, { cell: cell, link: visible }) }, j))) }, i))) })] }) }));
}
// Only a table on the page carries links: in the hidden one they would be
// keyboard stops nobody can see (the drawing's points already link).
function Cell({ cell, link }) {
if (typeof cell !== "object")
return _jsx(_Fragment, { children: cell });
if (!cell.href || !link)
return _jsx(_Fragment, { children: cell.text });
return (_jsx(MaybeLink, { href: cell.href, className: "ck-cell-link", children: cell.text }));
}
/** A label that is an anchor when it has somewhere to go, else a span. */
export function MaybeLink({ href, className, title, children, style, }) {
if (href) {
const out = /^https?:\/\//.test(href);
return (_jsx("a", { href: href, className: className, title: title, style: style, ...(out ? { target: "_blank", rel: "noopener noreferrer" } : {}), children: children }));
}
return (_jsx("span", { className: className, title: title, style: style, children: children }));
}
//# sourceMappingURL=Figure.js.map