@internetstiftelsen/charts 0.10.1 → 0.11.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/README.md +64 -0
- package/dist/area.d.ts +9 -1
- package/dist/area.js +174 -38
- package/dist/bar.d.ts +9 -1
- package/dist/bar.js +130 -47
- package/dist/base-chart.js +11 -1
- package/dist/donut-chart.js +3 -18
- package/dist/gauge-chart.d.ts +3 -4
- package/dist/gauge-chart.js +7 -53
- package/dist/lazy-mount.d.ts +13 -0
- package/dist/lazy-mount.js +90 -0
- package/dist/line.d.ts +9 -1
- package/dist/line.js +141 -23
- package/dist/pie-chart.js +5 -29
- package/dist/radial-chart-base.d.ts +4 -3
- package/dist/radial-chart-base.js +27 -12
- package/dist/scatter.d.ts +5 -1
- package/dist/scatter.js +89 -8
- package/dist/theme.js +17 -0
- package/dist/tooltip.d.ts +55 -3
- package/dist/tooltip.js +950 -137
- package/dist/types.d.ts +20 -0
- package/dist/xy-animation.d.ts +3 -0
- package/dist/xy-animation.js +2 -0
- package/dist/xy-chart.d.ts +11 -1
- package/dist/xy-chart.js +107 -10
- package/dist/xy-motion/config.d.ts +2 -0
- package/dist/xy-motion/config.js +177 -0
- package/dist/xy-motion/driver.d.ts +9 -0
- package/dist/xy-motion/driver.js +10 -0
- package/dist/xy-motion/helpers.d.ts +17 -0
- package/dist/xy-motion/helpers.js +105 -0
- package/dist/xy-motion/live-state.d.ts +8 -0
- package/dist/xy-motion/live-state.js +240 -0
- package/dist/xy-motion/noop-xy-motion-driver.d.ts +9 -0
- package/dist/xy-motion/noop-xy-motion-driver.js +15 -0
- package/dist/xy-motion/types.d.ts +85 -0
- package/dist/xy-motion/types.js +1 -0
- package/dist/xy-motion/xy-motion-driver.d.ts +19 -0
- package/dist/xy-motion/xy-motion-driver.js +130 -0
- package/docs/components.md +36 -0
- package/docs/getting-started.md +35 -0
- package/docs/theming.md +14 -0
- package/docs/xy-chart.md +67 -1
- package/package.json +1 -1
package/docs/xy-chart.md
CHANGED
|
@@ -21,6 +21,7 @@ new XYChart(config: XYChartConfig)
|
|
|
21
21
|
| `responsive` | `ResponsiveConfig` | - | Container-query responsive overrides (theme + components) |
|
|
22
22
|
| `barStack` | `BarStackConfig` | `{ mode: 'normal', gap: 0.1, reverseSeries: false }` | Bar stacking configuration |
|
|
23
23
|
| `areaStack` | `AreaStackConfig` | `{ mode: 'none' }` | Area stacking configuration |
|
|
24
|
+
| `animate` | `boolean \| XYAnimationConfig` | `false` | Opt-in XY series animation for initial render and `update()` |
|
|
24
25
|
|
|
25
26
|
### Theme Options
|
|
26
27
|
|
|
@@ -223,6 +224,45 @@ is measured after declarative breakpoint overrides are merged. It receives
|
|
|
223
224
|
`context.activeBreakpoints` with every match and `context.breakpoint` as the
|
|
224
225
|
last matching breakpoint name.
|
|
225
226
|
|
|
227
|
+
## Animation
|
|
228
|
+
|
|
229
|
+
Use `animate` when you want XY series marks to animate on the first render and
|
|
230
|
+
when calling `chart.update(...)`.
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const chart = new XYChart({
|
|
234
|
+
data,
|
|
235
|
+
animate: {
|
|
236
|
+
duration: 700,
|
|
237
|
+
easing: 'ease-in-out',
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`XYAnimationConfig` supports:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
animate: boolean | {
|
|
246
|
+
show?: boolean, // default: true when object form is used
|
|
247
|
+
duration?: number, // ms, default: 700
|
|
248
|
+
easing?:
|
|
249
|
+
| 'linear'
|
|
250
|
+
| 'ease-in'
|
|
251
|
+
| 'ease-out'
|
|
252
|
+
| 'ease-in-out'
|
|
253
|
+
| 'bounce-out'
|
|
254
|
+
| 'elastic-out'
|
|
255
|
+
| `linear(...)`
|
|
256
|
+
| ((t: number) => number),
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Notes:
|
|
261
|
+
|
|
262
|
+
- Animation is off by default.
|
|
263
|
+
- Animates XY series marks only. Axes, legends, tooltips, and value labels remain static.
|
|
264
|
+
- Visual exports always render the final static state, even when the live chart is animated.
|
|
265
|
+
|
|
226
266
|
## Validation
|
|
227
267
|
|
|
228
268
|
`XYChart` validates configuration and series data early:
|
|
@@ -256,6 +296,9 @@ chart.render('#chart-container');
|
|
|
256
296
|
chart.render(document.getElementById('chart-container'));
|
|
257
297
|
```
|
|
258
298
|
|
|
299
|
+
When `animate` is enabled, the first render returns immediately while the series
|
|
300
|
+
transition continues in the background.
|
|
301
|
+
|
|
259
302
|
### update(data)
|
|
260
303
|
|
|
261
304
|
Updates the chart with new data and re-renders.
|
|
@@ -264,6 +307,18 @@ Updates the chart with new data and re-renders.
|
|
|
264
307
|
chart.update(newData);
|
|
265
308
|
```
|
|
266
309
|
|
|
310
|
+
When `animate` is enabled, `update()` animates XY series marks from the previous
|
|
311
|
+
rendered geometry to the new one.
|
|
312
|
+
|
|
313
|
+
### whenReady()
|
|
314
|
+
|
|
315
|
+
Returns a promise that resolves after any pending async render work finishes.
|
|
316
|
+
For animated XY charts, this waits until the current series transitions finish.
|
|
317
|
+
|
|
318
|
+
```javascript
|
|
319
|
+
await chart.whenReady();
|
|
320
|
+
```
|
|
321
|
+
|
|
267
322
|
### destroy()
|
|
268
323
|
|
|
269
324
|
Cleans up all resources, removes resize observer, and clears the chart from the DOM.
|
|
@@ -438,7 +493,18 @@ Bar charts support different stacking modes:
|
|
|
438
493
|
- `percent` - 100% stacked bars
|
|
439
494
|
- `layer` - Overlapping bars
|
|
440
495
|
|
|
441
|
-
|
|
496
|
+
XY charts use split tooltips by default, rendering one tooltip per visible
|
|
497
|
+
series at the hovered category. Use
|
|
498
|
+
`new Tooltip({ mode: 'shared' | 'split', position: 'side' | 'vertical' })`
|
|
499
|
+
to override the grouping and split-tooltip placement.
|
|
500
|
+
For bars, set `barAnchorPosition: 'top' | 'middle'` to choose whether split
|
|
501
|
+
tooltips point to the top or middle of each bar.
|
|
502
|
+
Use `transition: { show: true, duration: 120, easing: 'ease-out' }` to opt in
|
|
503
|
+
to softer tooltip opacity transitions without delaying position updates.
|
|
504
|
+
|
|
505
|
+
Use `barStack.reverseSeries: true` to reverse bar series display order for
|
|
506
|
+
rendering, legend entries, and split tooltip ordering without changing data
|
|
507
|
+
exports.
|
|
442
508
|
|
|
443
509
|
---
|
|
444
510
|
|
package/package.json
CHANGED