@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.
Files changed (45) hide show
  1. package/README.md +64 -0
  2. package/dist/area.d.ts +9 -1
  3. package/dist/area.js +174 -38
  4. package/dist/bar.d.ts +9 -1
  5. package/dist/bar.js +130 -47
  6. package/dist/base-chart.js +11 -1
  7. package/dist/donut-chart.js +3 -18
  8. package/dist/gauge-chart.d.ts +3 -4
  9. package/dist/gauge-chart.js +7 -53
  10. package/dist/lazy-mount.d.ts +13 -0
  11. package/dist/lazy-mount.js +90 -0
  12. package/dist/line.d.ts +9 -1
  13. package/dist/line.js +141 -23
  14. package/dist/pie-chart.js +5 -29
  15. package/dist/radial-chart-base.d.ts +4 -3
  16. package/dist/radial-chart-base.js +27 -12
  17. package/dist/scatter.d.ts +5 -1
  18. package/dist/scatter.js +89 -8
  19. package/dist/theme.js +17 -0
  20. package/dist/tooltip.d.ts +55 -3
  21. package/dist/tooltip.js +950 -137
  22. package/dist/types.d.ts +20 -0
  23. package/dist/xy-animation.d.ts +3 -0
  24. package/dist/xy-animation.js +2 -0
  25. package/dist/xy-chart.d.ts +11 -1
  26. package/dist/xy-chart.js +107 -10
  27. package/dist/xy-motion/config.d.ts +2 -0
  28. package/dist/xy-motion/config.js +177 -0
  29. package/dist/xy-motion/driver.d.ts +9 -0
  30. package/dist/xy-motion/driver.js +10 -0
  31. package/dist/xy-motion/helpers.d.ts +17 -0
  32. package/dist/xy-motion/helpers.js +105 -0
  33. package/dist/xy-motion/live-state.d.ts +8 -0
  34. package/dist/xy-motion/live-state.js +240 -0
  35. package/dist/xy-motion/noop-xy-motion-driver.d.ts +9 -0
  36. package/dist/xy-motion/noop-xy-motion-driver.js +15 -0
  37. package/dist/xy-motion/types.d.ts +85 -0
  38. package/dist/xy-motion/types.js +1 -0
  39. package/dist/xy-motion/xy-motion-driver.d.ts +19 -0
  40. package/dist/xy-motion/xy-motion-driver.js +130 -0
  41. package/docs/components.md +36 -0
  42. package/docs/getting-started.md +35 -0
  43. package/docs/theming.md +14 -0
  44. package/docs/xy-chart.md +67 -1
  45. 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
- Use `barStack.reverseSeries: true` to reverse bar series display order for rendering, legend entries, and tooltip rows without changing data exports.
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.10.1",
2
+ "version": "0.11.0",
3
3
  "name": "@internetstiftelsen/charts",
4
4
  "type": "module",
5
5
  "sideEffects": false,