expressive-charts 0.5.0 → 0.7.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.
- package/CHANGELOG.md +55 -1
- package/README.md +7 -7
- package/dist/{drawing-Ypmq-2h6.d.ts → drawing-OmQV-0BB.d.cts} +8 -2
- package/dist/{drawing-Ypmq-2h6.d.cts → drawing-OmQV-0BB.d.ts} +8 -2
- package/dist/{effect-CMo-2gPf.d.ts → effect-DYCLY_6e.d.cts} +28 -4
- package/dist/{effect-C786hGyJ.d.cts → effect-HCWnmB72.d.ts} +28 -4
- package/dist/expressive-charts.global.js +10 -10
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.d.cts +1 -1
- package/dist/icons/sport.d.ts +1 -1
- package/dist/index.cjs +1226 -234
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -17
- package/dist/index.d.ts +102 -17
- package/dist/index.js +1159 -226
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +36 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -3
- package/dist/testing.d.ts +12 -3
- package/dist/testing.js +20 -3
- package/dist/testing.js.map +1 -1
- package/dist/{transition-Bu1NsQor.js → transition-romki_A6.js} +70 -12
- package/dist/transition-romki_A6.js.map +1 -0
- package/package.json +3 -3
- package/dist/transition-Bu1NsQor.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,7 +11,7 @@ The library follows [semantic versioning](https://semver.org) from 0.1.0, with t
|
|
|
11
11
|
- `defineEffect` and `defineDataEffect`, with `GeometryEffectSpec` and `DataEffectSpec`;
|
|
12
12
|
- `matrix` and `offset`;
|
|
13
13
|
- `describe.bar`, `describe.arc`, `describe.line`, `describe.point` and `describe.shape`, with their specs: `BarSpec`, `BarSegmentSpec`, `Baseline`, `ArcSpec`, `LineSpec`, `PointSpec` and `ShapeSpec`;
|
|
14
|
-
- the effect contracts (`GeometryEffect`, `DataEffect`, `TransitionEffect`, `MarkEffect`, `AnyMarkEffect`, `Combined`), the contexts (`EffectContext`, `TransitionContext`), the mark and its data (`MarkGeometry`, `Outline`, `Point`, `Rect`, `MarkData`, `Sample`), the drawing API (`Layer`, `MarkHandle`, `MarkStyle`, `Matrix`, `Paint`, `TextStyle`, `Color`, and the handles `IconHandle`, `PathHandle` and `TextHandle`), and icons as an effect gets them (`Icon`, `IconShape`, `IconSource`);
|
|
14
|
+
- the effect contracts (`GeometryEffect`, `DataEffect`, `TransitionEffect`, `MarkEffect`, `AnyMarkEffect`, `Combined`), the contexts (`EffectContext`, `TransitionContext`) and where their text sits (`TextSpace`), the mark and its data (`MarkGeometry`, `Outline`, `Point`, `Rect`, `MarkData`, `Sample`), the drawing API (`Layer`, `MarkHandle`, `MarkStyle`, `Matrix`, `Paint`, `TextStyle`, `Color`, and the handles `IconHandle`, `PathHandle` and `TextHandle`), and icons as an effect gets them (`Icon`, `IconShape`, `IconSource`);
|
|
15
15
|
- the motion types the context uses: `MotionView`, `MotionMode`, `Timing`, `Tween`, `TweenOptions`, `TweenResult` and `Easing`;
|
|
16
16
|
- `expressive-charts/testing`: `checkEffect`, `checkTransition`, `fixtures`, `fixturePairs`, `testContext` and `play`, with their options (`CheckEffectOptions`, `CheckTransitionOptions`, `TestContextOptions`, `PlayOptions`), the fixtures' names (`FixtureName`, `FixturePairName`), the test context (`TestContext`) and what it records (`RecordingLayer`, `RecordingMark`, `Drawn`, `DrawnIcon`, `DrawnPath`, `DrawnText`, `LayerCall`, `MarkCall`, `Picture`), and the motion types they use: `Motion`, `Clock`, `ManualClock`, `ScalingOverrides` and `ScalingRule`.
|
|
17
17
|
|
|
@@ -25,6 +25,60 @@ 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.7.0 (1 November 2026)
|
|
29
|
+
|
|
30
|
+
A new effect, `drawIn`, that draws a mark in along its walk as it enters, a stack part by part, each in its own colour; `morph` pairing two lines by x, so their corners and gaps hold on every frame; a chart switch that draws a line's end dot and a point's ring, and keeps its tab stop on the week; and room above a line chart's plot. In the effect-author API, the one change is `part` on `Paint`, an addition. The other changes are outside the promise, and none needs anything written instead.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **`part` on `Paint`**, under the 0.x promise: the key of one of the mark's segments (`segment.key`). In that paint, `"mark"` and `"mark-strong"` are that segment's colours, so an effect can draw a stack part by part, each in its own colour. Unset, or a key the mark hasn't, they're the mark's own, its first segment's for a stack, as before. Our charts give each segment's colours: the bar chart's by series, and `expressive()`'s from each part's own fill or stroke. The testing entry's recording layer keeps it with the paint. It's an optional field, an addition: a paint without it draws as before.
|
|
35
|
+
- **`drawIn()`**, with `DrawInOptions`: a mark draws itself in along its walk as it enters (`on: { enter: drawIn() }`). Its body goes faint (`faint`, default 0.3), and the overlay draws it from its start to its end at its own width and colour over `duration` (750 ms base, effect timing). A line draws along its stroke, its gaps left out; a bar from its baseline to its tip; a slice round its ring; and a stack each segment in turn, in its own colour, each over its share of the time by its length. A point or a closed shape shows at once. It follows the mark as it grows or moves, and its end state is the mark as it is, so reduced motion shows it at once. Its labels stay as they are. It's for `enter`, not `hover`, where it would make the mark being read faint, and it isn't a preset.
|
|
36
|
+
- **`end` and `ring` on `ChartSwitchPaint`,** both optional. `end` is the radius of the dot a view's chart draws at the end of a mark's walk, and `ring` the width of the ring in `--ec-surface` it draws round the mark, or round that dot. The line chart's handle gives a line's end dot (4.5) and its ring, and a point drawn at rest its ring (2). A view whose paints have neither draws as before.
|
|
37
|
+
- **`moveTabStop(key)` on `ChartSwitchView`,** optional: it moves a chart's tab stop to the stop `focus(key)` would focus, without focus, so no ring shows and nothing hovers, and says whether it did. The bar, donut and line charts' handles have it. A view without it keeps its own tab stop after a switch, as before.
|
|
38
|
+
- **`room` on `lineChart` takes sides:** `{ right, top }`. `top` is px the layout keeps clear above the plot, below the chart's top, for text an effect draws above it, such as a `delta` past a line that ends near the top heading up. The plot is that much shorter, and its value labels and end labels move with it. A side that isn't given is 0, so a number is `{ right }` as before, and a number, `{}` and `{ right }` lay out as before. Anything but a number of px, 0 or more, or an object of them by side, throws a `RangeError`, and `update({ room })` lays the chart out again. `barChart`'s `room` stays a number.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **`morph` pairs two lines by x.** Two lines whose vertices' x each go one way, the same way for both, as a line chart's do, morph by x: the point a share of the way across one line's x span moves to the point that share across the other's, so between two line charts of the same weeks each week moves straight up or down, whatever the plots' widths. They're sampled at `points` shares evenly across and at every vertex of both, up to 1,000 of each line's; of a denser line, the first, last, highest and lowest in each of 250 columns. Their middle frames change. Any other two lines, closed outlines and crossfades morph as before, byte for byte. Nothing to write instead.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **A chart switch draws a line's end dot.** It went on the first frame of a switch to or from a line view, and came back as it landed. Now it moves with its line from one end to the other between two line charts, and fades with its line into the columns.
|
|
47
|
+
- **A chart switch draws a point's ring,** the 2 px in the surface's colour round a value alone between gaps and round an end dot. It keeps it into another line chart, and loses it as the point grows into its column.
|
|
48
|
+
- **Tab after a toggle lands on the same week.** With focus outside a switch, on the toggle that started it, Tab went to the new view's own tab stop. Now the switch reads the old view's tab stop before anything hides, and moves the new view's to the first of the keys it stood for, as focus follows when it's in the view.
|
|
49
|
+
- **`morph` keeps a line's corners, and matches its gaps by x.** Between two lines that each run one way, the stroke next to the first and last frames is each line's own polyline: on the morph page's season card, with 160 points, goals' corners were cut by up to 10.9 px. And where both lines miss the same weeks, nothing is drawn on any frame: faint strokes reached up to 54 px across them, since gaps met by how far along each line they were. A page that gives `morph({ points })` more points for its corners can drop them.
|
|
50
|
+
|
|
51
|
+
## 0.6.0 (30 October 2026)
|
|
52
|
+
|
|
53
|
+
Line charts in a chart switch, their points growing into columns, change text that keeps clear of other effects' text, with room for it on the line chart, and `morph` keeping a line's gaps and a shape's holes. `expressive()` reads more marks by tag (a turned `<rect>`, a pie's slices and a non-scaling stroke), and the hover on one point reaches a point drawn on another. In the effect-author API, the one change is `texts` on `EffectContext`, with its type, `TextSpace`, an addition. The other changes are outside the promise, and each says what to write instead, if anything.
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- **`texts` on `EffectContext`**, under the 0.x promise, with its type, `TextSpace`: where effects' text sits on the same chart or attachment, so an effect's text can keep clear of other effects' text. `box(content, style)` gives the box the text takes, measured as the chart measures its own labels (estimated where there's no layout); `held()` the boxes held by the runs that started before this one; and `hold(box)` says where this run's text is, until it holds another or the run is cleared. Every run on one runner shares one space. Our charts, `expressive()` and `fromVegaView()` always give it, and so does `testContext()`, with `held` in its options and `texts.holding` to read what a run holds. It's an optional field, an addition: an effect that ignores it works as before, and a context without it is still one.
|
|
58
|
+
- **A line chart as a chart switch's view.** Its points grow into columns keyed as they are, and back: key the columns with the bar chart's `key` (``key: (d) => `goals@${d.week}` ``).
|
|
59
|
+
- Each point pairs with its column and grows out of a dot of no size at its centre, or out of its own dot when it's alone between gaps, while the lines fade out over the first half. Back, each column shrinks into its point.
|
|
60
|
+
- Between two line charts, the lines morph by series and their end labels move. The points stay hidden, but for a value alone between gaps, which morphs as its dot.
|
|
61
|
+
- Focus follows the x: from an x to its first series' point's column, and back to the x, or to the point with `hover: "point"`.
|
|
62
|
+
- **`paintOf(key)` and `standsFor(key)` on `ChartSwitchView`,** both optional, with the `ChartSwitchPaint` type. `paintOf` gives the name a mark's colour comes from in the switch's assignment, and whether its chart draws it at rest; `standsFor` gives the keys a focus stop stands for, in the order the next view tries them. The bar, donut and line charts' handles have `paintOf`, and the line chart's has `standsFor`. A view without them is drawn by key, as before, so no page needs to change.
|
|
63
|
+
- **`room` on `lineChart`:** px the layout keeps clear to the right of the end labels, for text an effect draws past them, such as a `delta`. The plot is that much narrower. Its default, 0, lays out as before; anything but a number of px, 0 or more, throws a `RangeError`, and `update({ room })` lays the chart out again.
|
|
64
|
+
- **`expressive()` reads a `<rect>` turned or skewed by its transforms** as a closed shape: the shape `describe.shape` gives its outline, rounded corners too, moved by its matrix, as a `<polygon>` is. It used to throw. An upright rect is a bar, as before, and with a turned one among bars, every mark keeps document order, as with a circle or a shape among them. A turned rect that shares its key with other rects still throws a `TypeError`, since a bar's segments are upright. Nothing to write instead.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- **A slice's `nearbyLabels` are every other slice's labels,** in the slices' order, not only the nearest each way round: text that goes past a neighbour's label could meet the next one round. A page's effect that reads them sees more boxes; `delta` and `label` read them as before.
|
|
69
|
+
- **The runner tells an effect `onChange` when text held before its run's moved,** though its own mark didn't, once the chart has told every mark that moved, so the effect can place its text again. An effect that follows `onChange` already handles it.
|
|
70
|
+
- **`expressive()` reads a pie's or a donut's paths as slices.** A `<path>` that draws a ring's slice, within 0.5 px, is read with `describe.arc`: one circular arc with two straight sides through its centre (a pie's), two arcs about one centre, one each way, joined along radii (a donut's), or a whole ring. Its centre, radii and angles, in `d3.pie()`'s convention, come from the path through its transforms, so a D3 pie read by tag goes clockwise from 12 o'clock, for the arrow keys and in `marks()`, and every effect treats its slices as our donut's: `travel` and `trace` run round a slice's middle, where on a shape they did nothing. It used to read each as a closed shape, in document order. A path with rounded corners, an elliptical arc, a donut's with a pad angle that takes its sides more than 0.5 px off radii, a disc, or one under a transform that stretches or skews it, is a shape, as before. To keep the shapes, give `geometry` with `describe.shape` from each path's `d`.
|
|
71
|
+
- **A line chart with `hover: "point"` calls `markLabel` once for each point,** the stops it shows, with the same arguments as before. It used to call it for every x as well, for the x's hidden columns, which aren't named now; `update({ hover: "x" })` names them. A page that counts `markLabel`'s calls with `"point"` sees fewer. Nothing to write instead.
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- **`delta` and `label` keep clear of other effects' text.** Each goes past the text the runs before it hold (the first mark in the chart's order keeps its place, and the next goes past it), so two lines that end close together no longer put their changes on each other, and a line's `delta` no longer lands on its own `label`. On the season page's goals and xG lines, their changes met in 5 of the 9 matchweeks where both change at 1,000 px, and in 8 at 320; now in none.
|
|
76
|
+
- **Their text's own box keeps clear of labels beside it.** They checked a 6 px band along the way the text is placed, which text centred along a slice's ring reached past. Now, after passing the mark's own labels as before, the text moves along its way until its own box is clear: 6 px clear of a label the way misses, clear of other effects' text the way misses, so changes on rows a line apart stay beside their names, and past a box the way meets as before. On 1,500 random donuts, 61 of the 963 slices whose label was dropped put their text on another slice's label, and now none does; such text also sits nearer its slice. A box the text would only meet further along its way isn't passed, as it was. Text that was clear stays where it was.
|
|
77
|
+
- **A chart switch draws each mark in its view's colour.** It drew each pair, and each mark that fades, in its key's colour, so columns coloured by series (the default) each took a colour of their own while they morphed, and the switch asked the shared assignment for a slot for every key. A switch whose views colour by key, such as a donut and its `colorBy: "category"` columns, draws as before.
|
|
78
|
+
- **`morph` keeps a line's gaps and a shape's holes.** Between two lines with gaps, it joined them part way; now the stroke inside a gap of the old line fades in as it goes, and inside a gap of the new line fades out, so nothing is drawn inside a gap both have and nothing jumps. Between two shapes with holes, such as two D3 rings, the holes showed only at the ends; now each hole morphs to its partner, largest with largest, and one with no partner closes up inside the shape as it moves, or opens from a point. A hole stays a hole under either fill rule. Lines without gaps and outlines without holes morph as before, byte for byte, so nothing to write instead.
|
|
79
|
+
- **`expressive()` reads a non-scaling stroke's width.** With `vector-effect: non-scaling-stroke`, as an attribute or a computed style, an open shape's width is in screen px, as a browser draws it: its transforms no longer scale it. Where there's layout, it's turned into the marks' units by their common ancestor's screen scale; where there isn't, as in jsdom, it's kept as given. `watch` keeps it through the frames, as it keeps the width, and reads it again when the common ancestor's screen scale changes.
|
|
80
|
+
- **A line chart's point drawn on another's can be hovered by the pointer.** With `hover: "point"`, where other lines' points are drawn within a px of the nearest, as where goals equal xG, the pointer hovers the one whose line passes nearest it: its stroke as drawn, curved and with its gaps, within 9 px along it of the point. A value alone between gaps counts as its dot. So the pointer just off them along a line hovers that line's point, and at their centre the series first in `series`, as before. Before, the first series always won there, and the others could be reached only by the keyboard. The hover held on a dot while its tooltip shows, touch and a click keep the rule; the keys are as before.
|
|
81
|
+
|
|
28
82
|
## 0.5.0 (29 October 2026)
|
|
29
83
|
|
|
30
84
|
Curved lines and a hover on one point on the line chart, change labels that keep off other marks' labels, a negative column's value label off its name, curved Vega lines, and smaller pages for the motion core and `describe`. In the effect-author API, the one change is `nearbyLabels` on `MarkGeometry` and on the builders' specs, an addition. The other changes are outside the promise, and each says what to write instead, if anything.
|
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ 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.
|
|
18
|
+
> **Status: 0.7.0 (November 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#070-1-november-2026) lists what's new and what changed since 0.6.0.
|
|
19
19
|
|
|
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.
|
|
20
|
+
- **Effects first.** The mark effects `travel`, `flash`, `wiggle`, `pulse`, `trace`, `drawIn` 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.
|
|
22
22
|
- **Motion that stays readable.** One clock and three modes: Presentation (staged, about a second), Analysis (at most about 200 ms) and Off. The device's reduced-motion setting is followed unless the viewer picks a mode on the page, and every effect has an end state, which is what reduced motion shows.
|
|
23
23
|
- **Accessible.** Keyboard focus, a name for every mark, a data table, announcements and a pause control for anything that plays, checked against WCAG 2.2 AA.
|
|
@@ -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 31 KB gzipped, and everything
|
|
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 87 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.
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/expressive-charts@0.7/dist/expressive-charts.global.js"></script>
|
|
38
38
|
<script>
|
|
39
39
|
const { barChart } = ExpressiveCharts;
|
|
40
40
|
barChart("#sales", {
|
|
@@ -125,10 +125,10 @@ playButton("#play", season, { labels: { play: "Play season" } });
|
|
|
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
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, straight or, with `curve: "monotone"`, curved through every value without going past it, 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`, hovering every series at an x with a crosshair or, with `hover: "point"`, the one point nearest the pointer, the other lines dimmed. 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
|
-
- **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. Its `on()`, `marks()` and `leave()` are the view on show's, and it can be linked like a chart.
|
|
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, with only a key: rects as bars, circles as points, and paths, lines, polylines, polygons and
|
|
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, a line chart's points growing into columns keyed as they are, or one line chart's lines becoming another's, and back from wherever it is. Each mark keeps its view's colour, a line its end dot and a point its ring, and focus follows the x, or the tab stop does when focus is on a toggle. Its `on()`, `marks()` and `leave()` are the view on show's, and it can be linked like a chart.
|
|
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, with only a key: rects as bars, circles as points, a pie's or a donut's paths as slices, clockwise from 12 o'clock, and other paths, lines, polylines, polygons, ellipses and turned rects as shapes, through their transforms, a non-scaling stroke at its width on screen. It draws on an overlay, leaving the host's styling alone; `watch: true` follows the host's own transitions. A curve, or a line drawn with d3's `.defined()`, is read from its own path data, with its gaps, and no effect draws inside them; `geometry` describes anything else, or a mark as you'd rather have it. Observable Plot binds each rect or dot 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 marks. 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; a line breaks where Vega-Lite leaves out a missing value, and a curve is read from the path Vega draws. Both change their effects in place with `update({ on })`, as a chart does, and `leave()` ends their hover.
|
|
130
130
|
- **Linked hover.** [`link()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#link) links hover across charts, chart switches 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
|
-
- **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"`).
|
|
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; [`drawIn`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#drawin) draws a mark in along its walk as it enters, a stack part by part in its colours; [`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 and clear of other effects' text. 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.
|
|
133
133
|
- **The motion core.** [`motion`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#motion), [`tween()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#tween) and [`animated()`](https://github.com/Deaversbp/expressive-charts/blob/main/docs/api.md#animated), for animations of your own that follow the same modes.
|
|
134
134
|
|
|
@@ -127,7 +127,8 @@ interface IconSource {
|
|
|
127
127
|
/**
|
|
128
128
|
* A theme token or any CSS colour. Tokens: "text", "text-muted", "surface", "grid", "axis", "focus",
|
|
129
129
|
* "negative", "series-N" and "series-N-strong" (palette slots 1–8), and "mark" / "mark-strong", the
|
|
130
|
-
* colours of the mark a run belongs to (its first segment's, for a stack
|
|
130
|
+
* colours of the mark a run belongs to (its first segment's, for a stack, or in a paint with `part`,
|
|
131
|
+
* that segment's).
|
|
131
132
|
*/
|
|
132
133
|
type Color = string;
|
|
133
134
|
/**
|
|
@@ -141,6 +142,11 @@ interface Paint {
|
|
|
141
142
|
readonly width?: number;
|
|
142
143
|
readonly opacity?: number;
|
|
143
144
|
readonly linecap?: "butt" | "round";
|
|
145
|
+
/**
|
|
146
|
+
* The key of one of the mark's segments (`segment.key`). In this paint, "mark" and "mark-strong"
|
|
147
|
+
* are that segment's colours. Unset, or a key the mark hasn't, they're the mark's own, as without it.
|
|
148
|
+
*/
|
|
149
|
+
readonly part?: string;
|
|
144
150
|
}
|
|
145
151
|
interface MarkStyle {
|
|
146
152
|
/** In chart space. Moves the mark's body; its labels and pointer target stay put. */
|
|
@@ -211,4 +217,4 @@ interface Layer {
|
|
|
211
217
|
text(content: string, style: TextStyle): TextHandle;
|
|
212
218
|
}
|
|
213
219
|
export { Rect as _, MarkStyle as a, PathHandle as c, Icon as d, IconShape as f, Point as g, Outline as h, MarkHandle as i, TextHandle as l, MarkGeometry as m, IconHandle as n, Matrix as o, IconSource as p, Layer as r, Paint as s, Color as t, TextStyle as u };
|
|
214
|
-
//# sourceMappingURL=drawing-
|
|
220
|
+
//# sourceMappingURL=drawing-OmQV-0BB.d.cts.map
|
|
@@ -127,7 +127,8 @@ interface IconSource {
|
|
|
127
127
|
/**
|
|
128
128
|
* A theme token or any CSS colour. Tokens: "text", "text-muted", "surface", "grid", "axis", "focus",
|
|
129
129
|
* "negative", "series-N" and "series-N-strong" (palette slots 1–8), and "mark" / "mark-strong", the
|
|
130
|
-
* colours of the mark a run belongs to (its first segment's, for a stack
|
|
130
|
+
* colours of the mark a run belongs to (its first segment's, for a stack, or in a paint with `part`,
|
|
131
|
+
* that segment's).
|
|
131
132
|
*/
|
|
132
133
|
type Color = string;
|
|
133
134
|
/**
|
|
@@ -141,6 +142,11 @@ interface Paint {
|
|
|
141
142
|
readonly width?: number;
|
|
142
143
|
readonly opacity?: number;
|
|
143
144
|
readonly linecap?: "butt" | "round";
|
|
145
|
+
/**
|
|
146
|
+
* The key of one of the mark's segments (`segment.key`). In this paint, "mark" and "mark-strong"
|
|
147
|
+
* are that segment's colours. Unset, or a key the mark hasn't, they're the mark's own, as without it.
|
|
148
|
+
*/
|
|
149
|
+
readonly part?: string;
|
|
144
150
|
}
|
|
145
151
|
interface MarkStyle {
|
|
146
152
|
/** In chart space. Moves the mark's body; its labels and pointer target stay put. */
|
|
@@ -211,4 +217,4 @@ interface Layer {
|
|
|
211
217
|
text(content: string, style: TextStyle): TextHandle;
|
|
212
218
|
}
|
|
213
219
|
export { Rect as _, MarkStyle as a, PathHandle as c, Icon as d, IconShape as f, Point as g, Outline as h, MarkHandle as i, TextHandle as l, MarkGeometry as m, IconHandle as n, Matrix as o, IconSource as p, Layer as r, Paint as s, Color as t, TextStyle as u };
|
|
214
|
-
//# sourceMappingURL=drawing-
|
|
220
|
+
//# sourceMappingURL=drawing-OmQV-0BB.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as MarkHandle, m as MarkGeometry, p as IconSource, r as Layer } from "./drawing-
|
|
1
|
+
import { _ as Rect, i as MarkHandle, m as MarkGeometry, p as IconSource, r as Layer, u as TextStyle } from "./drawing-OmQV-0BB.cjs";
|
|
2
2
|
/** Where frames come from. The default uses requestAnimationFrame, or a 16 ms timer outside the browser. */
|
|
3
3
|
interface FrameSource {
|
|
4
4
|
now(): number;
|
|
@@ -146,6 +146,25 @@ interface MarkData<D = unknown> {
|
|
|
146
146
|
/** The values before this update, for update effects that show change. */
|
|
147
147
|
readonly previous?: MarkData<D>;
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Where effects' text sits on one chart or attachment: one space for every run on its runner, so an
|
|
151
|
+
* effect's text can keep clear of other effects' text. Runs start in the chart's mark order, so text
|
|
152
|
+
* goes past the text of the runs before it, and never moves for the runs after it.
|
|
153
|
+
*/
|
|
154
|
+
interface TextSpace {
|
|
155
|
+
/**
|
|
156
|
+
* The box `content` takes drawn with `style`, at the overlay's text size, measured as the chart
|
|
157
|
+
* measures its own text (estimated where there's no layout). Its digits are measured as 0s.
|
|
158
|
+
*/
|
|
159
|
+
box(content: string, style: TextStyle): Rect;
|
|
160
|
+
/** The boxes the runs on this runner that started before this one hold now. */
|
|
161
|
+
held(): readonly Rect[];
|
|
162
|
+
/**
|
|
163
|
+
* This run's text is at `box` from now on, until it holds another, holds undefined, or the run is
|
|
164
|
+
* cleared. When it moves, the runs after it that are placed against it hear `onChange` again.
|
|
165
|
+
*/
|
|
166
|
+
hold(box: Rect | undefined): void;
|
|
167
|
+
}
|
|
149
168
|
interface EffectContext {
|
|
150
169
|
/** Aborted on leave, re-trigger, data update or destroy. */
|
|
151
170
|
readonly signal: AbortSignal;
|
|
@@ -162,10 +181,15 @@ interface EffectContext {
|
|
|
162
181
|
readonly index: number;
|
|
163
182
|
readonly count: number;
|
|
164
183
|
};
|
|
165
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Called when the geometry moves (transitions, resizes, line reveals), and when text held before
|
|
186
|
+
* this run's moved after it was placed (`texts`); unsubscribed on clear.
|
|
187
|
+
*/
|
|
166
188
|
onChange(listener: (mark: MarkGeometry, data?: MarkData) => void): void;
|
|
167
189
|
/** The mark's geometry before this update, on update events. */
|
|
168
190
|
readonly previous?: MarkGeometry;
|
|
191
|
+
/** Where effects' text sits on this chart or attachment. Unset means no other text is known. */
|
|
192
|
+
readonly texts?: TextSpace;
|
|
169
193
|
}
|
|
170
194
|
interface GeometryEffect {
|
|
171
195
|
readonly kind: "geometry";
|
|
@@ -228,5 +252,5 @@ type AllRowNeeds<E extends readonly unknown[]> = E extends readonly [] ? unknown
|
|
|
228
252
|
type Combined<E extends readonly AnyMarkEffect[]> = [Extract<E[number], {
|
|
229
253
|
kind: "data";
|
|
230
254
|
}>] extends [never] ? GeometryEffect : DataEffect<AllRowNeeds<E>>;
|
|
231
|
-
export {
|
|
232
|
-
//# sourceMappingURL=effect-
|
|
255
|
+
export { scaleDuration as A, manualClock as B, ScalingRule as C, defaultScaling as D, createMotion as E, Clock as F, FrameSource as I, ManualClock as L, easeInOutCubic as M, easeOutCubic as N, mediaReducedMotion as O, linear as P, createClock as R, ScalingOverrides as S, Timing as T, Motion as _, GeometryEffect as a, MotionView as b, TransitionContext as c, Sample as d, MotionEnv as f, tween as g, TweenResult as h, EffectContext as i, Easing as j, motion as k, TransitionEffect as l, TweenOptions as m, Combined as n, MarkEffect as o, Tween as p, DataEffect as r, TextSpace as s, AnyMarkEffect as t, MarkData as u, MotionMode as v, ScalingTable as w, ReducedMotionSource as x, MotionOptions as y, defaultClock as z };
|
|
256
|
+
//# sourceMappingURL=effect-DYCLY_6e.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as MarkHandle, m as MarkGeometry, p as IconSource, r as Layer } from "./drawing-
|
|
1
|
+
import { _ as Rect, i as MarkHandle, m as MarkGeometry, p as IconSource, r as Layer, u as TextStyle } from "./drawing-OmQV-0BB.js";
|
|
2
2
|
/** Where frames come from. The default uses requestAnimationFrame, or a 16 ms timer outside the browser. */
|
|
3
3
|
interface FrameSource {
|
|
4
4
|
now(): number;
|
|
@@ -146,6 +146,25 @@ interface MarkData<D = unknown> {
|
|
|
146
146
|
/** The values before this update, for update effects that show change. */
|
|
147
147
|
readonly previous?: MarkData<D>;
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Where effects' text sits on one chart or attachment: one space for every run on its runner, so an
|
|
151
|
+
* effect's text can keep clear of other effects' text. Runs start in the chart's mark order, so text
|
|
152
|
+
* goes past the text of the runs before it, and never moves for the runs after it.
|
|
153
|
+
*/
|
|
154
|
+
interface TextSpace {
|
|
155
|
+
/**
|
|
156
|
+
* The box `content` takes drawn with `style`, at the overlay's text size, measured as the chart
|
|
157
|
+
* measures its own text (estimated where there's no layout). Its digits are measured as 0s.
|
|
158
|
+
*/
|
|
159
|
+
box(content: string, style: TextStyle): Rect;
|
|
160
|
+
/** The boxes the runs on this runner that started before this one hold now. */
|
|
161
|
+
held(): readonly Rect[];
|
|
162
|
+
/**
|
|
163
|
+
* This run's text is at `box` from now on, until it holds another, holds undefined, or the run is
|
|
164
|
+
* cleared. When it moves, the runs after it that are placed against it hear `onChange` again.
|
|
165
|
+
*/
|
|
166
|
+
hold(box: Rect | undefined): void;
|
|
167
|
+
}
|
|
149
168
|
interface EffectContext {
|
|
150
169
|
/** Aborted on leave, re-trigger, data update or destroy. */
|
|
151
170
|
readonly signal: AbortSignal;
|
|
@@ -162,10 +181,15 @@ interface EffectContext {
|
|
|
162
181
|
readonly index: number;
|
|
163
182
|
readonly count: number;
|
|
164
183
|
};
|
|
165
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Called when the geometry moves (transitions, resizes, line reveals), and when text held before
|
|
186
|
+
* this run's moved after it was placed (`texts`); unsubscribed on clear.
|
|
187
|
+
*/
|
|
166
188
|
onChange(listener: (mark: MarkGeometry, data?: MarkData) => void): void;
|
|
167
189
|
/** The mark's geometry before this update, on update events. */
|
|
168
190
|
readonly previous?: MarkGeometry;
|
|
191
|
+
/** Where effects' text sits on this chart or attachment. Unset means no other text is known. */
|
|
192
|
+
readonly texts?: TextSpace;
|
|
169
193
|
}
|
|
170
194
|
interface GeometryEffect {
|
|
171
195
|
readonly kind: "geometry";
|
|
@@ -228,5 +252,5 @@ type AllRowNeeds<E extends readonly unknown[]> = E extends readonly [] ? unknown
|
|
|
228
252
|
type Combined<E extends readonly AnyMarkEffect[]> = [Extract<E[number], {
|
|
229
253
|
kind: "data";
|
|
230
254
|
}>] extends [never] ? GeometryEffect : DataEffect<AllRowNeeds<E>>;
|
|
231
|
-
export {
|
|
232
|
-
//# sourceMappingURL=effect-
|
|
255
|
+
export { scaleDuration as A, manualClock as B, ScalingRule as C, defaultScaling as D, createMotion as E, Clock as F, FrameSource as I, ManualClock as L, easeInOutCubic as M, easeOutCubic as N, mediaReducedMotion as O, linear as P, createClock as R, ScalingOverrides as S, Timing as T, Motion as _, GeometryEffect as a, MotionView as b, TransitionContext as c, Sample as d, MotionEnv as f, tween as g, TweenResult as h, EffectContext as i, Easing as j, motion as k, TransitionEffect as l, TweenOptions as m, Combined as n, MarkEffect as o, Tween as p, DataEffect as r, TextSpace as s, AnyMarkEffect as t, MarkData as u, MotionMode as v, ScalingTable as w, ReducedMotionSource as x, MotionOptions as y, defaultClock as z };
|
|
256
|
+
//# sourceMappingURL=effect-HCWnmB72.d.ts.map
|