expressive-charts 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +8 -8
  3. package/dist/{chunk-N5IF2RO2.js → chunk-7A7LXXT4.js} +6 -2
  4. package/dist/chunk-7A7LXXT4.js.map +1 -0
  5. package/dist/{chunk-V5IUTXRW.js → chunk-CJUQHEX6.js} +70 -23
  6. package/dist/chunk-CJUQHEX6.js.map +1 -0
  7. package/dist/{chunk-CVXP2L2J.js → chunk-N2BLUETM.js} +17 -5
  8. package/dist/chunk-N2BLUETM.js.map +1 -0
  9. package/dist/{drawing-DWZIXIeR.d.cts → drawing-CdTgixMY.d.cts} +14 -2
  10. package/dist/{drawing-DWZIXIeR.d.ts → drawing-CdTgixMY.d.ts} +14 -2
  11. package/dist/{effect-CcGdU41j.d.cts → effect-Bu3MHHeg.d.ts} +4 -2
  12. package/dist/{effect-CZUckY0l.d.ts → effect-D4vmdYP4.d.cts} +4 -2
  13. package/dist/expressive-charts.css +6 -1
  14. package/dist/expressive-charts.css.d.cts +2 -0
  15. package/dist/expressive-charts.css.d.ts +2 -0
  16. package/dist/expressive-charts.global.js +51 -46
  17. package/dist/expressive-charts.global.js.map +1 -1
  18. package/dist/icons/sport.cjs +5 -1
  19. package/dist/icons/sport.cjs.map +1 -1
  20. package/dist/icons/sport.js +2 -2
  21. package/dist/index.cjs +839 -358
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +43 -15
  24. package/dist/index.d.ts +43 -15
  25. package/dist/index.js +700 -282
  26. package/dist/index.js.map +1 -1
  27. package/dist/testing.cjs +71 -37
  28. package/dist/testing.cjs.map +1 -1
  29. package/dist/testing.d.cts +2 -2
  30. package/dist/testing.d.ts +2 -2
  31. package/dist/testing.js +6 -8
  32. package/dist/testing.js.map +1 -1
  33. package/package.json +16 -4
  34. package/dist/chunk-CVXP2L2J.js.map +0 -1
  35. package/dist/chunk-N5IF2RO2.js.map +0 -1
  36. package/dist/chunk-V5IUTXRW.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -25,6 +25,35 @@ From 0.1.0:
25
25
 
26
26
  Everything else can still change in a minor release while the library is 0.x: the motion core (`motion`, `createMotion`, the clocks, `tween`, `animated`, `playback`, and the types the list doesn't name), the charts, the adapters, the built-in effects and the controls. Those changes are listed here too. [docs/effects-guide.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/effects-guide.md) is the guide to the author API.
27
27
 
28
+ ## 0.3.0 (27 October 2026)
29
+
30
+ A tooltip that can be hovered, change labels that hold up, lines that skip missing values, long axes, and more of the icon sets' SVG. In the effect-author API, `gaps` on `MarkGeometry`, `gapBefore` on `Sample`, `breaks` on `LineSpec`, and `fillRule` and `opacity` on `IconShape` are additions. Its one change is the `"gapped line"` fixture, with its migration note under Changed. The other changes are outside the promise, and each says what to write instead, if anything.
31
+
32
+ ### Added
33
+
34
+ - **`fillRule` and `opacity` on `IconShape`**, under the 0.x promise. `fillRule` is `"nonzero"` (the default) or `"evenodd"`, which leaves a hole where the path's parts overlap. `opacity`, from 0 to 1 (default 1), fades the whole shape, its fill and stroke together. `defineIcon` checks them, with a `RangeError` naming the shape and the field, and the SVG layer draws them. They're optional fields: code that builds an `IconShape` needs no change.
35
+ - **`gaps` on `MarkGeometry`**, under the 0.x promise: the stretches of a mark's walk with no data, as `[from, to]` values of `t`, in order and apart. A line that skips a value has one, from the value before to the value after. The walk runs straight across a gap, so `start`, `end`, `length`, `path(t)`, `angle(t)` and `outline.sample(n)` work as on any walk; `slice(t0, t1)` and an open outline's `d` leave the gaps out, with a move across each. It's an optional field: code that builds a `MarkGeometry` needs no change, and no mark has gaps unless a line skips a value. An effect that draws its own path from `path(t)` would draw across a gap, so draw along a walk with `slice()`, as the effects guide says.
36
+ - **`breaks` on `LineSpec`**, under the 0.x promise: `describe.line({ points, breaks })` takes the indices of the points that start a new run, so there's a gap from `points[i - 1]` to `points[i]`. Each is a whole number from 1 to the last index, in order, with no repeats; anything else throws a `RangeError` naming it (`breaks[1]`). So a page describes a D3 line drawn with `.defined()` by its defined points and where they break. An optional field: code without it needs no change.
37
+ - **`gapBefore` on `Sample`**, under the 0.x promise: `true` on the first sample after a gap, so a data effect doesn't join it to the one before. `samplesAlong()` sets it from the mark's gaps, and `expressive()` keeps it on the samples a page gives. An optional field.
38
+ - **Missing values on `lineChart`.** `series` take fields of `number | null | undefined`, and a value that's `null` or `undefined` is missing: a gap in its line, from the value before to the value after, with no point. It used to throw. The x stays a stop: the crosshair stops there, and its name, the tooltip and the data table say the series is missing ("3: goals missing, 3.6 xg"). At an x with every value missing there's no point to ring, so keyboard focus there is a 2 px line in `--ec-focus` where the crosshair is, which stays when Escape hides the crosshair. A value alone between gaps shows its point at rest; a line revealed into a gap ends at its last value, with its end label there; and a line with no values is empty. Its samples leave the missing values out, with `gapBefore` after each gap, so `threshold` colours nothing there and `travel` jumps across. A gap opens or closes as a change starts, a value that comes growing out of the line. `NaN` and the infinities still throw. `markLabel`'s summary lists only the values an x has.
39
+ - **Effects across a gap.** `travel` jumps: its icon is never drawn over a gap, and goes from one side to the other at once, inset from each run's ends as from the walk's. Its trip's time counts only the runs it's drawn on, and a run shorter than the icon is passed at once, unless it's the last, where the icon rests at the last value. `threshold` doesn't interpolate across a `gapBefore`, in the mark's samples or the reference's, so where either has no value nothing is coloured. `trace`, `pulse`, `flash`, `wiggle`, `delta` and `label` skip gaps unchanged. No built-in effect draws inside a gap.
40
+ - **`room` on `barChart`**: px the layout keeps clear past the labels at each end of the value axis that bars reach, for text an effect draws there, such as a `delta`. Default 0, so nothing moves. At 320 px, `room: 28` keeps a bar's, a column's and a negative bar's `delta` inside the chart, so a page no longer pads the chart's container for it. Anything but a number of px, 0 or more, throws a `RangeError`.
41
+ - **Page Up and Page Down** on every chart, and on an attachment with `keyboard: true`. They move focus a page on or back and stop at the ends, as the arrows do: a tenth of the marks, rounded up, or on a line chart's time axis a calendar month in its `timeZone`, to the first x a month or more away. A month on keeps the day, or ends a shorter month on its last day: 31 January goes to 28 February. So ten years of days is 120 presses, not 3,653. With Alt, Ctrl or Meta they're still the browser's.
42
+
43
+ ### Changed
44
+
45
+ - **`"gapped line"` in `FixtureName` and `fixtures`**, under the 0.x promise: the line fixture with a gap after its second point, a run either side. So `checkEffect` runs every effect on it too, by default: an effect that fails its checks on a mark with gaps fails where it passed before. Code that maps every fixture's name, such as a `Record<FixtureName, …>`, needs one more entry: `"gapped line": …`. Code that only reads fixtures, or passes its own `marks`, needs no change.
46
+ - **An update ends the last one's `update` effects on the marks it leaves alone**, as a re-trigger would: a `delta` goes at its chart's next update, and a `flash` still playing stops there. An update is a chart's `update()` with `data`, even if no value changed (a matchweek where nobody scores), or one that changes a value or adds or removes a mark; or an attachment's `refresh()` that finds a new row, a new value, or a mark entering or leaving. `update({ on })` alone, a re-sort, a resize, a line's `reveal()`, and a `refresh()` that finds nothing new (a Vega render for a hover signal) keep them. Before, an update effect stayed until its own mark's next update, so a page emptied the slot itself (`update({ on: {} })`) before each update; that's no longer needed, and can go. To keep something past the next update, put it in `decorate`.
47
+ - **Overlay text on attachments is sized as on our charts**: 12.5 px, weight 600, with tabular digits, in the theme's text colour, by a new `.ec-overlay .ec-text` rule. So `delta`'s and `label`'s text on an `expressive()` or `fromVegaView()` attachment no longer takes the host page's text size. The rule is in `:where()`, so a page's own CSS still wins: for the page's size, as before, add `.ec-overlay .ec-text { font-size: inherit; font-weight: inherit; }`, or size it in the page's own rule, such as `#slope .ec-text { font-size: 11px; }`.
48
+ - **A bar chart thins labels that would overlap.** Past about 40 bars, its labels overlapped. Now it draws every nth category label, from the first, with n the smallest of 1, 2, 5, 10, 20, 50 and so on that leaves none overlapping, and its value labels all or none: none when any two would overlap. The marks' names, the tooltip, the legend and the data table keep every name and value; `labelBounds` and `labels()` have only the labels drawn. A chart whose labels didn't overlap looks as it did, and there's no option. A page that thinned the labels itself, with CSS such as `.ec-mark:not([data-key$="0"]) .ec-label { display: none; }`, should drop that rule, which now thins them twice. To show every name, give the chart room for them: more `height` for bars, more `width` for columns, or fewer bars.
49
+
50
+ ### Fixed
51
+
52
+ - **An update run's `data.previous` holds the values the last update gave**, not the values part way through a change still playing. So an update that replaces one still moving says "+1" with `delta`'s default `value`, not "+1.88", and a page no longer needs a `value` that reads its rows to get it right. The values before are the data the mark last rested at: its last update, or where it's been since without a transition (a resize, a line's reveal). The `previous` geometry, and an `update` event's `from`, are still the mark on screen, which the transition starts from.
53
+ - **`iconFromSvg` keeps `fill-rule` and `opacity`**, so an icon whose SVG has an even-odd hole (Heroicons' solid style) or a faded part (a duotone set's) draws as its SVG does. Before, the hole filled in and the faded part drew at full strength. They're read from attributes and `style` and inherited through groups, with a group's opacity multiplied into its shapes'. A shape with an opacity of 0 is dropped. `fill-opacity` and `stroke-opacity` still aren't kept.
54
+ - **`import "expressive-charts/style.css"` typechecks on TypeScript 6 and 7.** From TypeScript 6, a side-effect import must find something (`noUncheckedSideEffectImports` is on by default), and the stylesheet had no types, so the import was error TS2882. Its export now has types, an empty module (`dist/expressive-charts.css.d.ts` and `.d.cts`), and bundlers and Node still load the CSS. It keeps a plain `default` too, so a CSS `@import` (css-loader's) and Sass, which resolve with conditions such as `style`, still find it. Nothing changes on TypeScript 5.4 to 5.9.
55
+ - **The tooltip can be hovered** (WCAG 1.4.13, the accessibility audit's one fail). It took no pointer, so moving onto it hovered whatever was under it, or nothing, which hid it. Now, while it shows, the pointer on it stays on the mark or x it's for, so its text can be read, selected and magnified: leaving it for a mark hovers that mark, and leaving it for anything else ends the hover. Beside a mark, a clear bridge over the 12 px gap leads to it, and one that comes up under a resting pointer, as a crosshair's can, lets the pointer through until the pointer is off it. It looks the same, and Escape still hides it. While it shows it covers the marks under it: reach them round it, or by keyboard.
56
+
28
57
  ## 0.2.0 (26 October 2026)
29
58
 
30
59
  Built-in effects that explain a change, text that keeps clear of a mark's own labels, and hover linked across charts. Nothing in the effect-author API breaks: its one change, `labelBounds`, is an addition. The other changes are outside the promise, and each says what to write instead, if anything.
package/README.md CHANGED
@@ -15,7 +15,7 @@ Composable motion and expressive effects for web charts. Hover, update and morph
15
15
 
16
16
  Each picture plays once and stops where its effect ends. **[The demo site](https://deaversbp.github.io/expressive-charts/)** has every effect to try, on the library's charts and on D3, Vega-Lite and hand-written ones, with the motion modes and reduced motion.
17
17
 
18
- > **Status: 0.2.0 (October 2026).** The effect-author API is under [the 0.x promise](#the-0x-promise); the charts, adapters, built-in effects and motion core can still change in a minor release. [CHANGELOG.md](https://github.com/Deaversbp/expressive-charts/blob/main/CHANGELOG.md#020-26-october-2026) lists what's new and what changed since 0.1.0.
18
+ > **Status: 0.3.0 (October 2026).** The effect-author API is under [the 0.x promise](#the-0x-promise); the charts, adapters, built-in effects and motion core can still change in a minor release. [CHANGELOG.md](https://github.com/Deaversbp/expressive-charts/blob/main/CHANGELOG.md#030-27-october-2026) lists what's new and what changed since 0.2.0.
19
19
 
20
20
  - **Effects first.** The mark effects `travel`, `flash`, `wiggle`, `pulse`, `trace` and the data effects `threshold`, `delta` and `label`, put together with `sequence`, `parallel`, `only` and `stagger`; and the transition effect `morph`, which `chartSwitch` plays to turn each mark of one chart into its mark in the next (a transition can't go into a combinator). An effect reads only a shared description of the mark, so one effect works on every chart, and effects of your own work everywhere the built-in ones do.
21
21
  - **Charts and adapters.** Bar, donut and line charts, a switch that morphs one into another, adapters that bring the same effects to SVG marks drawn by other code, and hover linked across them.
@@ -28,13 +28,13 @@ Each picture plays once and stops where its effect ends. **[The demo site](https
28
28
  npm install expressive-charts
29
29
  ```
30
30
 
31
- It has no runtime dependencies. It's an ES module and CommonJS, each with its own types, and its JavaScript has no side effects, so a bundler keeps only what a page imports: a bar chart is about 29 KB gzipped, and everything 68 KB.
31
+ It has no runtime dependencies. It's an ES module and CommonJS, each with its own types, and its JavaScript has no side effects, so a bundler keeps only what a page imports: a bar chart is about 31 KB gzipped, and everything 72 KB.
32
32
 
33
33
  On a page with no bundler, the script-tag bundle defines one global, `ExpressiveCharts`, holding the main entry:
34
34
 
35
35
  ```html
36
36
  <div id="sales"></div>
37
- <script src="https://cdn.jsdelivr.net/npm/expressive-charts@0.2/dist/expressive-charts.global.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/expressive-charts@0.3/dist/expressive-charts.global.js"></script>
38
38
  <script>
39
39
  const { barChart } = ExpressiveCharts;
40
40
  barChart("#sales", {
@@ -124,9 +124,9 @@ playButton("#play", season, { labels: { play: "Play season" } });
124
124
 
125
125
  [docs/api.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md) documents every export, with its options, their defaults and what it returns.
126
126
 
127
- - **Charts.** [`barChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#barchart) draws bars or columns, plain or stacked; [`donutChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#donutchart) shares of a total; [`lineChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#linechart) a line per series, on a number axis or, when `x` gives `Date`s, a time axis in UTC (or `timeZone: "local"`) worded in the page's locale. Each sizes itself to its container, follows the light or dark theme, and has a tooltip, a legend, a data table and keyboard focus. Its handle has `update()`, which animates a change by the motion mode, and `update({ on })` swaps its effects in place; `focus(key)`; `leave()`, which ends its hover; and `labels()`. `table.series` heads a series' column in the data table.
127
+ - **Charts.** [`barChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#barchart) draws bars or columns, plain or stacked; [`donutChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#donutchart) shares of a total; [`lineChart`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#linechart) a line per series, on a number axis or, when `x` gives `Date`s, a time axis in UTC (or `timeZone: "local"`) worded in the page's locale, with a gap wherever a value is `null` or `undefined`. Each sizes itself to its container, follows the light or dark theme, and has a tooltip, a legend, a data table and keyboard focus. Its handle has `update()`, which animates a change by the motion mode, and `update({ on })` swaps its effects in place; `focus(key)`; `leave()`, which ends its hover; and `labels()`. `table.series` heads a series' column in the data table.
128
128
  - **Switching.** [`chartSwitch`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#chartswitch) shows views of the same data one at a time, and turns each mark into its own mark in the next with [`morph()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#morph): a donut becoming columns, and back from wherever it is.
129
- - **Adapters.** [`expressive()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#expressive) reads keys, rows and geometry from SVG marks drawn by D3, Observable Plot or by hand, and draws on an overlay, leaving the host's styling alone; `watch: true` follows the host's own transitions. Observable Plot binds each rect to its row's index, so pass `datum: (el) => rows[el.__data__]`; Plot draws a new `<svg>` each time, so pass `refresh()` the new one's rects. The Plot accessors are tested against Plot 0.6.17. [`fromVegaView()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#fromvegaview) does the same for a Vega or Vega-Lite View rendered as SVG, and follows its renders.
129
+ - **Adapters.** [`expressive()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#expressive) reads keys, rows and geometry from SVG marks drawn by D3, Observable Plot or by hand, and draws on an overlay, leaving the host's styling alone; `watch: true` follows the host's own transitions. A line drawn with d3's `.defined()` keeps its gaps: describe it with [`describe.line`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#linespec)'s `breaks`, and no effect draws inside them. Observable Plot binds each rect to its row's index, so pass `datum: (el) => rows[el.__data__]`; Plot draws a new `<svg>` each time, so pass `refresh()` the new one's rects. The Plot accessors are tested against Plot 0.6.17. [`fromVegaView()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#fromvegaview) does the same for a Vega or Vega-Lite View rendered as SVG, and follows its renders.
130
130
  - **Linked hover.** [`link()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#link) links hover across charts and attachments by a value their marks share, such as a column's matchweek and the line's x there: hovering one hovers the others' marks with that value, with their emphasis, dimming and hover effects, as `source: "linked"`. Linked charts show no tooltip and take no focus.
131
131
  - **Effects.** [`travel`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#travel) carries an icon along a mark; [`flash`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#flash), [`wiggle`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#wiggle) and [`pulse`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#pulse) draw attention without changing a value; [`trace`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#trace) draws a highlighter stroke along a mark and leaves it there; [`threshold`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#threshold) colours the parts of a mark below or above a reference; [`delta`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#delta) labels a mark's change since the last update ("+2"), and [`label`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#label) any text worked out from its data, past the mark's own labels. Each goes in an effect slot (`hover`, `enter`, `update`, `exit`, `decorate`), as an effect or a preset's name (`"wiggle"`).
132
132
  - **Controls.** [`motionSwitch()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#motionswitch) is the viewer's own choice of mode. [`playback()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#playback) plays a value through a range, and [`playButton()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#playbutton) is its Play/Pause button.
@@ -170,7 +170,7 @@ The script-tag bundle, `dist/expressive-charts.global.js`, is the main entry alo
170
170
  ## Browsers and TypeScript
171
171
 
172
172
  - **Browsers.** Current Chrome and Edge, Firefox, and Safari. Every DOM check in the test suite (names, roles, tab order, focus rings, tooltips, keys, switches and reduced motion), with axe's accessibility rules, runs in Chromium, Firefox and WebKit, in Playwright 1.64; the screenshots are Chromium's. That's each browser's engine, not a device: Safari on macOS and iOS hasn't been run itself. The build targets ES2020.
173
- - **TypeScript 5.4 or newer**, since the types use `NoInfer`. The packed package is checked under `bundler` and `node16` resolution, as an ES module and as CommonJS. Under the old `node10` (`"node"`), TypeScript can't find the subpath entries' types.
173
+ - **TypeScript 5.4 or newer**, since the types use `NoInfer`. The packed package is checked on TypeScript 5.4, 6 and 7, under `bundler` and `node16` resolution, as an ES module and as CommonJS, with `import "expressive-charts/style.css"`. Under the old `node10` (`"node"`), TypeScript can't find the subpath entries' types.
174
174
  - **Node.js 22 or newer** to import it on a server: nothing touches the DOM until a chart, an adapter or a control is made, and those need one.
175
175
 
176
176
  ## Content-Security-Policy
@@ -193,12 +193,12 @@ The package lists its CSS under `sideEffects`, so bundlers keep that import. Cha
193
193
  ## Accessibility
194
194
 
195
195
  - **Names.** Each chart is a `role="group"` named by its `label`, and each mark one image named by what it shows: "Okafor: 16 goals, 4 assists", or a slice's "Saved: 112 shots, 28%". `markLabel` words the names ("1 goal") and `markDescription` adds what they don't say.
196
- - **Keyboard.** A chart is one tab stop: the arrow keys move between its marks, Home and End go to the ends, and focus shows a ring and plays the same effects as hover. Escape ends a hover, and so does `leave()`.
196
+ - **Keyboard.** A chart is one tab stop: the arrow keys move between its marks, Page Up and Page Down by a page (a month on a line's time axis), Home and End go to the ends, and focus shows a ring and plays the same effects as hover. Escape ends a hover, and so does `leave()`.
197
197
  - **Fallbacks.** A data table after every chart, which every screen reader can read, and with `announce: true` a polite live region that says what each update changed.
198
198
  - **Motion.** Reduced motion jumps every animation to its end state unless the viewer picks a mode on the page, with `motionSwitch()`. Nothing plays by itself, and a playback has its pause control in `playButton()` (WCAG 2.2.2).
199
199
  - **Other people's charts.** `expressive()` adds the same keyboard focus with `keyboard: true`, and one name per mark with `markLabel`.
200
200
 
201
- The demo pages with the library's charts on them have had a written WCAG 2.2 AA audit ([a11y-audit.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/a11y-audit.md)), and the test suite runs axe's WCAG rules on every demo page in Chromium, Firefox and WebKit, in light and dark, at 320 px wide and under forced colours. Screen-reader scripts for NVDA and Chrome, with their results, are in [a11y-check.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/a11y-check.md#results). Known gaps: the tooltip can't be hovered itself (it can be dismissed with Escape), and VoiceOver hasn't been run.
201
+ The demo pages with the library's charts on them have had a written WCAG 2.2 AA audit ([a11y-audit.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/a11y-audit.md)), and the test suite runs axe's WCAG rules on every demo page in Chromium, Firefox and WebKit, in light and dark, at 320 px wide and under forced colours. Screen-reader scripts for NVDA and Chrome, with their results, are in [a11y-check.md](https://github.com/Deaversbp/expressive-charts/blob/main/docs/a11y-check.md#results). The tooltip can be hovered, and dismissed with Escape. Known gap: VoiceOver hasn't been run.
202
202
 
203
203
  ## Limits
204
204
 
@@ -2,6 +2,7 @@
2
2
  var GAITS = ["roll", "step", "slide"];
3
3
  var LINECAPS = ["butt", "round"];
4
4
  var LINEJOINS = ["miter", "round"];
5
+ var FILL_RULES = ["nonzero", "evenodd"];
5
6
  var PATH_DATA = /^\s*[Mm][MmLlHhVvCcSsQqTtAaZz0-9eE.,+\-\s]*$/;
6
7
  function defineIcon(spec) {
7
8
  const name = spec?.name;
@@ -52,8 +53,11 @@ function checkShape(shape, field, fail, finite) {
52
53
  if (shape.width !== void 0 && finite(`${field}.width`, shape.width) < 0) fail(`${field}.width`, `can't be negative, got ${shape.width}`);
53
54
  if (shape.linecap !== void 0 && !LINECAPS.includes(shape.linecap)) fail(`${field}.linecap`, `must be butt or round, got ${String(shape.linecap)}`);
54
55
  if (shape.linejoin !== void 0 && !LINEJOINS.includes(shape.linejoin)) fail(`${field}.linejoin`, `must be miter or round, got ${String(shape.linejoin)}`);
56
+ if (shape.fillRule !== void 0 && !FILL_RULES.includes(shape.fillRule)) fail(`${field}.fillRule`, `must be nonzero or evenodd, got ${String(shape.fillRule)}`);
57
+ const opacity = shape.opacity === void 0 ? 1 : finite(`${field}.opacity`, shape.opacity);
58
+ if (opacity < 0 || opacity > 1) fail(`${field}.opacity`, `must be from 0 to 1, got ${opacity}`);
55
59
  const copy = { d: shape.d };
56
- for (const key of ["fill", "stroke", "width", "linecap", "linejoin", "clip"]) {
60
+ for (const key of ["fill", "stroke", "width", "linecap", "linejoin", "clip", "fillRule", "opacity"]) {
57
61
  if (shape[key] !== void 0) copy[key] = shape[key];
58
62
  }
59
63
  return freeze(copy);
@@ -63,4 +67,4 @@ var freeze = (value) => Object.freeze(value);
63
67
  export {
64
68
  defineIcon
65
69
  };
66
- //# sourceMappingURL=chunk-N5IF2RO2.js.map
70
+ //# sourceMappingURL=chunk-7A7LXXT4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/icons/define.ts"],"sourcesContent":["// defineIcon: fills an icon's defaults and checks every field, so effects can rely on all of them.\n\nimport type { Icon, IconShape, Point, Rect } from \"../core\";\n\n/** What defineIcon takes: an Icon whose pivot, footprint and size are optional. */\nexport type IconSpec = Omit<Icon, \"footprint\" | \"pivot\" | \"size\"> & Partial<Pick<Icon, \"footprint\" | \"pivot\" | \"size\">>;\n\nconst GAITS: readonly string[] = [\"roll\", \"step\", \"slide\"];\nconst LINECAPS: readonly string[] = [\"butt\", \"round\"];\nconst LINEJOINS: readonly string[] = [\"miter\", \"round\"];\nconst FILL_RULES: readonly string[] = [\"nonzero\", \"evenodd\"];\n/** Path data: commands, numbers, separators. Anything else (markup, url(), quotes) is a mistake. */\nconst PATH_DATA = /^\\s*[Mm][MmLlHhVvCcSsQqTtAaZz0-9eE.,+\\-\\s]*$/;\n\n/**\n * Makes an icon from its parts. Shapes are drawn facing +x, up towards −y, in px at the icon's\n * natural size. Defaults: `pivot` is the anchor, `footprint` reaches from the anchor to the box's\n * edges, `size` is the box's width and `radius` half its height. Bad input throws a RangeError\n * naming the field. The icon and its parts are frozen, since one icon is shared by every run.\n */\nexport function defineIcon(spec: IconSpec): Icon {\n const name = spec?.name;\n if (typeof name !== \"string\" || name === \"\") throw new TypeError(`defineIcon needs a non-empty string name, got ${JSON.stringify(name)}.`);\n const fail = (field: string, problem: string): never => {\n throw new RangeError(`defineIcon: \"${name}\" ${field} ${problem}.`);\n };\n const finite = (field: string, value: unknown): number =>\n typeof value === \"number\" && Number.isFinite(value) ? value : fail(field, `must be a finite number, got ${String(value)}`);\n const positive = (field: string, value: unknown): number => (finite(field, value) > 0 ? (value as number) : fail(field, `must be more than 0, got ${String(value)}`));\n const point = (field: string, value: Point | undefined): Point =>\n value && typeof value === \"object\" ? freeze({ x: finite(`${field}.x`, value.x), y: finite(`${field}.y`, value.y) }) : fail(field, \"must be a point { x, y }\");\n\n if (!Array.isArray(spec.shapes) || spec.shapes.length === 0) fail(\"shapes\", \"must be a non-empty array\");\n const shapes = spec.shapes.map((shape, i) => checkShape(shape, `shapes[${i}]`, fail, finite));\n\n const b = spec.box;\n if (!b || typeof b !== \"object\") fail(\"box\", \"must be a rectangle { x, y, width, height }\");\n const box: Rect = freeze({ x: finite(\"box.x\", b.x), y: finite(\"box.y\", b.y), width: positive(\"box.width\", b.width), height: positive(\"box.height\", b.height) });\n\n const anchor = point(\"anchor\", spec.anchor);\n const pivot = spec.pivot === undefined ? anchor : point(\"pivot\", spec.pivot);\n const footprint = spec.footprint ?? [Math.max(0, anchor.x - box.x), Math.max(0, box.x + box.width - anchor.x)];\n if (!Array.isArray(footprint) || footprint.length !== 2) fail(\"footprint\", \"must be [behind, ahead]\");\n footprint.forEach((reach, i) => {\n if (finite(`footprint[${i}]`, reach) < 0) fail(`footprint[${i}]`, `can't be negative, got ${reach}`);\n });\n const size = spec.size === undefined ? box.width : positive(\"size\", spec.size);\n const radius = spec.radius === undefined ? box.height / 2 : positive(\"radius\", spec.radius);\n if (spec.gait !== undefined && !GAITS.includes(spec.gait)) fail(\"gait\", `must be roll, step or slide, got ${String(spec.gait)}`);\n if (spec.upright !== undefined && typeof spec.upright !== \"boolean\") fail(\"upright\", `must be true or false, got ${String(spec.upright)}`);\n\n return freeze({\n name,\n shapes: freeze(shapes),\n box,\n size,\n anchor,\n pivot,\n footprint: freeze([footprint[0], footprint[1]] as const),\n ...(spec.gait !== undefined ? { gait: spec.gait } : {}),\n radius,\n ...(spec.upright !== undefined ? { upright: spec.upright } : {})\n });\n}\n\nfunction checkShape(\n shape: IconShape,\n field: string,\n fail: (field: string, problem: string) => never,\n finite: (field: string, value: unknown) => number\n): IconShape {\n if (!shape || typeof shape !== \"object\") fail(field, \"must be a shape { d, fill?, stroke?, … }\");\n if (typeof shape.d !== \"string\" || !PATH_DATA.test(shape.d)) fail(`${field}.d`, \"must be path data starting with a move\");\n if (shape.clip !== undefined && (typeof shape.clip !== \"string\" || !PATH_DATA.test(shape.clip))) fail(`${field}.clip`, \"must be path data starting with a move\");\n for (const paint of [\"fill\", \"stroke\"] as const) {\n const value = shape[paint];\n if (value !== undefined && (typeof value !== \"string\" || value === \"\")) fail(`${field}.${paint}`, `must be a colour, got ${String(value)}`);\n }\n if (shape.width !== undefined && finite(`${field}.width`, shape.width) < 0) fail(`${field}.width`, `can't be negative, got ${shape.width}`);\n if (shape.linecap !== undefined && !LINECAPS.includes(shape.linecap)) fail(`${field}.linecap`, `must be butt or round, got ${String(shape.linecap)}`);\n if (shape.linejoin !== undefined && !LINEJOINS.includes(shape.linejoin)) fail(`${field}.linejoin`, `must be miter or round, got ${String(shape.linejoin)}`);\n if (shape.fillRule !== undefined && !FILL_RULES.includes(shape.fillRule)) fail(`${field}.fillRule`, `must be nonzero or evenodd, got ${String(shape.fillRule)}`);\n const opacity = shape.opacity === undefined ? 1 : finite(`${field}.opacity`, shape.opacity);\n if (opacity < 0 || opacity > 1) fail(`${field}.opacity`, `must be from 0 to 1, got ${opacity}`);\n const copy: { -readonly [K in keyof IconShape]: IconShape[K] } = { d: shape.d };\n for (const key of [\"fill\", \"stroke\", \"width\", \"linecap\", \"linejoin\", \"clip\", \"fillRule\", \"opacity\"] as const) {\n if (shape[key] !== undefined) (copy as Record<string, unknown>)[key] = shape[key];\n }\n return freeze(copy);\n}\n\nconst freeze = <T>(value: T): T => Object.freeze(value);\n"],"mappings":";AAOA,IAAM,QAA2B,CAAC,QAAQ,QAAQ,OAAO;AACzD,IAAM,WAA8B,CAAC,QAAQ,OAAO;AACpD,IAAM,YAA+B,CAA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A4B,OAAO,EAAE;AAC9F,QAAM,OAA2D,EAAE,GAAG,MAAM,EAAE;AAC9E,aAAW,OAAO,CAAC,QAAQ,UAAU,SAAS,WAAW,YAAY,QAAQ,YAAY,SAAS,GAAY;AAC5G,QAAI,MAAM,GAAG,MAAM,OAAW,CAAC,KAAiC,GAAG,IAAI,MAAM,GAAG;AAAA,EAClF;AACA,SAAO,OAAO,IAAI;AACpB;AAEA,IAAM,SAAS,CAAI,UAAgB,OAAO,OAAO,KAAK;","names":[]}
@@ -99,7 +99,8 @@ function pathData(segments, closed = false) {
99
99
 
100
100
  // src/core/geometry/walk.ts
101
101
  var clamp01 = (t) => t > 0 ? t < 1 ? t : 1 : 0;
102
- function createWalk(segments) {
102
+ var NONE = Object.freeze([]);
103
+ function createWalk(segments, gaps = NONE) {
103
104
  const first = segments[0];
104
105
  const last = segments[segments.length - 1];
105
106
  if (!first || !last) throw new RangeError("A walk needs at least one segment.");
@@ -131,40 +132,54 @@ function createWalk(segments) {
131
132
  const { index, u } = locate(at * length);
132
133
  return pointOn(segments[index], u);
133
134
  };
135
+ const draw = (from, to) => {
136
+ let d = moveTo(point(from));
137
+ const a = from * length;
138
+ const b = to * length;
139
+ if (!(b > a)) return d;
140
+ const first2 = locate(a);
141
+ for (let i = first2.index; i < segments.length && cumulative[i] < b; i++) {
142
+ const segment = segments[i];
143
+ if (!(segment.length > 0)) continue;
144
+ const u0 = i === first2.index ? first2.u : 0;
145
+ const u1 = cumulative[i + 1] > b ? Math.min(1, (b - cumulative[i]) / segment.length) : 1;
146
+ if (u1 > u0) d += drawTo(segment, u0, u1);
147
+ }
148
+ return d;
149
+ };
150
+ const slice = (t0, t1) => {
151
+ const from = clamp01(Math.min(t0, t1));
152
+ const to = clamp01(Math.max(t0, t1));
153
+ if (gaps.length === 0) return draw(from, to);
154
+ let d = "";
155
+ let at = from;
156
+ for (const [a, b] of gaps) {
157
+ if (a >= to) break;
158
+ if (a > at) d += draw(at, a);
159
+ if (b > at) at = b;
160
+ }
161
+ if (to > at) d += draw(at, to);
162
+ return d === "" ? moveTo(point(from)) : d;
163
+ };
134
164
  return {
135
165
  segments,
136
166
  length,
137
167
  start,
138
168
  end,
169
+ gaps,
139
170
  point,
140
171
  angle(t) {
141
172
  const { index, u } = locate(clamp01(t) * length);
142
173
  return angleOn(segments[index], u);
143
174
  },
144
- slice(t0, t1) {
145
- const from = clamp01(Math.min(t0, t1));
146
- const to = clamp01(Math.max(t0, t1));
147
- let d = moveTo(point(from));
148
- const a = from * length;
149
- const b = to * length;
150
- if (!(b > a)) return d;
151
- const first2 = locate(a);
152
- for (let i = first2.index; i < segments.length && cumulative[i] < b; i++) {
153
- const segment = segments[i];
154
- if (!(segment.length > 0)) continue;
155
- const u0 = i === first2.index ? first2.u : 0;
156
- const u1 = cumulative[i + 1] > b ? Math.min(1, (b - cumulative[i]) / segment.length) : 1;
157
- if (u1 > u0) d += drawTo(segment, u0, u1);
158
- }
159
- return d;
160
- },
161
- d: pathData(segments)
175
+ slice,
176
+ d: gaps.length === 0 ? pathData(segments) : slice(0, 1)
162
177
  };
163
178
  }
164
179
 
165
180
  // src/core/geometry/outline.ts
166
181
  function closedOutline(sides) {
167
- const walks = sides.map(createWalk);
182
+ const walks = sides.map((side) => createWalk(side));
168
183
  return {
169
184
  d: pathData(sides.flat(), true),
170
185
  closed: true,
@@ -210,6 +225,7 @@ function assemble({ key, series, walk, thickness, outline, bounds, center, pivot
210
225
  path: (t) => walk.point(t),
211
226
  angle: (t) => walk.angle(t),
212
227
  slice: (t0, t1) => walk.slice(t0, t1),
228
+ ...walk.gaps.length === 0 ? {} : { gaps: walk.gaps },
213
229
  thickness,
214
230
  outline,
215
231
  bounds,
@@ -365,12 +381,13 @@ function describeLine(spec) {
365
381
  finite("line", `points[${i}].x`, p.x);
366
382
  finite("line", `points[${i}].y`, p.y);
367
383
  });
384
+ const breaks = checkBreaks(spec.breaks, points.length);
368
385
  const segments = [];
369
386
  for (let i = 1; i < points.length; i++) {
370
387
  segments.push(line(points[i - 1], points[i], segments[segments.length - 1]?.angle ?? 0));
371
388
  }
372
389
  if (segments.length === 0) segments.push(line(first, first));
373
- const walk = createWalk(segments);
390
+ const walk = createWalk(segments, gapsAt(breaks, segments));
374
391
  const box = boundsOf(points);
375
392
  const pad = width / 2;
376
393
  return assemble({
@@ -385,6 +402,25 @@ function describeLine(spec) {
385
402
  labelBounds: labelBoxes("line", spec.labelBounds)
386
403
  });
387
404
  }
405
+ function gapsAt(breaks, segments) {
406
+ const along = [0];
407
+ for (const segment of segments) along.push(along[along.length - 1] + segment.length);
408
+ const length = along[along.length - 1];
409
+ return breaks.filter((i) => along[i] > along[i - 1]).map((i) => [along[i - 1] / length, along[i] / length]);
410
+ }
411
+ function checkBreaks(breaks, count) {
412
+ if (breaks === void 0) return [];
413
+ if (!Array.isArray(breaks)) throw new RangeError(`describe.line: breaks must be an array of point indices, got ${show(breaks)}.`);
414
+ let after = 0;
415
+ breaks.forEach((index, i) => {
416
+ if (!(Number.isInteger(index) && index > after && index < count)) {
417
+ throw new RangeError(`describe.line: breaks[${i}] must be a whole number more than ${after} and less than ${count}, the number of points, got ${show(index)}.`);
418
+ }
419
+ after = index;
420
+ });
421
+ return breaks;
422
+ }
423
+ var show = (value) => typeof value === "string" ? JSON.stringify(value) : String(value);
388
424
 
389
425
  // src/core/geometry/describe/point.ts
390
426
  function describePoint(spec) {
@@ -514,7 +550,18 @@ function samplesAlong(mark, points) {
514
550
  });
515
551
  const n = mark.length > 0 ? Math.min(MAX_GRID, Math.ceil(mark.length) + 1) : 1;
516
552
  const grid = Array.from({ length: n }, (_, i) => mark.path(n === 1 ? 0 : i / (n - 1)));
517
- return points.map((p, index) => ({ index, sample: { t: nearest(mark, grid, p), value: p.value, ...p.at === void 0 ? {} : { at: p.at } } })).sort((a, b) => a.sample.t - b.sample.t || a.index - b.index).map(({ sample }) => sample);
553
+ const samples = points.map((p, index) => ({ index, sample: { t: nearest(mark, grid, p), value: p.value, ...p.at === void 0 ? {} : { at: p.at } } })).sort((a, b) => a.sample.t - b.sample.t || a.index - b.index).map(({ sample }) => sample);
554
+ return mark.gaps && mark.gaps.length > 0 ? gapped(samples, mark.gaps) : samples;
555
+ }
556
+ function gapped(samples, gaps) {
557
+ const middles = gaps.map(([from, to]) => (from + to) / 2).sort((a, b) => a - b);
558
+ let next = 0;
559
+ return samples.map((sample, k) => {
560
+ if (k === 0) return sample;
561
+ const before = samples[k - 1].t;
562
+ while (next < middles.length && middles[next] <= before) next++;
563
+ return next < middles.length && middles[next] <= sample.t ? { ...sample, gapBefore: true } : sample;
564
+ });
518
565
  }
519
566
  function nearest(mark, grid, p) {
520
567
  const n = grid.length;
@@ -568,4 +615,4 @@ export {
568
615
  offset,
569
616
  samplesAlong
570
617
  };
571
- //# sourceMappingURL=chunk-V5IUTXRW.js.map
618
+ //# sourceMappingURL=chunk-CJUQHEX6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/geometry/segment.ts","../src/core/geometry/path-data.ts","../src/core/geometry/walk.ts","../src/core/geometry/outline.ts","../src/core/geometry/describe/mark.ts","../src/core/geometry/describe/arc.ts","../src/core/geometry/describe/bar.ts","../src/core/geometry/describe/line.ts","../src/core/geometry/describe/point.ts","../src/core/geometry/describe/index.ts","../src/core/geometry/matrix.ts","../src/core/geometry/samples.ts"],"sourcesContent":["// Path segments: straight lines and circular arcs, with exact lengths.\n//\n// Angles are screen angles: radians, 0 along +x, increasing clockwise on screen (y points down).\n// That is the convention of Math.atan2 in chart pixels, and of the walk's `angle(t)`.\n\nimport type { Point, Rect } from \"../contracts/geometry\";\n\nexport const TAU = 2 * Math.PI;\n\nexport interface LineSegment {\n readonly kind: \"line\";\n readonly from: Point;\n readonly to: Point;\n readonly length: number;\n /** Direction from `from` to `to`, or the fallback given to `line()` when they coincide. */\n readonly angle: number;\n}\n\nexport interface ArcSegment {\n readonly kind: \"arc\";\n readonly center: Point;\n readonly radius: number;\n /** Screen angle of the first point. */\n readonly start: number;\n /** Signed: positive is clockwise on screen. */\n readonly sweep: number;\n /** Exact: radius × |sweep|. */\n readonly length: number;\n}\n\nexport type PathSegment = LineSegment | ArcSegment;\n\n/** A straight segment. `fallbackAngle` is its direction if `from` and `to` coincide. */\nexport function line(from: Point, to: Point, fallbackAngle = 0): LineSegment {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const length = Math.hypot(dx, dy);\n return { kind: \"line\", from, to, length, angle: length > 0 ? Math.atan2(dy, dx) : normalizeAngle(fallbackAngle) };\n}\n\n/** A circular arc from screen angle `start`, turning `sweep` radians (positive = clockwise on screen). */\nexport function arc(center: Point, radius: number, start: number, sweep: number): ArcSegment {\n return { kind: \"arc\", center, radius, start, sweep, length: radius * Math.abs(sweep) };\n}\n\n/** The point a fraction `u` (0–1) of the way along the segment, by distance. Exact at both ends of a line. */\nexport function pointOn(segment: PathSegment, u: number): Point {\n if (segment.kind === \"line\") {\n const { from, to } = segment;\n return { x: from.x * (1 - u) + to.x * u, y: from.y * (1 - u) + to.y * u };\n }\n return polar(segment.center, segment.radius, segment.start + segment.sweep * u);\n}\n\n/** Direction of travel at fraction `u`, in (-PI, PI]. */\nexport function angleOn(segment: PathSegment, u: number): number {\n if (segment.kind === \"line\") return segment.angle;\n const quarter = segment.sweep < 0 ? -Math.PI / 2 : Math.PI / 2;\n return normalizeAngle(segment.start + segment.sweep * u + quarter);\n}\n\nexport function polar(center: Point, radius: number, angle: number): Point {\n return { x: center.x + radius * Math.cos(angle), y: center.y + radius * Math.sin(angle) };\n}\n\n/** The same angle in (-PI, PI]. */\nexport function normalizeAngle(angle: number): number {\n return angle - TAU * Math.ceil((angle - Math.PI) / TAU);\n}\n\n/** The points that bound a segment: its ends, plus an arc's extremes in x and y. */\nexport function extremes(segment: PathSegment): Point[] {\n if (segment.kind === \"line\") return [segment.from, segment.to];\n const points = [pointOn(segment, 0), pointOn(segment, 1)];\n for (let k = 0; k < 4; k++) {\n const angle = (k * Math.PI) / 2;\n if (sweeps(segment, angle)) points.push(polar(segment.center, segment.radius, angle));\n }\n return points;\n}\n\nexport function boundsOf(points: readonly Point[]): Rect {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const { x, y } of points) {\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/** True if the arc passes through screen angle `angle`. */\nfunction sweeps(segment: ArcSegment, angle: number): boolean {\n const extent = Math.abs(segment.sweep);\n if (extent >= TAU) return true;\n const turned = segment.sweep >= 0 ? angle - segment.start : segment.start - angle;\n return ((turned % TAU) + TAU) % TAU <= extent;\n}\n","// SVG path data for segments: M, L, A and Z only, with numbers rounded to 0.001 px.\n\nimport type { Point } from \"../contracts/geometry\";\nimport { pointOn, polar, type PathSegment } from \"./segment\";\n\n/** A coordinate for path data: rounded to 0.001, with no \"-0\". */\nexport function formatNumber(value: number): string {\n const rounded = Math.round(value * 1000) / 1000;\n return rounded === 0 ? \"0\" : String(rounded);\n}\n\nexport function moveTo(point: Point): string {\n return `M${formatNumber(point.x)},${formatNumber(point.y)}`;\n}\n\n/**\n * Commands that draw a segment from fraction `u0` to `u1` of its length, assuming the pen is already\n * at the `u0` point. Arcs are split into pieces of at most half a turn, so the large-arc flag is\n * always 0 and a full circle still draws.\n */\nexport function drawTo(segment: PathSegment, u0 = 0, u1 = 1): string {\n if (segment.kind === \"line\") {\n const p = u1 === 1 ? segment.to : pointOn(segment, u1);\n return `L${formatNumber(p.x)},${formatNumber(p.y)}`;\n }\n const from = segment.start + segment.sweep * u0;\n const turn = segment.sweep * (u1 - u0);\n const pieces = Math.max(1, Math.ceil(Math.abs(turn) / Math.PI - 1e-9));\n const r = formatNumber(segment.radius);\n const clockwise = turn >= 0 ? 1 : 0;\n let d = \"\";\n for (let i = 1; i <= pieces; i++) {\n const p = polar(segment.center, segment.radius, from + (turn * i) / pieces);\n d += `A${r},${r} 0 0 ${clockwise} ${formatNumber(p.x)},${formatNumber(p.y)}`;\n }\n return d;\n}\n\n/**\n * Path data for a run of connected segments. Zero-length segments draw nothing. A closed run ends\n * with Z, which also replaces a final straight segment back to the start.\n */\nexport function pathData(segments: readonly PathSegment[], closed = false): string {\n const first = segments[0];\n if (!first) return \"\";\n let count = segments.length;\n if (closed) {\n while (count > 0 && segments[count - 1]!.length <= 0) count--;\n if (count > 0 && segments[count - 1]!.kind === \"line\") count--;\n }\n let d = moveTo(pointOn(first, 0));\n for (let i = 0; i < count; i++) {\n const segment = segments[i]!;\n if (segment.length > 0) d += drawTo(segment);\n }\n return closed ? `${d}Z` : d;\n}\n","// A walk: connected segments parameterised by distance, so t = 0.5 is halfway along on screen. It can\n// have gaps, stretches with no data that its path data leaves out.\n\nimport type { Point } from \"../contracts/geometry\";\nimport { drawTo, moveTo, pathData } from \"./path-data\";\nimport { angleOn, pointOn, type PathSegment } from \"./segment\";\n\n/** Stretches of a walk with no data, as [from, to] values of t: in order, apart, each with 0 ≤ from < to ≤ 1. */\nexport type Gaps = readonly (readonly [from: number, to: number])[];\n\nexport interface Walk {\n readonly segments: readonly PathSegment[];\n readonly length: number;\n readonly start: Point;\n readonly end: Point;\n /** The stretches slice() and d leave out; empty when there are none. */\n readonly gaps: Gaps;\n /** t in [0, 1], proportional to distance. Values outside are clamped. */\n point(t: number): Point;\n /** Direction of travel in (-PI, PI]. At a joint, the segment ahead wins, except at t = 1. */\n angle(t: number): number;\n /**\n * Path data from t0 to t1, in either order. Just a move when they're equal. It leaves out the gaps:\n * each part between them starts with its own move, and a part with no length isn't written.\n */\n slice(t0: number, t1: number): string;\n /** Path data for the whole walk, less its gaps. */\n readonly d: string;\n}\n\nconst clamp01 = (t: number): number => (t > 0 ? (t < 1 ? t : 1) : 0);\nconst NONE: Gaps = Object.freeze([]);\n\n/** The segments must connect: each starts where the one before ends. The gaps are taken as given. */\nexport function createWalk(segments: readonly PathSegment[], gaps: Gaps = NONE): Walk {\n const first = segments[0];\n const last = segments[segments.length - 1];\n if (!first || !last) throw new RangeError(\"A walk needs at least one segment.\");\n\n // cumulative[i] is the distance to the start of segment i.\n const cumulative = [0];\n for (const segment of segments) cumulative.push(cumulative[cumulative.length - 1]! + segment.length);\n const length = cumulative[segments.length]!;\n const start = pointOn(first, 0);\n const end = pointOn(last, 1);\n\n // The segment at distance d, and the fraction along it. Zero-length segments are never picked\n // unless the whole walk has zero length.\n const locate = (d: number): { readonly index: number; readonly u: number } => {\n if (!(length > 0)) return { index: 0, u: 0 };\n if (d >= length) {\n let index = segments.length - 1;\n while (index > 0 && !(segments[index]!.length > 0)) index--;\n return { index, u: 1 };\n }\n // The first segment that ends beyond d.\n let lo = 0;\n let hi = segments.length - 1;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (cumulative[mid + 1]! > d) hi = mid;\n else lo = mid + 1;\n }\n return { index: lo, u: Math.min(1, (d - cumulative[lo]!) / segments[lo]!.length) };\n };\n\n const point = (t: number): Point => {\n const at = clamp01(t);\n if (at === 0) return start;\n if (at === 1) return end;\n const { index, u } = locate(at * length);\n return pointOn(segments[index]!, u);\n };\n\n /** Path data from t `from` to `to` (from ≤ to, both in [0, 1]), gaps and all. */\n const draw = (from: number, to: number): string => {\n let d = moveTo(point(from));\n const a = from * length;\n const b = to * length;\n if (!(b > a)) return d;\n const first = locate(a);\n for (let i = first.index; i < segments.length && cumulative[i]! < b; i++) {\n const segment = segments[i]!;\n if (!(segment.length > 0)) continue;\n const u0 = i === first.index ? first.u : 0;\n const u1 = cumulative[i + 1]! > b ? Math.min(1, (b - cumulative[i]!) / segment.length) : 1;\n if (u1 > u0) d += drawTo(segment, u0, u1);\n }\n return d;\n };\n\n const slice = (t0: number, t1: number): string => {\n const from = clamp01(Math.min(t0, t1));\n const to = clamp01(Math.max(t0, t1));\n if (gaps.length === 0) return draw(from, to);\n // The parts between the gaps, each drawn from its own move. All in a gap: a move where it starts.\n let d = \"\";\n let at = from;\n for (const [a, b] of gaps) {\n if (a >= to) break;\n if (a > at) d += draw(at, a);\n if (b > at) at = b;\n }\n if (to > at) d += draw(at, to);\n return d === \"\" ? moveTo(point(from)) : d;\n };\n\n return {\n segments,\n length,\n start,\n end,\n gaps,\n point,\n angle(t) {\n const { index, u } = locate(clamp01(t) * length);\n return angleOn(segments[index]!, u);\n },\n slice,\n d: gaps.length === 0 ? pathData(segments) : slice(0, 1)\n };\n}\n","// Outlines with canonical sampling, so morph can match corners and winding between any two marks.\n\nimport type { Outline, Point } from \"../contracts/geometry\";\nimport { pathData } from \"./path-data\";\nimport type { PathSegment } from \"./segment\";\nimport { createWalk, type Walk } from \"./walk\";\n\n/** The four sides of a closed outline, in order. Each must start where the one before ends. */\nexport type Sides = readonly [\n left: readonly PathSegment[],\n end: readonly PathSegment[],\n right: readonly PathSegment[],\n start: readonly PathSegment[]\n];\n\n/**\n * A closed outline from its sides: left (the up side, walked in the direction of travel), end,\n * right (walked back) and start. That order runs clockwise on screen from the start-left corner.\n */\nexport function closedOutline(sides: Sides): Outline {\n const walks = sides.map((side) => createWalk(side));\n return {\n d: pathData(sides.flat(), true),\n closed: true,\n sample(n) {\n checkCount(n, 4);\n const perSide = n / 4;\n const points: Point[] = [];\n for (const walk of walks) {\n for (let j = 0; j < perSide; j++) points.push(walk.point(j / perSide));\n }\n return points;\n }\n };\n}\n\n/** An open outline: the stroke along a walk, less its gaps. Its samples run along the whole walk, gaps and all. */\nexport function openOutline(walk: Walk): Outline {\n return {\n d: walk.d,\n closed: false,\n sample(n) {\n checkCount(n, 1);\n if (n === 1) return [walk.start];\n const points: Point[] = [];\n for (let j = 0; j < n; j++) points.push(walk.point(j / (n - 1)));\n return points;\n }\n };\n}\n\nfunction checkCount(n: number, multiple: number): void {\n if (!Number.isInteger(n) || n < 0 || n % multiple !== 0) {\n const what = multiple === 1 ? \"a whole number ≥ 0\" : `a whole multiple of ${multiple}`;\n throw new RangeError(`outline.sample(n): n must be ${what}, got ${n}.`);\n }\n}\n","// Shared by the builders: assembling a MarkGeometry from a walk and a body, and checking input.\n\nimport type { MarkGeometry, Outline, Point, Rect } from \"../../contracts/geometry\";\nimport type { Walk } from \"../walk\";\n\nexport interface MarkParts {\n readonly key: string;\n readonly series?: string | undefined;\n readonly walk: Walk;\n readonly thickness: number;\n readonly outline: Outline;\n readonly bounds: Rect;\n readonly center: Point;\n readonly pivot: Point;\n readonly labelBounds?: readonly Rect[] | undefined;\n readonly segments?: readonly MarkGeometry[];\n}\n\nexport function assemble({ key, series, walk, thickness, outline, bounds, center, pivot, labelBounds, segments }: MarkParts): MarkGeometry {\n return {\n key,\n ...(series === undefined ? {} : { series }),\n start: walk.start,\n end: walk.end,\n length: walk.length,\n path: (t) => walk.point(t),\n angle: (t) => walk.angle(t),\n slice: (t0, t1) => walk.slice(t0, t1),\n ...(walk.gaps.length === 0 ? {} : { gaps: walk.gaps }),\n thickness,\n outline,\n bounds,\n center,\n pivot,\n ...(labelBounds === undefined ? {} : { labelBounds }),\n ...(segments === undefined ? {} : { segments })\n };\n}\n\n/** Throws a RangeError naming the builder and field unless `value` is a finite number. */\nexport function finite(builder: string, field: string, value: number): number {\n if (!Number.isFinite(value)) throw new RangeError(`describe.${builder}: ${field} must be a finite number, got ${value}.`);\n return value;\n}\n\n/** A spec's `labelBounds`, checked: each box's numbers finite, its sizes ≥ 0. Charts give them every frame, so a good box costs four comparisons. */\nexport function labelBoxes(builder: string, boxes: readonly Rect[] | undefined): readonly Rect[] | undefined {\n if (!boxes) return boxes;\n for (let i = 0; i < boxes.length; i++) {\n const { x, y, width, height } = boxes[i]!;\n if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(width) && width >= 0 && Number.isFinite(height) && height >= 0) continue;\n finite(builder, `labelBounds[${i}].x`, x);\n finite(builder, `labelBounds[${i}].y`, y);\n size(builder, `labelBounds[${i}].width`, width);\n size(builder, `labelBounds[${i}].height`, height);\n }\n return boxes;\n}\n\n/** Throws a RangeError unless `value` is a finite number ≥ 0. */\nexport function size(builder: string, field: string, value: number): number {\n if (!(Number.isFinite(value) && value >= 0)) {\n throw new RangeError(`describe.${builder}: ${field} must be a finite number ≥ 0, got ${value}.`);\n }\n return value;\n}\n","// describe.arc: donut and pie slices, in d3.pie()'s angle convention.\n\nimport type { MarkGeometry, Rect } from \"../../contracts/geometry\";\nimport { closedOutline } from \"../outline\";\nimport { arc, boundsOf, extremes, line, polar, TAU } from \"../segment\";\nimport { createWalk } from \"../walk\";\nimport { assemble, finite, labelBoxes, size } from \"./mark\";\n\nexport interface ArcSpec {\n readonly key: string;\n readonly series?: string;\n /** The donut's centre. */\n readonly cx: number;\n readonly cy: number;\n /** Radii in px; 0 inner makes a pie slice. They're swapped if inner > outer, as d3.arc() does. */\n readonly inner: number;\n readonly outer: number;\n /** Radians, 0 at 12 o'clock, clockwise: the d3.pie() convention. end < start walks anticlockwise. */\n readonly start: number;\n readonly end: number;\n /** The boxes of the text drawn for the mark, in the same px: passed through as `labelBounds`. */\n readonly labelBounds?: readonly Rect[];\n}\n\n/**\n * The walk runs along the mid-radius arc from the start angle to the end angle, so for a slice\n * walked clockwise \"up\" is outward. The angle of travel equals the d3 angle (normalised).\n */\nexport function describeArc(spec: ArcSpec): MarkGeometry {\n const { key, series } = spec;\n const center = { x: finite(\"arc\", \"cx\", spec.cx), y: finite(\"arc\", \"cy\", spec.cy) };\n const r0 = Math.min(size(\"arc\", \"inner\", spec.inner), size(\"arc\", \"outer\", spec.outer));\n const r1 = Math.max(spec.inner, spec.outer);\n finite(\"arc\", \"start\", spec.start);\n finite(\"arc\", \"end\", spec.end);\n // More than a full turn draws the same ring, as with d3.arc().\n const sweep = Math.max(-TAU, Math.min(TAU, spec.end - spec.start));\n // d3 measures from 12 o'clock; screen angles from 3 o'clock.\n const from = spec.start - Math.PI / 2;\n const to = from + sweep;\n\n // The up side is outward when walking clockwise, inward when walking anticlockwise.\n const [left, right] = sweep >= 0 ? [r1, r0] : [r0, r1];\n const sides = [\n [arc(center, left, from, sweep)],\n [line(polar(center, left, to), polar(center, right, to), to + (left > right ? Math.PI : 0))],\n [arc(center, right, to, -sweep)],\n [line(polar(center, right, from), polar(center, left, from), from + (left > right ? 0 : Math.PI))]\n ] as const;\n\n const walk = createWalk([arc(center, (r0 + r1) / 2, from, sweep)]);\n return assemble({\n key,\n series,\n walk,\n thickness: r1 - r0,\n outline: closedOutline(sides),\n bounds: boundsOf(sides.flat().flatMap(extremes)),\n center: walk.point(0.5),\n pivot: center,\n labelBounds: labelBoxes(\"arc\", spec.labelBounds)\n });\n}\n","// describe.bar: horizontal bars and vertical columns, plain or stacked, with an optional rounded tip.\n\nimport type { MarkGeometry, Point, Rect } from \"../../contracts/geometry\";\nimport { closedOutline } from \"../outline\";\nimport { arc, boundsOf, line } from \"../segment\";\nimport { createWalk } from \"../walk\";\nimport { assemble, finite, labelBoxes, size } from \"./mark\";\n\n/** The edge a bar grows from. */\nexport type Baseline = \"left\" | \"right\" | \"top\" | \"bottom\";\n\nexport interface BarSegmentSpec {\n readonly series: string;\n /** Px along the walk, gap included. */\n readonly size: number;\n}\n\nexport interface BarSpec {\n readonly key: string;\n readonly series?: string;\n /** The whole bar's rectangle, in chart px. */\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly baseline: Baseline;\n /** Corner radius at the tip. The baseline end stays square. Default 0. */\n readonly radius?: number;\n /**\n * Ordered parts, from the baseline. Default: one segment named after `series`, covering the bar.\n * Sizes normally add up to the bar's length; anything past the tip is cut off.\n */\n readonly segments?: readonly BarSegmentSpec[];\n /**\n * Px left empty between segments (the prototype uses 2). It comes out of the start of the later\n * segment, so every segment still ends at its value, and it shrinks to fit when what comes\n * before is shorter. Default 0.\n */\n readonly gap?: number;\n /** The boxes of the text drawn for the bar, its segments having none, in the same px: passed through as `labelBounds`. */\n readonly labelBounds?: readonly Rect[];\n}\n\nconst ANGLE: Readonly<Record<Baseline, number>> = { left: 0, right: Math.PI, top: Math.PI / 2, bottom: -Math.PI / 2 };\n\n/**\n * The walk runs along the centre line from the middle of the baseline edge to the middle of the\n * tip. A plain bar has one segment, so `travel(…, { along: \"goals\" })` works stacked or not.\n */\nexport function describeBar(spec: BarSpec): MarkGeometry {\n const { key, series, baseline, x, y, width, height } = spec;\n if (!Object.prototype.hasOwnProperty.call(ANGLE, baseline)) {\n throw new RangeError(`describe.bar: baseline must be left, right, top or bottom, got ${String(baseline)}.`);\n }\n finite(\"bar\", \"x\", x);\n finite(\"bar\", \"y\", y);\n size(\"bar\", \"width\", width);\n size(\"bar\", \"height\", height);\n const radius = size(\"bar\", \"radius\", spec.radius ?? 0);\n const gap = size(\"bar\", \"gap\", spec.gap ?? 0);\n const labelBounds = labelBoxes(\"bar\", spec.labelBounds);\n\n const horizontal = baseline === \"left\" || baseline === \"right\";\n const length = horizontal ? width : height;\n const thickness = horizontal ? height : width;\n const T = thickness;\n const angle = ANGLE[baseline];\n const at = frame(spec);\n\n // The bar or segment covering [p0, p1] along the walk. The tip is rounded by up to `tip` px.\n const part = (\n p0: number,\n p1: number,\n tip: number,\n rest: { key: string; series: string | undefined; bounds?: Rect; labelBounds?: readonly Rect[] | undefined; segments?: readonly MarkGeometry[] }\n ): MarkGeometry => {\n const rr = Math.max(0, Math.min(tip, p1 - p0, T / 2));\n const outline = closedOutline([\n [line(at(p0, 0), at(p1 - rr, 0), angle)],\n rr > 0\n ? [\n arc(at(p1 - rr, rr), rr, angle - Math.PI / 2, Math.PI / 2),\n line(at(p1, rr), at(p1, T - rr), angle + Math.PI / 2),\n arc(at(p1 - rr, T - rr), rr, angle, Math.PI / 2)\n ]\n : [line(at(p1, 0), at(p1, T), angle + Math.PI / 2)],\n [line(at(p1 - rr, T), at(p0, T), angle + Math.PI)],\n [line(at(p0, T), at(p0, 0), angle - Math.PI / 2)]\n ]);\n const walk = createWalk([line(at(p0, T / 2), at(p1, T / 2), angle)]);\n return assemble({\n ...rest,\n walk,\n thickness,\n outline,\n bounds: rest.bounds ?? boundsOf([at(p0, 0), at(p1, T)]),\n center: at((p0 + p1) / 2, T / 2),\n pivot: walk.start\n });\n };\n\n const specs: readonly { readonly series?: string | undefined; readonly size: number }[] = spec.segments ?? [{ series, size: length }];\n const seen = new Set<string>();\n let cursor = 0;\n const spans = specs.map((segment, index) => {\n size(\"bar\", `segments[${index}].size`, segment.size);\n if (segment.series !== undefined) {\n if (seen.has(segment.series)) throw new Error(`describe.bar: series \"${segment.series}\" appears twice in the segments of \"${key}\".`);\n seen.add(segment.series);\n }\n const from = Math.min(cursor, length);\n cursor += segment.size;\n const to = Math.min(cursor, length);\n return { segment, index, p0: Math.min(from + Math.min(gap, from), to), p1: to };\n });\n\n const segments = spans.map(({ segment, index, p0, p1 }) =>\n // The rounding fades in as a segment nears the tip, so a growing stack never pops.\n part(p0, p1, radius - (length - p1), {\n key: segment.series === undefined ? `${key}/${index}` : `${key}/${segment.series}`,\n series: segment.series\n })\n );\n // The whole bar keeps the exact rectangle it was given.\n return part(0, length, radius, { key, series, bounds: { x, y, width, height }, labelBounds, segments });\n}\n\n/** Chart px at distance p along the walk and s across it, measured from the left (up) edge. */\nfunction frame({ x, y, width: w, height: h, baseline }: BarSpec): (p: number, s: number) => Point {\n switch (baseline) {\n case \"left\":\n return (p, s) => ({ x: x + p, y: y + s });\n case \"right\":\n return (p, s) => ({ x: x + w - p, y: y + h - s });\n case \"top\":\n return (p, s) => ({ x: x + w - s, y: y + p });\n case \"bottom\":\n return (p, s) => ({ x: x + s, y: y + h - p });\n }\n}\n","// describe.line: a straight-segment polyline, as d3.line() draws with its default curve, with gaps\n// where a run of points ends and the next begins.\n\nimport type { MarkGeometry, Point, Rect } from \"../../contracts/geometry\";\nimport { openOutline } from \"../outline\";\nimport { boundsOf, line, type LineSegment } from \"../segment\";\nimport { createWalk, type Gaps } from \"../walk\";\nimport { assemble, finite, labelBoxes, size } from \"./mark\";\n\nexport interface LineSpec {\n readonly key: string;\n readonly series?: string;\n /** At least one point, in chart px. */\n readonly points: readonly Point[];\n /**\n * The indices of the points that start a new run, so there's a gap from `points[i - 1]` to\n * `points[i]`: each a whole number from 1 to the last index, in order, with no repeats. A line\n * drawn with d3's `.defined()` is described by its defined points and where they break. Default none.\n */\n readonly breaks?: readonly number[];\n /** Stroke width in px. Default 1, SVG's default. */\n readonly width?: number;\n /** The boxes of the text drawn for the mark, in the same px: passed through as `labelBounds`. */\n readonly labelBounds?: readonly Rect[];\n}\n\n/**\n * The walk is the line itself, first point to last, running straight across each break. Its outline\n * is open: the stroke, with the breaks left out. A break between two points in the same place leaves\n * no gap, since there's nothing between them to leave out.\n */\nexport function describeLine(spec: LineSpec): MarkGeometry {\n const { key, series, points } = spec;\n const width = size(\"line\", \"width\", spec.width ?? 1);\n const first = points[0];\n if (!first) throw new RangeError(`describe.line: \"${key}\" needs at least one point.`);\n points.forEach((p, i) => {\n finite(\"line\", `points[${i}].x`, p.x);\n finite(\"line\", `points[${i}].y`, p.y);\n });\n const breaks = checkBreaks(spec.breaks, points.length);\n\n const segments: LineSegment[] = [];\n for (let i = 1; i < points.length; i++) {\n // A repeated point keeps the direction so far.\n segments.push(line(points[i - 1]!, points[i]!, segments[segments.length - 1]?.angle ?? 0));\n }\n if (segments.length === 0) segments.push(line(first, first));\n\n const walk = createWalk(segments, gapsAt(breaks, segments));\n const box = boundsOf(points);\n const pad = width / 2;\n return assemble({\n key,\n series,\n walk,\n thickness: width,\n outline: openOutline(walk),\n bounds: { x: box.x - pad, y: box.y - pad, width: box.width + width, height: box.height + width },\n center: walk.point(0.5),\n pivot: first,\n labelBounds: labelBoxes(\"line\", spec.labelBounds)\n });\n}\n\n/** The walk's gaps, in t: from the point before each break to the point at it, where they're apart. */\nfunction gapsAt(breaks: readonly number[], segments: readonly LineSegment[]): Gaps {\n // The distance to each point, summed as createWalk sums it, so the last point is at t = 1 exactly.\n const along = [0];\n for (const segment of segments) along.push(along[along.length - 1]! + segment.length);\n const length = along[along.length - 1]!;\n return breaks.filter((i) => along[i]! > along[i - 1]!).map((i) => [along[i - 1]! / length, along[i]! / length]);\n}\n\n/** `breaks`, checked: whole numbers from 1 to the last index, in order, with no repeats. */\nfunction checkBreaks(breaks: readonly number[] | undefined, count: number): readonly number[] {\n if (breaks === undefined) return [];\n if (!Array.isArray(breaks)) throw new RangeError(`describe.line: breaks must be an array of point indices, got ${show(breaks)}.`);\n let after = 0;\n breaks.forEach((index: unknown, i) => {\n if (!(Number.isInteger(index) && (index as number) > after && (index as number) < count)) {\n throw new RangeError(`describe.line: breaks[${i}] must be a whole number more than ${after} and less than ${count}, the number of points, got ${show(index)}.`);\n }\n after = index as number;\n });\n return breaks;\n}\n\nconst show = (value: unknown): string => (typeof value === \"string\" ? JSON.stringify(value) : String(value));\n","// describe.point: a dot with no direction (a scatter point or a marker).\n\nimport type { MarkGeometry, Rect } from \"../../contracts/geometry\";\nimport { closedOutline } from \"../outline\";\nimport { arc, line } from \"../segment\";\nimport { createWalk } from \"../walk\";\nimport { assemble, finite, labelBoxes, size } from \"./mark\";\n\nexport interface PointSpec {\n readonly key: string;\n readonly series?: string;\n readonly x: number;\n readonly y: number;\n /** Radius in px. */\n readonly r: number;\n /** The boxes of the text drawn for the mark, in the same px: passed through as `labelBounds`. */\n readonly labelBounds?: readonly Rect[];\n}\n\n/**\n * Length 0, with start = end = centre, so travel does nothing while wiggle, pulse and flash still\n * work. Faces +x: the outline's sides are the quarter circles top, right, bottom and left.\n */\nexport function describePoint(spec: PointSpec): MarkGeometry {\n const { key, series } = spec;\n const center = { x: finite(\"point\", \"x\", spec.x), y: finite(\"point\", \"y\", spec.y) };\n const r = size(\"point\", \"r\", spec.r);\n const quarter = Math.PI / 2;\n return assemble({\n key,\n series,\n walk: createWalk([line(center, center)]),\n thickness: 2 * r,\n outline: closedOutline([\n [arc(center, r, (-3 * quarter) / 2, quarter)],\n [arc(center, r, -quarter / 2, quarter)],\n [arc(center, r, quarter / 2, quarter)],\n [arc(center, r, (3 * quarter) / 2, quarter)]\n ]),\n bounds: { x: center.x - r, y: center.y - r, width: 2 * r, height: 2 * r },\n center,\n pivot: center,\n labelBounds: labelBoxes(\"point\", spec.labelBounds)\n });\n}\n","// The public geometry builders. Reference charts and adapters share these, so a bar is described\n// the same way whoever drew it.\n\nimport { describeArc } from \"./arc\";\nimport { describeBar } from \"./bar\";\nimport { describeLine } from \"./line\";\nimport { describePoint } from \"./point\";\n\nexport const describe = {\n bar: describeBar,\n arc: describeArc,\n line: describeLine,\n point: describePoint\n};\n\nexport type { ArcSpec } from \"./arc\";\nexport type { BarSegmentSpec, BarSpec, Baseline } from \"./bar\";\nexport type { LineSpec } from \"./line\";\nexport type { PointSpec } from \"./point\";\n","// Transform helpers for effect authors: matrix and offset are public (docs/effects-guide.md).\n\nimport type { Matrix } from \"../contracts/drawing\";\nimport type { Point } from \"../contracts/geometry\";\n\nfunction translate(x: number, y: number): Matrix {\n return [1, 0, 0, 1, x, y];\n}\n\n/** Positive radians turn clockwise on screen, like SVG's rotate(). */\nfunction rotate(radians: number, about?: Point): Matrix {\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n return around([cos, sin, -sin, cos, 0, 0], about);\n}\n\nfunction scale(sx: number, sy: number = sx, about?: Point): Matrix {\n return around([sx, 0, 0, sy, 0, 0], about);\n}\n\n/** Composes like an SVG transform list: multiply(a, b) applies b first, then a. No arguments gives the identity. */\nfunction multiply(...matrices: Matrix[]): Matrix {\n let result: Matrix = [1, 0, 0, 1, 0, 0];\n for (const m of matrices) result = product(result, m);\n return result;\n}\n\n/** Where the transform takes a point. */\nfunction apply(m: Matrix, point: Point): Point {\n const [a, b, c, d, e, f] = m;\n return { x: a * point.x + c * point.y + e, y: b * point.x + d * point.y + f };\n}\n\nfunction product(l: Matrix, r: Matrix): Matrix {\n const [a1, b1, c1, d1, e1, f1] = l;\n const [a2, b2, c2, d2, e2, f2] = r;\n return [\n a1 * a2 + c1 * b2,\n b1 * a2 + d1 * b2,\n a1 * c2 + c1 * d2,\n b1 * c2 + d1 * d2,\n a1 * e2 + c1 * f2 + e1,\n b1 * e2 + d1 * f2 + f1\n ];\n}\n\n/** A linear transform (no translation) moved so it keeps `about` fixed. */\nfunction around(m: Matrix, about: Point | undefined): Matrix {\n if (!about) return m;\n const [a, b, c, d] = m;\n return [a, b, c, d, about.x - a * about.x - c * about.y, about.y - b * about.x - d * about.y];\n}\n\n/** Builds and applies 2D transforms in SVG order, for `mark.set({ transform })` and `IconHandle.place()`. */\nexport const matrix = { translate, rotate, scale, multiply, apply };\n\n// Internal: iconFromSvg and the adapter read SVG transforms with these.\n\n/** The inverse transform. A singular matrix (it squashes everything onto a line) throws a RangeError. */\nexport function invert(m: Matrix): Matrix {\n const [a, b, c, d, e, f] = m;\n const det = a * d - b * c;\n if (!Number.isFinite(det) || Math.abs(det) < 1e-12) throw new RangeError(\"This transform can't be inverted: it has no area.\");\n return [d / det, -b / det, -c / det, a / det, (c * f - d * e) / det, (b * e - a * f) / det];\n}\n\n/** An SVG transform list, as in the transform attribute. An unknown or malformed function is skipped. */\nexport function parseTransform(source: string): Matrix {\n const parts: Matrix[] = [];\n for (const [, name, rawArgs = \"\"] of source.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\\s*\\(([^)]*)\\)/g)) {\n const args = rawArgs.trim().split(/[\\s,]+/).filter(Boolean).map(Number);\n if (!args.every(Number.isFinite)) continue;\n const [a = 0, b, c, d = 0, e = 0, f = 0] = args;\n const radians = (degrees: number): number => (degrees * Math.PI) / 180;\n switch (name) {\n case \"matrix\":\n if (args.length === 6) parts.push([a, b!, c!, d, e, f]);\n break;\n case \"translate\":\n parts.push(translate(a, b ?? 0));\n break;\n case \"scale\":\n parts.push(scale(a, b ?? a));\n break;\n case \"rotate\":\n parts.push(rotate(radians(a), b !== undefined && c !== undefined ? { x: b, y: c } : undefined));\n break;\n case \"skewX\":\n parts.push([1, 0, Math.tan(radians(a)), 1, 0, 0]);\n break;\n case \"skewY\":\n parts.push([1, Math.tan(radians(a)), 0, 1, 0, 0]);\n break;\n }\n }\n return multiply(...parts);\n}\n\n/** A point `distance` px from `point` in direction `angle` (screen radians). */\nexport function offset(point: Point, angle: number, distance: number): Point {\n return { x: point.x + distance * Math.cos(angle), y: point.y + distance * Math.sin(angle) };\n}\n","// samplesAlong: data points placed on a mark's walk, as data effects' samples. A page gives a host's\n// line its values this way: the points that drew it, projected onto the walk that describes it.\n// It reads only the MarkGeometry contract (path and length), so it works on any mark.\n\nimport type { Sample } from \"../contracts/data\";\nimport type { MarkGeometry, Point } from \"../contracts/geometry\";\n\n/** A data point in the mark's coordinates, with its value and, optionally, the x value behind it. */\nexport interface SamplePoint {\n readonly x: number;\n readonly y: number;\n readonly value: number;\n readonly at?: string | number | Date;\n}\n\n/** The grid that finds each point's nearest stretch of the walk: a point every px, up to this many. */\nconst MAX_GRID = 4096;\n/**\n * Golden-section steps that narrow a stretch of 2 grid steps down: to about 1e-12 px for a point on\n * the walk, and to well under 1e-6 px for one off it, where the nearest point is a flat minimum.\n */\nconst REFINE = 48;\nconst GOLDEN = (Math.sqrt(5) - 1) / 2;\n\n/**\n * Projects each point onto the nearest point of the mark's walk and returns the samples in `t` order\n * (points at the same `t` keep their order). A point on the walk, such as a vertex of the polyline it\n * drew, lands exactly where it is. Where the mark has gaps, the first sample past each gap's middle\n * has `gapBefore`, so a data effect doesn't join it to the one before. Throws a RangeError on a point\n * whose x, y or value isn't finite.\n */\nexport function samplesAlong(mark: MarkGeometry, points: readonly SamplePoint[]): Sample[] {\n if (typeof mark !== \"object\" || mark === null || typeof mark.path !== \"function\" || !Number.isFinite(mark.length)) {\n throw new TypeError(\"samplesAlong needs a MarkGeometry, as describe builds it.\");\n }\n if (!Array.isArray(points)) throw new TypeError(\"samplesAlong needs an array of points { x, y, value, at? }.\");\n points.forEach((p, i) => {\n for (const field of [\"x\", \"y\", \"value\"] as const) {\n const value: unknown = (p as Partial<SamplePoint> | null)?.[field];\n if (typeof value !== \"number\" || !Number.isFinite(value)) throw new RangeError(`samplesAlong: points[${i}].${field} must be a finite number, got ${String(value)}.`);\n }\n });\n\n const n = mark.length > 0 ? Math.min(MAX_GRID, Math.ceil(mark.length) + 1) : 1;\n const grid = Array.from({ length: n }, (_, i): Point => mark.path(n === 1 ? 0 : i / (n - 1)));\n const samples = points\n .map((p, index) => ({ index, sample: { t: nearest(mark, grid, p), value: p.value, ...(p.at === undefined ? {} : { at: p.at }) } }))\n .sort((a, b) => a.sample.t - b.sample.t || a.index - b.index)\n .map(({ sample }): Sample => sample);\n return mark.gaps && mark.gaps.length > 0 ? gapped(samples, mark.gaps) : samples;\n}\n\n/**\n * The samples with `gapBefore` on each that a gap's middle lies before, past the sample before it. A\n * gap's ends are values, so samples there project to within float noise of them, either side: its\n * middle is far from both.\n */\nfunction gapped(samples: readonly Sample[], gaps: NonNullable<MarkGeometry[\"gaps\"]>): Sample[] {\n const middles = gaps.map(([from, to]) => (from + to) / 2).sort((a, b) => a - b);\n let next = 0;\n return samples.map((sample, k) => {\n if (k === 0) return sample;\n const before = samples[k - 1]!.t;\n while (next < middles.length && middles[next]! <= before) next++;\n return next < middles.length && middles[next]! <= sample.t ? { ...sample, gapBefore: true } : sample;\n });\n}\n\n/** The t of the walk's nearest point to `p`: the nearest grid point, then a golden-section search on the stretch either side of it. */\nfunction nearest(mark: MarkGeometry, grid: readonly Point[], p: Point): number {\n const n = grid.length;\n if (n === 1) return 0;\n let best = 0;\n let bestDistance = Infinity;\n grid.forEach((q, i) => {\n const d = squared(q, p);\n if (d < bestDistance) {\n best = i;\n bestDistance = d;\n }\n });\n const f = (t: number): number => squared(mark.path(t), p);\n let lo = Math.max(0, best - 1) / (n - 1);\n let hi = Math.min(n - 1, best + 1) / (n - 1);\n let a = hi - GOLDEN * (hi - lo);\n let b = lo + GOLDEN * (hi - lo);\n let fa = f(a);\n let fb = f(b);\n for (let step = 0; step < REFINE; step++) {\n if (fa <= fb) {\n hi = b;\n b = a;\n fb = fa;\n a = hi - GOLDEN * (hi - lo);\n fa = f(a);\n } else {\n lo = a;\n a = b;\n fa = fb;\n b = lo + GOLDEN * (hi - lo);\n fb = f(b);\n }\n }\n const t = (lo + hi) / 2;\n // The grid point itself unless the search found somewhere nearer, so a point at either end lands\n // on exactly 0 or 1, and a stretch that isn't one dip can't make it worse.\n const found = f(t) < bestDistance ? t : best / (n - 1);\n return found > 0 ? (found < 1 ? found : 1) : 0;\n}\n\nfunction squared(a: Point, b: Point): number {\n return (a.x - b.x) ** 2 + (a.y - b.y) ** 2;\n}\n"],"mappings":";AAOO,IAAM,MAAM,IAAI,KAAK;AA0BrB,SAAS,KAAK,MAAa,IAAW,gBAAgB,GAAgB;AAC3E,QAAM,KAAK,GAAG,IAAI,KAAK;AACvB,QAAM,KAAK,GAAG,IAAI,KAAK;AACvB,QAAM,SAAS,KAAK,MAAM,IAAI,EAAE;AAChC,SAAO,EAAE,MAAM,QAAQ,MAAM,IAAI,QAAQ,OAAO,SAAS,IAAI,KAAK,MAAM,IAAI,EAAE,IAAI,eAAe,aAAa,EAAE;AAClH;AAGO,SAAS,IAAI,QAAe,QAAgB,OAAe,OAA2B;AAC3F,SAAO,EAAE,MAAM,OAAO,QAAQ,QAAQ,OAAO,OAAO,QAAQ,SAAS,KAAK,IAAI,KAAK,EAAE;AACvF;AAGO,SAAS,QAAQ,SAAsB,GAAkB;AAC9D,MAAI,QAAQ,SAAS,QAAQ;AAC3B,UAAM,EAAE,MAAM,GAAG,IAAI;AACrB,WAAO,EAAE,GAAG,KAAK,KAAK,IAAI,KAAK,GAAG,IAAI,GAAG,GAAG,KAAK,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE;AAAA,EAC1E;AACA,SAAO,MAAM,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,CAAC;AAChF;AAGO,SAAS,QAAQ,SAAsB,GAAmB;AAC/D,MAAI,QAAQ,SAAS,OAAQ,QAAO,QAAQ;AAC5C,QAAM,UAAU,QAAQ,QAAQ,IAAI,CAAC,KAAK,KAAK,IAAI,KAAK,KAAK;AAC7D,SAAO,eAAe,QAAQ,QAAQ,QAAQ,QAAQ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IAAI,KAAK;AACf,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,eAAe;AACnB,OAAK,QAAQ,CAAC,GAAG,MAAM;AACrB,UAAM,IAAI,QAAQ,GAAG,CAAC;AACtB,QAAI,IAAI,cAAc;AACpB,aAAO;AACP,qBAAe;AAAA,IACjB;AAAA,EACF,CAAC;AACD,QAAM,IAAI,CAACC,OAAsB,QAAQ,KAAK,KAAKA,EAAC,GAAG,CAAC;AACxD,MAAI,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,KAAK,IAAI;AACtC,MAAI,KAAK,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,KAAK,IAAI;AAC1C,MAAI,IAAI,KAAK,UAAU,KAAK;AAC5B,MAAI,IAAI,KAAK,UAAU,KAAK;AAC5B,MAAI,KAAK,EAAE,CAAC;AACZ,MAAI,KAAK,EAAE,CAAC;AACZ,WAAS,OAAO,GAAG,OAAO,QAAQ,QAAQ;AACxC,QAAI,MAAM,IAAI;AACZ,WAAK;AACL,UAAI;AACJ,WAAK;AACL,UAAI,KAAK,UAAU,KAAK;AACxB,WAAK,EAAE,CAAC;AAAA,IACV,OAAO;AACL,WAAK;AACL,UAAI;AACJ,WAAK;AACL,UAAI,KAAK,UAAU,KAAK;AACxB,WAAK,EAAE,CAAC;AAAA,IACV;AAAA,EACF;AACA,QAAM,KAAK,KAAK,MAAM;AAGtB,QAAM,QAAQ,EAAE,CAAC,IAAI,eAAe,IAAI,QAAQ,IAAI;AACpD,SAAO,QAAQ,IAAK,QAAQ,IAAI,QAAQ,IAAK;AAC/C;AAEA,SAAS,QAAQ,GAAU,GAAkB;AAC3C,UAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI,EAAE,MAAM;AAC3C;","names":["first","t"]}
@@ -702,7 +702,7 @@ function createRunner(options) {
702
702
  entry.data = input.data;
703
703
  return entry;
704
704
  }
705
- const created = { key, mark: input.mark, data: input.data, runs: /* @__PURE__ */ new Map(), applied: {}, handle: void 0, exiting: void 0 };
705
+ const created = { key, mark: input.mark, data: input.data, resting: input.data, runs: /* @__PURE__ */ new Map(), applied: {}, handle: void 0, exiting: void 0 };
706
706
  entries.set(key, created);
707
707
  return created;
708
708
  }
@@ -882,6 +882,7 @@ function createRunner(options) {
882
882
  if (destroyed) return;
883
883
  marks.forEach((input, index) => {
884
884
  const entry = track(input);
885
+ entry.resting = input.data;
885
886
  cancelExit(entry);
886
887
  const batch = { index, count: marks.length };
887
888
  start(entry, "decorate", input.data, batch);
@@ -890,11 +891,18 @@ function createRunner(options) {
890
891
  },
891
892
  update(marks) {
892
893
  if (destroyed) return;
894
+ const changing = new Set(marks.map((input) => input.mark.key));
895
+ for (const entry of [...entries.values()]) {
896
+ const run = entry.runs.get("update");
897
+ if (run && !changing.has(entry.key)) clearRun(run);
898
+ }
893
899
  marks.forEach((input, index) => {
894
900
  const known = entries.get(input.mark.key);
895
901
  const previous = input.from ?? known?.mark;
896
- const data = known && !input.data.previous ? withPrevious(input.data, known.data) : input.data;
897
- start(track(input), "update", data, { index, count: marks.length }, { previous });
902
+ const data = known && !input.data.previous ? withPrevious(input.data, known.resting) : input.data;
903
+ const entry = track(input);
904
+ entry.resting = input.data;
905
+ start(entry, "update", data, { index, count: marks.length }, { previous });
898
906
  });
899
907
  },
900
908
  exit(marks) {
@@ -939,7 +947,10 @@ function createRunner(options) {
939
947
  const entry = entries.get(mark.key);
940
948
  if (!entry) return;
941
949
  entry.mark = mark;
942
- if (data) entry.data = data;
950
+ if (data) {
951
+ entry.data = data;
952
+ if (!transitioning) entry.resting = data;
953
+ }
943
954
  for (const run of [...entry.runs.values()]) {
944
955
  if (run.state === "cleared") continue;
945
956
  try {
@@ -961,6 +972,7 @@ function createRunner(options) {
961
972
  settle() {
962
973
  if (!transitioning) return;
963
974
  transitioning = false;
975
+ for (const entry of entries.values()) if (!entry.exiting) entry.resting = entry.data;
964
976
  const keys = [...hovered];
965
977
  keys.forEach((key, index) => {
966
978
  const entry = entries.get(key);
@@ -1179,4 +1191,4 @@ export {
1179
1191
  playTransition,
1180
1192
  isTransitionEffect
1181
1193
  };
1182
- //# sourceMappingURL=chunk-CVXP2L2J.js.map
1194
+ //# sourceMappingURL=chunk-N2BLUETM.js.map