@vielzeug/prism 26.10.3 → 26.10.5

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 (119) hide show
  1. package/README.md +15 -26
  2. package/dist/animation/easing.cjs +1 -1
  3. package/dist/animation/easing.cjs.map +1 -1
  4. package/dist/animation/easing.d.ts +15 -1
  5. package/dist/animation/easing.d.ts.map +1 -1
  6. package/dist/animation/easing.js +1 -1
  7. package/dist/animation/easing.js.map +1 -1
  8. package/dist/animation/motion.cjs +1 -1
  9. package/dist/animation/motion.cjs.map +1 -1
  10. package/dist/animation/motion.d.ts +17 -2
  11. package/dist/animation/motion.d.ts.map +1 -1
  12. package/dist/animation/motion.js +1 -1
  13. package/dist/animation/motion.js.map +1 -1
  14. package/dist/animation/reveal.cjs +2 -0
  15. package/dist/animation/reveal.cjs.map +1 -0
  16. package/dist/animation/reveal.d.ts +29 -0
  17. package/dist/animation/reveal.d.ts.map +1 -0
  18. package/dist/animation/reveal.js +2 -0
  19. package/dist/animation/reveal.js.map +1 -0
  20. package/dist/charts/area/area-chart.cjs +1 -1
  21. package/dist/charts/area/area-chart.cjs.map +1 -1
  22. package/dist/charts/area/area-chart.d.ts.map +1 -1
  23. package/dist/charts/area/area-chart.js +1 -1
  24. package/dist/charts/area/area-chart.js.map +1 -1
  25. package/dist/charts/area/area-renderer.cjs +1 -1
  26. package/dist/charts/area/area-renderer.cjs.map +1 -1
  27. package/dist/charts/area/area-renderer.d.ts +2 -2
  28. package/dist/charts/area/area-renderer.d.ts.map +1 -1
  29. package/dist/charts/area/area-renderer.js +1 -1
  30. package/dist/charts/area/area-renderer.js.map +1 -1
  31. package/dist/charts/bar/bar-chart.cjs +1 -1
  32. package/dist/charts/bar/bar-chart.cjs.map +1 -1
  33. package/dist/charts/bar/bar-chart.d.ts.map +1 -1
  34. package/dist/charts/bar/bar-chart.js +1 -1
  35. package/dist/charts/bar/bar-chart.js.map +1 -1
  36. package/dist/charts/bar/bar-renderer.cjs +1 -1
  37. package/dist/charts/bar/bar-renderer.cjs.map +1 -1
  38. package/dist/charts/bar/bar-renderer.d.ts +2 -2
  39. package/dist/charts/bar/bar-renderer.d.ts.map +1 -1
  40. package/dist/charts/bar/bar-renderer.js +1 -1
  41. package/dist/charts/bar/bar-renderer.js.map +1 -1
  42. package/dist/charts/line/line-chart.cjs +1 -1
  43. package/dist/charts/line/line-chart.cjs.map +1 -1
  44. package/dist/charts/line/line-chart.d.ts.map +1 -1
  45. package/dist/charts/line/line-chart.js +1 -1
  46. package/dist/charts/line/line-chart.js.map +1 -1
  47. package/dist/charts/line/line-renderer.cjs +1 -1
  48. package/dist/charts/line/line-renderer.cjs.map +1 -1
  49. package/dist/charts/line/line-renderer.d.ts +7 -2
  50. package/dist/charts/line/line-renderer.d.ts.map +1 -1
  51. package/dist/charts/line/line-renderer.js +1 -1
  52. package/dist/charts/line/line-renderer.js.map +1 -1
  53. package/dist/charts/pie/pie-chart.cjs +1 -1
  54. package/dist/charts/pie/pie-chart.cjs.map +1 -1
  55. package/dist/charts/pie/pie-chart.d.ts.map +1 -1
  56. package/dist/charts/pie/pie-chart.js +1 -1
  57. package/dist/charts/pie/pie-chart.js.map +1 -1
  58. package/dist/charts/radar/radar-chart.cjs +1 -1
  59. package/dist/charts/radar/radar-chart.cjs.map +1 -1
  60. package/dist/charts/radar/radar-chart.d.ts.map +1 -1
  61. package/dist/charts/radar/radar-chart.js +1 -1
  62. package/dist/charts/radar/radar-chart.js.map +1 -1
  63. package/dist/charts/sparkline/sparkline.cjs +1 -1
  64. package/dist/charts/sparkline/sparkline.cjs.map +1 -1
  65. package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
  66. package/dist/charts/sparkline/sparkline.js +1 -1
  67. package/dist/charts/sparkline/sparkline.js.map +1 -1
  68. package/dist/core/chart-base.cjs +1 -1
  69. package/dist/core/chart-base.cjs.map +1 -1
  70. package/dist/core/chart-base.d.ts +1 -0
  71. package/dist/core/chart-base.d.ts.map +1 -1
  72. package/dist/core/chart-base.js +1 -1
  73. package/dist/core/chart-base.js.map +1 -1
  74. package/dist/core/chart-scaffold.cjs +1 -1
  75. package/dist/core/chart-scaffold.cjs.map +1 -1
  76. package/dist/core/chart-scaffold.d.ts +4 -2
  77. package/dist/core/chart-scaffold.d.ts.map +1 -1
  78. package/dist/core/chart-scaffold.js +1 -1
  79. package/dist/core/chart-scaffold.js.map +1 -1
  80. package/dist/core/responsive.cjs +1 -1
  81. package/dist/core/responsive.cjs.map +1 -1
  82. package/dist/core/responsive.d.ts.map +1 -1
  83. package/dist/core/responsive.js +1 -1
  84. package/dist/core/responsive.js.map +1 -1
  85. package/dist/index.d.ts +2 -2
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/interaction/crosshair.cjs +1 -1
  88. package/dist/interaction/crosshair.cjs.map +1 -1
  89. package/dist/interaction/crosshair.d.ts +7 -0
  90. package/dist/interaction/crosshair.d.ts.map +1 -1
  91. package/dist/interaction/crosshair.js +1 -1
  92. package/dist/interaction/crosshair.js.map +1 -1
  93. package/dist/interaction/legend.cjs +1 -1
  94. package/dist/interaction/legend.cjs.map +1 -1
  95. package/dist/interaction/legend.d.ts +1 -1
  96. package/dist/interaction/legend.d.ts.map +1 -1
  97. package/dist/interaction/legend.js +1 -1
  98. package/dist/interaction/legend.js.map +1 -1
  99. package/dist/interaction/tooltip.cjs +1 -1
  100. package/dist/interaction/tooltip.cjs.map +1 -1
  101. package/dist/interaction/tooltip.d.ts.map +1 -1
  102. package/dist/interaction/tooltip.js +1 -1
  103. package/dist/interaction/tooltip.js.map +1 -1
  104. package/dist/prism.cjs +1 -1
  105. package/dist/prism.cjs.map +1 -1
  106. package/dist/prism.iife.js +1 -1
  107. package/dist/prism.iife.js.map +1 -1
  108. package/dist/prism.js +1 -1
  109. package/dist/prism.js.map +1 -1
  110. package/dist/theme/index.cjs +1 -1
  111. package/dist/theme/index.cjs.map +1 -1
  112. package/dist/theme/index.d.ts +9 -4
  113. package/dist/theme/index.d.ts.map +1 -1
  114. package/dist/theme/index.js +1 -1
  115. package/dist/theme/index.js.map +1 -1
  116. package/dist/theme/prism.css +18 -4
  117. package/dist/types.d.ts +39 -5
  118. package/dist/types.d.ts.map +1 -1
  119. package/package.json +3 -6
package/README.md CHANGED
@@ -13,40 +13,29 @@ yarn add @vielzeug/prism
13
13
  ## Quick Start
14
14
 
15
15
  ```ts
16
- import { createLineChart, setTheme } from '@vielzeug/prism';
17
- import '@vielzeug/prism/theme';
16
+ import { createLineChart } from '@vielzeug/prism';
17
+ import '@vielzeug/prism/theme.css';
18
18
 
19
- // Optional: apply a custom color palette at startup
20
- setTheme({ colors: ['#6366f1', '#22d3ee', '#f59e0b', '#10b981'] });
19
+ const host = document.createElement('div');
20
+ host.style.cssText = 'width:640px;height:320px';
21
+ document.body.append(host);
21
22
 
22
- let series = [
23
- {
23
+ const chart = createLineChart(host, {
24
+ a11y: { ariaLabel: 'Revenue by month' },
25
+ series: [{
24
26
  color: '#3b82f6',
25
- data: [
26
- { key: 1, value: 10 },
27
- { key: 2, value: 25 },
28
- { key: 3, value: 18 },
29
- { key: 4, value: 32 },
30
- ],
27
+ data: [{ key: 1, value: 10 }, { key: 2, value: 25 }, { key: 3, value: 18 }, { key: 4, value: 32 }],
31
28
  name: 'Revenue',
32
- },
33
- ];
34
-
35
- const chart = createLineChart(document.getElementById('chart')!, {
36
- a11y: { ariaLabel: 'Revenue by month' },
37
- series,
38
- xAxis: { position: 'bottom' },
39
- yAxis: { position: 'left', grid: true },
29
+ }],
40
30
  tooltip: true,
41
- crosshair: true,
42
- onHover: (event) => console.log(event?.datum),
43
31
  });
44
32
 
45
- // Replace data explicitly when application state changes
46
- series = [{ ...series[0]!, data: [...series[0]!.data, { key: 5, value: 28 }] }];
47
- chart.update(series);
33
+ chart.update([{
34
+ color: '#3b82f6',
35
+ data: [{ key: 1, value: 10 }, { key: 2, value: 25 }, { key: 3, value: 18 }, { key: 4, value: 32 }, { key: 5, value: 28 }],
36
+ name: 'Revenue',
37
+ }]);
48
38
 
49
- // Cleanup (also works with TC39 `using` declarations)
50
39
  chart.dispose();
51
40
  ```
52
41
 
@@ -1,2 +1,2 @@
1
- var e={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}exports.easings=e,exports.resolveEasing=resolveEasing;
1
+ var e={"back-out":e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,"ease-in":e=>e*e*e,"ease-in-out":e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,"ease-out":e=>1-(1-e)**3,"expo-out":e=>e>=1?1:1-2**(-10*e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}exports.easings=e,exports.resolveEasing=resolveEasing;
2
2
  //# sourceMappingURL=easing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.cjs","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`): a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":"AAEA,IAAa,EAAoC,CAC/C,UAAY,GAAM,EAAI,EACtB,cAAgB,GAAO,EAAI,GAAM,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACrE,WAAa,GAAM,GAAK,EAAI,IAAM,EAAI,GACtC,OAAS,GAAM,CACjB,EAEA,SAAgB,cAAc,EAAgE,CAS5F,OARI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAAU,EAAQ,GAEpE,EAAQ,WACjB"}
1
+ {"version":3,"file":"easing.cjs","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\n/** Overshoot coefficient behind CSS `cubic-bezier(.34, 1.56, .64, 1)`. */\nconst BACK_OVERSHOOT = 1.70158;\n\n/**\n * The named curves a {@link TransitionConfig} can select. The `ease-*` curves are cubic,\n * matching the feel of the CSS easing keywords; `expo-out` decelerates hard for data\n * reveals and `back-out` overshoots slightly for bar entrances.\n */\nexport const easings = {\n 'back-out': (t: number) => 1 + (BACK_OVERSHOOT + 1) * (t - 1) ** 3 + BACK_OVERSHOOT * (t - 1) ** 2,\n 'ease-in': (t: number) => t * t * t,\n 'ease-in-out': (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),\n 'ease-out': (t: number) => 1 - (1 - t) ** 3,\n 'expo-out': (t: number) => (t >= 1 ? 1 : 1 - 2 ** (-10 * t)),\n linear: (t: number) => t,\n} satisfies Record<string, EasingFn>;\n\n/** The literal names {@link resolveEasing} accepts, derived from {@link easings}. */\nexport type EasingName = keyof typeof easings;\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`): a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) {\n return (easings as Record<string, EasingFn>)[easing];\n }\n\n return easings['ease-out'];\n}\n"],"mappings":"AAGA,IAOa,EAAU,CACrB,WAAa,GAAc,EAAK,SAAuB,EAAI,IAAM,EAAI,SAAkB,EAAI,IAAM,EACjG,UAAY,GAAc,EAAI,EAAI,EAClC,cAAgB,GAAe,EAAI,GAAM,EAAI,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACjF,WAAa,GAAc,GAAK,EAAI,IAAM,EAC1C,WAAa,GAAe,GAAK,EAAI,EAAI,EAAI,IAAM,IAAM,GACzD,OAAS,GAAc,CACzB,EAKA,SAAgB,cAAc,EAAgE,CAW5F,OAVI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAC/C,EAAqC,GAGxC,EAAQ,WACjB"}
@@ -1,4 +1,18 @@
1
1
  export type EasingFn = (t: number) => number;
2
- export declare const easings: Record<string, EasingFn>;
2
+ /**
3
+ * The named curves a {@link TransitionConfig} can select. The `ease-*` curves are cubic,
4
+ * matching the feel of the CSS easing keywords; `expo-out` decelerates hard for data
5
+ * reveals and `back-out` overshoots slightly for bar entrances.
6
+ */
7
+ export declare const easings: {
8
+ 'back-out': (t: number) => number;
9
+ 'ease-in': (t: number) => number;
10
+ 'ease-in-out': (t: number) => number;
11
+ 'ease-out': (t: number) => number;
12
+ 'expo-out': (t: number) => number;
13
+ linear: (t: number) => number;
14
+ };
15
+ /** The literal names {@link resolveEasing} accepts, derived from {@link easings}. */
16
+ export type EasingName = keyof typeof easings;
3
17
  export declare function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn;
4
18
  //# sourceMappingURL=easing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/animation/easing.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE7C,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAK5C,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,GAAG,QAAQ,CAU5F"}
1
+ {"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/animation/easing.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAK7C;;;;GAIG;AACH,eAAO,MAAM,OAAO;oBACF,MAAM;mBACP,MAAM;uBACF,MAAM;oBACT,MAAM;oBACN,MAAM;gBACV,MAAM;CACgB,CAAC;AAErC,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,OAAO,CAAC;AAE9C,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,GAAG,QAAQ,CAY5F"}
@@ -1,2 +1,2 @@
1
- var e={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}export{e as easings,resolveEasing};
1
+ var e={"back-out":e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,"ease-in":e=>e*e*e,"ease-in-out":e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,"ease-out":e=>1-(1-e)**3,"expo-out":e=>e>=1?1:1-2**(-10*e),linear:e=>e};function resolveEasing(t){return typeof t==`function`?t:t!==void 0&&Object.hasOwn(e,t)?e[t]:e[`ease-out`]}export{e as easings,resolveEasing};
2
2
  //# sourceMappingURL=easing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"easing.js","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\nexport const easings: Record<string, EasingFn> = {\n 'ease-in': (t) => t * t,\n 'ease-in-out': (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),\n 'ease-out': (t) => 1 - (1 - t) * (1 - t),\n linear: (t) => t,\n};\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`): a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) return easings[easing];\n\n return easings['ease-out'];\n}\n"],"mappings":"AAEA,IAAa,EAAoC,CAC/C,UAAY,GAAM,EAAI,EACtB,cAAgB,GAAO,EAAI,GAAM,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACrE,WAAa,GAAM,GAAK,EAAI,IAAM,EAAI,GACtC,OAAS,GAAM,CACjB,EAEA,SAAgB,cAAc,EAAgE,CAS5F,OARI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAAU,EAAQ,GAEpE,EAAQ,WACjB"}
1
+ {"version":3,"file":"easing.js","names":[],"sources":["../../src/animation/easing.ts"],"sourcesContent":["export type EasingFn = (t: number) => number;\n\n/** Overshoot coefficient behind CSS `cubic-bezier(.34, 1.56, .64, 1)`. */\nconst BACK_OVERSHOOT = 1.70158;\n\n/**\n * The named curves a {@link TransitionConfig} can select. The `ease-*` curves are cubic,\n * matching the feel of the CSS easing keywords; `expo-out` decelerates hard for data\n * reveals and `back-out` overshoots slightly for bar entrances.\n */\nexport const easings = {\n 'back-out': (t: number) => 1 + (BACK_OVERSHOOT + 1) * (t - 1) ** 3 + BACK_OVERSHOOT * (t - 1) ** 2,\n 'ease-in': (t: number) => t * t * t,\n 'ease-in-out': (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),\n 'ease-out': (t: number) => 1 - (1 - t) ** 3,\n 'expo-out': (t: number) => (t >= 1 ? 1 : 1 - 2 ** (-10 * t)),\n linear: (t: number) => t,\n} satisfies Record<string, EasingFn>;\n\n/** The literal names {@link resolveEasing} accepts, derived from {@link easings}. */\nexport type EasingName = keyof typeof easings;\n\nexport function resolveEasing(easing: string | ((t: number) => number) | undefined): EasingFn {\n if (typeof easing === 'function') return easing;\n\n // `Object.hasOwn` guards against `easing` being a prototype-chain key (e.g. `'__proto__'`,\n // `'constructor'`): a plain bracket lookup on those would silently resolve to an\n // `Object.prototype` value instead of `undefined`, which is either not callable (throws)\n // or callable but not an easing function (produces garbage interpolation).\n if (easing !== undefined && Object.hasOwn(easings, easing)) {\n return (easings as Record<string, EasingFn>)[easing];\n }\n\n return easings['ease-out'];\n}\n"],"mappings":"AAGA,IAOa,EAAU,CACrB,WAAa,GAAc,EAAK,SAAuB,EAAI,IAAM,EAAI,SAAkB,EAAI,IAAM,EACjG,UAAY,GAAc,EAAI,EAAI,EAClC,cAAgB,GAAe,EAAI,GAAM,EAAI,EAAI,EAAI,EAAI,GAAK,GAAK,EAAI,IAAM,EAAI,EACjF,WAAa,GAAc,GAAK,EAAI,IAAM,EAC1C,WAAa,GAAe,GAAK,EAAI,EAAI,EAAI,IAAM,IAAM,GACzD,OAAS,GAAc,CACzB,EAKA,SAAgB,cAAc,EAAgE,CAW5F,OAVI,OAAO,GAAW,WAAmB,EAMrC,IAAW,IAAA,IAAa,OAAO,OAAO,EAAS,CAAM,EAC/C,EAAqC,GAGxC,EAAQ,WACjB"}
@@ -1,2 +1,2 @@
1
- function resolveMotion(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}exports.resolveMotion=resolveMotion;
1
+ function resolveMotion(e,t){if(e===!1)return{duration:0,stagger:0};let n=e===!0?void 0:e,r=n?.preference??`system`,i=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=r===`never`||r===`system`&&i?0:n?.duration??t?.defaultDuration??300;return{...n,duration:a,stagger:Math.max(0,n?.stagger??t?.defaultStagger??0)}}exports.resolveMotion=resolveMotion;
2
2
  //# sourceMappingURL=motion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.cjs","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":"AAEA,SAAgB,cACd,EACA,EAAkB,IAC2D,CAC7E,IAAM,EAAa,GAAQ,YAAc,SACnC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAAW,EAAK,GAAQ,UAAY,EAE5F,MAAO,CAAE,GAAG,EAAQ,WAAU,QAAS,KAAK,IAAI,EAAG,GAAQ,SAAW,CAAC,CAAE,CAC3E"}
1
+ {"version":3,"file":"motion.cjs","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig, TransitionOption } from '../types';\n\n/** Duration (ms) every chart uses when motion is enabled without an explicit `duration`. */\nexport const DEFAULT_DURATION = 300;\n\n/**\n * Resolves a user-facing `transition` option into concrete motion values.\n *\n * - `false` disables motion entirely: renderers apply their final state synchronously.\n * - `true` (or omitted) enables motion with the chart's `defaultDuration`/`defaultStagger`.\n * - `preference: 'system'` (the default) disables motion when the user prefers reduced motion.\n */\nexport function resolveMotion(\n config?: TransitionOption,\n defaults?: { defaultDuration?: number; defaultStagger?: number },\n): TransitionConfig & { duration: number; stagger: number } {\n if (config === false) return { duration: 0, stagger: 0 };\n\n const options = config === true ? undefined : config;\n const preference = options?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced)\n ? 0\n : (options?.duration ?? defaults?.defaultDuration ?? DEFAULT_DURATION);\n\n return { ...options, duration, stagger: Math.max(0, options?.stagger ?? defaults?.defaultStagger ?? 0) };\n}\n"],"mappings":"AAYA,SAAgB,cACd,EACA,EAC0D,CAC1D,GAAI,IAAW,GAAO,MAAO,CAAE,SAAU,EAAG,QAAS,CAAE,EAEvD,IAAM,EAAU,IAAW,GAAO,IAAA,GAAY,EACxC,EAAa,GAAS,YAAc,SACpC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAClD,EACC,GAAS,UAAY,GAAU,iBAAA,IAEtC,MAAO,CAAE,GAAG,EAAS,WAAU,QAAS,KAAK,IAAI,EAAG,GAAS,SAAW,GAAU,gBAAkB,CAAC,CAAE,CACzG"}
@@ -1,3 +1,18 @@
1
- import type { TransitionConfig } from '../types';
2
- export declare function resolveMotion(config?: TransitionConfig, defaultDuration?: number): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig;
1
+ import type { TransitionConfig, TransitionOption } from '../types';
2
+ /** Duration (ms) every chart uses when motion is enabled without an explicit `duration`. */
3
+ export declare const DEFAULT_DURATION = 300;
4
+ /**
5
+ * Resolves a user-facing `transition` option into concrete motion values.
6
+ *
7
+ * - `false` disables motion entirely: renderers apply their final state synchronously.
8
+ * - `true` (or omitted) enables motion with the chart's `defaultDuration`/`defaultStagger`.
9
+ * - `preference: 'system'` (the default) disables motion when the user prefers reduced motion.
10
+ */
11
+ export declare function resolveMotion(config?: TransitionOption, defaults?: {
12
+ defaultDuration?: number;
13
+ defaultStagger?: number;
14
+ }): TransitionConfig & {
15
+ duration: number;
16
+ stagger: number;
17
+ };
3
18
  //# sourceMappingURL=motion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/animation/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,gBAAgB,EACzB,eAAe,SAAM,GACpB,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC,GAAG,gBAAgB,CAO7E"}
1
+ {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/animation/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnE,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D,gBAAgB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAY1D"}
@@ -1,2 +1,2 @@
1
- function resolveMotion(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}export{resolveMotion};
1
+ function resolveMotion(e,t){if(e===!1)return{duration:0,stagger:0};let n=e===!0?void 0:e,r=n?.preference??`system`,i=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=r===`never`||r===`system`&&i?0:n?.duration??t?.defaultDuration??300;return{...n,duration:a,stagger:Math.max(0,n?.stagger??t?.defaultStagger??0)}}export{resolveMotion};
2
2
  //# sourceMappingURL=motion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.js","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nexport function resolveMotion(\n config?: TransitionConfig,\n defaultDuration = 300,\n): Required<Pick<TransitionConfig, 'duration' | 'stagger'>> & TransitionConfig {\n const preference = config?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced) ? 0 : (config?.duration ?? defaultDuration);\n\n return { ...config, duration, stagger: Math.max(0, config?.stagger ?? 0) };\n}\n"],"mappings":"AAEA,SAAgB,cACd,EACA,EAAkB,IAC2D,CAC7E,IAAM,EAAa,GAAQ,YAAc,SACnC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAAW,EAAK,GAAQ,UAAY,EAE5F,MAAO,CAAE,GAAG,EAAQ,WAAU,QAAS,KAAK,IAAI,EAAG,GAAQ,SAAW,CAAC,CAAE,CAC3E"}
1
+ {"version":3,"file":"motion.js","names":[],"sources":["../../src/animation/motion.ts"],"sourcesContent":["import type { TransitionConfig, TransitionOption } from '../types';\n\n/** Duration (ms) every chart uses when motion is enabled without an explicit `duration`. */\nexport const DEFAULT_DURATION = 300;\n\n/**\n * Resolves a user-facing `transition` option into concrete motion values.\n *\n * - `false` disables motion entirely: renderers apply their final state synchronously.\n * - `true` (or omitted) enables motion with the chart's `defaultDuration`/`defaultStagger`.\n * - `preference: 'system'` (the default) disables motion when the user prefers reduced motion.\n */\nexport function resolveMotion(\n config?: TransitionOption,\n defaults?: { defaultDuration?: number; defaultStagger?: number },\n): TransitionConfig & { duration: number; stagger: number } {\n if (config === false) return { duration: 0, stagger: 0 };\n\n const options = config === true ? undefined : config;\n const preference = options?.preference ?? 'system';\n const reduced = typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n const duration =\n preference === 'never' || (preference === 'system' && reduced)\n ? 0\n : (options?.duration ?? defaults?.defaultDuration ?? DEFAULT_DURATION);\n\n return { ...options, duration, stagger: Math.max(0, options?.stagger ?? defaults?.defaultStagger ?? 0) };\n}\n"],"mappings":"AAYA,SAAgB,cACd,EACA,EAC0D,CAC1D,GAAI,IAAW,GAAO,MAAO,CAAE,SAAU,EAAG,QAAS,CAAE,EAEvD,IAAM,EAAU,IAAW,GAAO,IAAA,GAAY,EACxC,EAAa,GAAS,YAAc,SACpC,EAAU,OAAO,WAAe,KAAe,WAAW,kCAAkC,CAAC,CAAC,QAC9F,EACJ,IAAe,SAAY,IAAe,UAAY,EAClD,EACC,GAAS,UAAY,GAAU,iBAAA,IAEtC,MAAO,CAAE,GAAG,EAAS,WAAU,QAAS,KAAK,IAAI,EAAG,GAAS,SAAW,GAAU,gBAAkB,CAAC,CAAE,CACzG"}
@@ -0,0 +1,2 @@
1
+ const e=require("../svg/element.cjs"),t=require("./easing.cjs"),n=require("./transition.cjs"),r=require("../core/ids.cjs");var i=new WeakMap;function cancelReveal(e){i.get(e)?.()}function playTraceReveal(a,o,s,c,l,u){if(cancelReveal(a),l.duration<=0||u?.aborted)return()=>{};let d=r.uniqueId(`prism-trace`),f=e.createSvgElement(`defs`),p=c/2,m=e.createSvgElement(`mask`,{height:o.height+c,id:d,maskContentUnits:`userSpaceOnUse`,maskUnits:`userSpaceOnUse`,width:o.width+c,x:-p,y:-p}),h=s.map(({d:t})=>{let n=e.createSvgElement(`path`,{d:t,fill:`none`,pathLength:1,stroke:`white`,"stroke-dasharray":`1 1`,"stroke-dashoffset":1,"stroke-width":c});return m.appendChild(n),n});f.appendChild(m),a.insertBefore(f,a.firstChild),a.setAttribute(`mask`,`url(#${d})`);let cancelTween=()=>{},finish=()=>{i.delete(a),a.removeAttribute(`mask`),f.remove(),u?.removeEventListener(`abort`,finish),cancelTween()};return i.set(a,finish),u?.addEventListener(`abort`,finish,{once:!0}),cancelTween=n.startTween({count:1,duration:l.duration,easing:t.resolveEasing(l.easing),onComplete:finish,onFrame:e=>{let t=e(0);for(let[e,n]of h.entries()){let{start:r,end:i}=s[e],a=Math.max(0,Math.min(1,(t-r)/(i-r)));n.setAttribute(`stroke-dashoffset`,String(1-a))}},signal:u}),finish}function playGrowReveal(a,o,s,c,l){if(cancelReveal(a),s(),c.duration<=0||o.length===0||l.signal?.aborted)return()=>{};let u=r.uniqueId(`prism-reveal`),d=e.createSvgElement(`defs`),f=e.createSvgElement(`clipPath`,{id:u}),p=o.map(t=>{let n=e.createSvgElement(`rect`,{height:0,width:0,x:t.x,y:t.y});return f.appendChild(n),n});d.appendChild(f),a.insertBefore(d,a.firstChild),a.setAttribute(`clip-path`,`url(#${u})`);let cancelTween=()=>{},finish=()=>{i.delete(a),a.removeAttribute(`clip-path`),d.remove(),l.signal?.removeEventListener(`abort`,finish),cancelTween()};return i.set(a,finish),l.signal?.addEventListener(`abort`,finish,{once:!0}),cancelTween=n.startTween({count:o.length,duration:c.duration,easing:t.resolveEasing(c.easing),onComplete:finish,onFrame:t=>{for(let[n,r]of p.entries()){let i=o[n],a=Math.max(0,Math.min(1,t(n)));if(l.axis===`y`){let t=i.anchor+(i.y-i.anchor)*a,n=i.anchor+(i.y+i.height-i.anchor)*a;e.setAttributes(r,{height:Math.max(0,n-t),width:i.width,y:t})}else{let t=i.anchor+(i.x-i.anchor)*a,n=i.anchor+(i.x+i.width-i.anchor)*a;e.setAttributes(r,{height:i.height,width:Math.max(0,n-t),x:t})}}},signal:l.signal,stagger:l.stagger}),finish}exports.cancelReveal=cancelReveal,exports.playGrowReveal=playGrowReveal,exports.playTraceReveal=playTraceReveal;
2
+ //# sourceMappingURL=reveal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal.cjs","names":[],"sources":["../../src/animation/reveal.ts"],"sourcesContent":["import { uniqueId } from '../core/ids';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport type { TransitionConfig } from '../types';\nimport { resolveEasing } from './easing';\nimport { startTween } from './transition';\n\nconst activeReveals = new WeakMap<Element, () => void>();\n\nexport function cancelReveal(parent: Element): void {\n activeReveals.get(parent)?.();\n}\n\n/** Traces final line geometry without replacing its dash or per-datum styling. */\nexport function playTraceReveal(\n parent: SVGGElement,\n bounds: { height: number; width: number },\n paths: readonly { d: string; end: number; start: number }[],\n strokeWidth: number,\n motion: TransitionConfig & { duration: number },\n signal?: AbortSignal,\n): () => void {\n cancelReveal(parent);\n if (motion.duration <= 0 || signal?.aborted) return () => {};\n\n const maskId = uniqueId('prism-trace');\n const host = createSvgElement('defs');\n const padding = strokeWidth / 2;\n const mask = createSvgElement('mask', {\n height: bounds.height + strokeWidth,\n id: maskId,\n maskContentUnits: 'userSpaceOnUse',\n maskUnits: 'userSpaceOnUse',\n width: bounds.width + strokeWidth,\n x: -padding,\n y: -padding,\n });\n const traces = paths.map(({ d }) => {\n const trace = createSvgElement('path', {\n d,\n fill: 'none',\n pathLength: 1,\n stroke: 'white',\n 'stroke-dasharray': '1 1',\n 'stroke-dashoffset': 1,\n 'stroke-width': strokeWidth,\n });\n mask.appendChild(trace);\n return trace;\n });\n host.appendChild(mask);\n parent.insertBefore(host, parent.firstChild);\n parent.setAttribute('mask', `url(#${maskId})`);\n\n let cancelTween: () => void = () => {};\n const finish = (): void => {\n activeReveals.delete(parent);\n parent.removeAttribute('mask');\n host.remove();\n signal?.removeEventListener('abort', finish);\n cancelTween();\n };\n activeReveals.set(parent, finish);\n signal?.addEventListener('abort', finish, { once: true });\n cancelTween = startTween({\n count: 1,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete: finish,\n onFrame: (progress) => {\n const e = progress(0);\n for (const [i, trace] of traces.entries()) {\n const { start, end } = paths[i];\n const revealed = Math.max(0, Math.min(1, (e - start) / (end - start)));\n trace.setAttribute('stroke-dashoffset', String(1 - revealed));\n }\n },\n signal,\n });\n return finish;\n}\n\nexport interface GrowRevealLane {\n anchor: number;\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\n/** Reveals finished bars from their own baseline without distorting rounded corners. */\nexport function playGrowReveal(\n parent: SVGGElement,\n lanes: readonly GrowRevealLane[],\n paintFinal: () => void,\n motion: TransitionConfig & { duration: number },\n options: { axis: 'x' | 'y'; signal?: AbortSignal; stagger?: number },\n): () => void {\n cancelReveal(parent);\n paintFinal();\n if (motion.duration <= 0 || lanes.length === 0 || options.signal?.aborted) return () => {};\n\n const clipId = uniqueId('prism-reveal');\n const host = createSvgElement('defs');\n const clipPath = createSvgElement('clipPath', { id: clipId });\n const rects = lanes.map((lane) => {\n const rect = createSvgElement('rect', { height: 0, width: 0, x: lane.x, y: lane.y });\n clipPath.appendChild(rect);\n return rect;\n });\n host.appendChild(clipPath);\n parent.insertBefore(host, parent.firstChild);\n parent.setAttribute('clip-path', `url(#${clipId})`);\n\n let cancelTween: () => void = () => {};\n const finish = (): void => {\n activeReveals.delete(parent);\n parent.removeAttribute('clip-path');\n host.remove();\n options.signal?.removeEventListener('abort', finish);\n cancelTween();\n };\n activeReveals.set(parent, finish);\n options.signal?.addEventListener('abort', finish, { once: true });\n cancelTween = startTween({\n count: lanes.length,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete: finish,\n onFrame: (progress) => {\n for (const [i, rect] of rects.entries()) {\n const lane = lanes[i];\n const e = Math.max(0, Math.min(1, progress(i)));\n if (options.axis === 'y') {\n const top = lane.anchor + (lane.y - lane.anchor) * e;\n const bottom = lane.anchor + (lane.y + lane.height - lane.anchor) * e;\n setAttributes(rect, { height: Math.max(0, bottom - top), width: lane.width, y: top });\n } else {\n const left = lane.anchor + (lane.x - lane.anchor) * e;\n const right = lane.anchor + (lane.x + lane.width - lane.anchor) * e;\n setAttributes(rect, { height: lane.height, width: Math.max(0, right - left), x: left });\n }\n }\n },\n signal: options.signal,\n stagger: options.stagger,\n });\n return finish;\n}\n"],"mappings":"2HAMA,IAAM,EAAgB,IAAI,QAE1B,SAAgB,aAAa,EAAuB,CAClD,EAAc,IAAI,CAAM,CAAC,GAAG,CAC9B,CAGA,SAAgB,gBACd,EACA,EACA,EACA,EACA,EACA,EACY,CAEZ,GADA,aAAa,CAAM,EACf,EAAO,UAAY,GAAK,GAAQ,QAAS,UAAa,CAAC,EAE3D,IAAM,EAAS,EAAA,SAAS,aAAa,EAC/B,EAAO,EAAA,iBAAiB,MAAM,EAC9B,EAAU,EAAc,EACxB,EAAO,EAAA,iBAAiB,OAAQ,CACpC,OAAQ,EAAO,OAAS,EACxB,GAAI,EACJ,iBAAkB,iBAClB,UAAW,iBACX,MAAO,EAAO,MAAQ,EACtB,EAAG,CAAC,EACJ,EAAG,CAAC,CACN,CAAC,EACK,EAAS,EAAM,KAAK,CAAE,OAAQ,CAClC,IAAM,EAAQ,EAAA,iBAAiB,OAAQ,CACrC,IACA,KAAM,OACN,WAAY,EACZ,OAAQ,QACR,mBAAoB,MACpB,oBAAqB,EACrB,eAAgB,CAClB,CAAC,EAED,OADA,EAAK,YAAY,CAAK,EACf,CACT,CAAC,EACD,EAAK,YAAY,CAAI,EACrB,EAAO,aAAa,EAAM,EAAO,UAAU,EAC3C,EAAO,aAAa,OAAQ,QAAQ,EAAO,EAAE,EAE7C,IAAI,gBAAgC,CAAC,EAC/B,WAAqB,CACzB,EAAc,OAAO,CAAM,EAC3B,EAAO,gBAAgB,MAAM,EAC7B,EAAK,OAAO,EACZ,GAAQ,oBAAoB,QAAS,MAAM,EAC3C,YAAY,CACd,EAkBA,OAjBA,EAAc,IAAI,EAAQ,MAAM,EAChC,GAAQ,iBAAiB,QAAS,OAAQ,CAAE,KAAM,EAAK,CAAC,EACxD,YAAc,EA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M,EAAK,CAAC,EAChE,YAAc,EAAA,WAAW,CACvB,MAAO,EAAM,OACb,SAAU,EAAO,SACjB,OAAQ,EAAA,cAAc,EAAO,MAAM,EACnC,WAAY,OACZ,QAAU,GAAa,CACrB,IAAK,GAAM,CAAC,EAAG,KAAS,EAAM,QAAQ,EAAG,CACvC,IAAM,EAAO,EAAM,GACb,EAAI,KAAK,IAAI,EAAG,KAAK,IAAI,EAAG,EAAS,CAAC,CAAC,CAAC,EAC9C,GAAI,EAAQ,OAAS,IAAK,CACxB,IAAM,EAAM,EAAK,QAAU,EAAK,EAAI,EAAK,QAAU,EAC7C,EAAS,EAAK,QAAU,EAAK,EAAI,EAAK,OAAS,EAAK,QAAU,EACpE,EAAA,cAAc,EAAM,CAAE,OAAQ,KAAK,IAAI,EAAG,EAAS,CAAG,EAAG,MAAO,EAAK,MAAO,EAAG,CAAI,CAAC,CACtF,KAAO,CACL,IAAM,EAAO,EAAK,QAAU,EAAK,EAAI,EAAK,QAAU,EAC9C,EAAQ,EAAK,QAAU,EAAK,EAAI,EAAK,MAAQ,EAAK,QAAU,EAClE,EAAA,cAAc,EAAM,CAAE,OAAQ,EAAK,OAAQ,MAAO,KAAK,IAAI,EAAG,EAAQ,CAAI,EAAG,EAAG,CAAK,CAAC,CACxF,CACF,CACF,EACA,OAAQ,EAAQ,OAChB,QAAS,EAAQ,OACnB,CAAC,EACM,MACT"}
@@ -0,0 +1,29 @@
1
+ import type { TransitionConfig } from '../types';
2
+ export declare function cancelReveal(parent: Element): void;
3
+ /** Traces final line geometry without replacing its dash or per-datum styling. */
4
+ export declare function playTraceReveal(parent: SVGGElement, bounds: {
5
+ height: number;
6
+ width: number;
7
+ }, paths: readonly {
8
+ d: string;
9
+ end: number;
10
+ start: number;
11
+ }[], strokeWidth: number, motion: TransitionConfig & {
12
+ duration: number;
13
+ }, signal?: AbortSignal): () => void;
14
+ export interface GrowRevealLane {
15
+ anchor: number;
16
+ height: number;
17
+ width: number;
18
+ x: number;
19
+ y: number;
20
+ }
21
+ /** Reveals finished bars from their own baseline without distorting rounded corners. */
22
+ export declare function playGrowReveal(parent: SVGGElement, lanes: readonly GrowRevealLane[], paintFinal: () => void, motion: TransitionConfig & {
23
+ duration: number;
24
+ }, options: {
25
+ axis: 'x' | 'y';
26
+ signal?: AbortSignal;
27
+ stagger?: number;
28
+ }): () => void;
29
+ //# sourceMappingURL=reveal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal.d.ts","sourceRoot":"","sources":["../../src/animation/reveal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMjD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAElD;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACzC,KAAK,EAAE,SAAS;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3D,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,gBAAgB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC/C,MAAM,CAAC,EAAE,WAAW,GACnB,MAAM,IAAI,CA2DZ;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,UAAU,EAAE,MAAM,IAAI,EACtB,MAAM,EAAE,gBAAgB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EAAE;IAAE,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,MAAM,IAAI,CAmDZ"}
@@ -0,0 +1,2 @@
1
+ import{createSvgElement as e,setAttributes as t}from"../svg/element.js";import{resolveEasing as n}from"./easing.js";import{startTween as r}from"./transition.js";import{uniqueId as i}from"../core/ids.js";var a=new WeakMap;function cancelReveal(e){a.get(e)?.()}function playTraceReveal(t,o,s,c,l,u){if(cancelReveal(t),l.duration<=0||u?.aborted)return()=>{};let d=i(`prism-trace`),f=e(`defs`),p=c/2,m=e(`mask`,{height:o.height+c,id:d,maskContentUnits:`userSpaceOnUse`,maskUnits:`userSpaceOnUse`,width:o.width+c,x:-p,y:-p}),h=s.map(({d:t})=>{let n=e(`path`,{d:t,fill:`none`,pathLength:1,stroke:`white`,"stroke-dasharray":`1 1`,"stroke-dashoffset":1,"stroke-width":c});return m.appendChild(n),n});f.appendChild(m),t.insertBefore(f,t.firstChild),t.setAttribute(`mask`,`url(#${d})`);let cancelTween=()=>{},finish=()=>{a.delete(t),t.removeAttribute(`mask`),f.remove(),u?.removeEventListener(`abort`,finish),cancelTween()};return a.set(t,finish),u?.addEventListener(`abort`,finish,{once:!0}),cancelTween=r({count:1,duration:l.duration,easing:n(l.easing),onComplete:finish,onFrame:e=>{let t=e(0);for(let[e,n]of h.entries()){let{start:r,end:i}=s[e],a=Math.max(0,Math.min(1,(t-r)/(i-r)));n.setAttribute(`stroke-dashoffset`,String(1-a))}},signal:u}),finish}function playGrowReveal(o,s,c,l,u){if(cancelReveal(o),c(),l.duration<=0||s.length===0||u.signal?.aborted)return()=>{};let d=i(`prism-reveal`),f=e(`defs`),p=e(`clipPath`,{id:d}),m=s.map(t=>{let n=e(`rect`,{height:0,width:0,x:t.x,y:t.y});return p.appendChild(n),n});f.appendChild(p),o.insertBefore(f,o.firstChild),o.setAttribute(`clip-path`,`url(#${d})`);let cancelTween=()=>{},finish=()=>{a.delete(o),o.removeAttribute(`clip-path`),f.remove(),u.signal?.removeEventListener(`abort`,finish),cancelTween()};return a.set(o,finish),u.signal?.addEventListener(`abort`,finish,{once:!0}),cancelTween=r({count:s.length,duration:l.duration,easing:n(l.easing),onComplete:finish,onFrame:e=>{for(let[n,r]of m.entries()){let i=s[n],a=Math.max(0,Math.min(1,e(n)));if(u.axis===`y`){let e=i.anchor+(i.y-i.anchor)*a,n=i.anchor+(i.y+i.height-i.anchor)*a;t(r,{height:Math.max(0,n-e),width:i.width,y:e})}else{let e=i.anchor+(i.x-i.anchor)*a,n=i.anchor+(i.x+i.width-i.anchor)*a;t(r,{height:i.height,width:Math.max(0,n-e),x:e})}}},signal:u.signal,stagger:u.stagger}),finish}export{cancelReveal,playGrowReveal,playTraceReveal};
2
+ //# sourceMappingURL=reveal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal.js","names":[],"sources":["../../src/animation/reveal.ts"],"sourcesContent":["import { uniqueId } from '../core/ids';\nimport { createSvgElement, setAttributes } from '../svg/element';\nimport type { TransitionConfig } from '../types';\nimport { resolveEasing } from './easing';\nimport { startTween } from './transition';\n\nconst activeReveals = new WeakMap<Element, () => void>();\n\nexport function cancelReveal(parent: Element): void {\n activeReveals.get(parent)?.();\n}\n\n/** Traces final line geometry without replacing its dash or per-datum styling. */\nexport function playTraceReveal(\n parent: SVGGElement,\n bounds: { height: number; width: number },\n paths: readonly { d: string; end: number; start: number }[],\n strokeWidth: number,\n motion: TransitionConfig & { duration: number },\n signal?: AbortSignal,\n): () => void {\n cancelReveal(parent);\n if (motion.duration <= 0 || signal?.aborted) return () => {};\n\n const maskId = uniqueId('prism-trace');\n const host = createSvgElement('defs');\n const padding = strokeWidth / 2;\n const mask = createSvgElement('mask', {\n height: bounds.height + strokeWidth,\n id: maskId,\n maskContentUnits: 'userSpaceOnUse',\n maskUnits: 'userSpaceOnUse',\n width: bounds.width + strokeWidth,\n x: -padding,\n y: -padding,\n });\n const traces = paths.map(({ d }) => {\n const trace = createSvgElement('path', {\n d,\n fill: 'none',\n pathLength: 1,\n stroke: 'white',\n 'stroke-dasharray': '1 1',\n 'stroke-dashoffset': 1,\n 'stroke-width': strokeWidth,\n });\n mask.appendChild(trace);\n return trace;\n });\n host.appendChild(mask);\n parent.insertBefore(host, parent.firstChild);\n parent.setAttribute('mask', `url(#${maskId})`);\n\n let cancelTween: () => void = () => {};\n const finish = (): void => {\n activeReveals.delete(parent);\n parent.removeAttribute('mask');\n host.remove();\n signal?.removeEventListener('abort', finish);\n cancelTween();\n };\n activeReveals.set(parent, finish);\n signal?.addEventListener('abort', finish, { once: true });\n cancelTween = startTween({\n count: 1,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete: finish,\n onFrame: (progress) => {\n const e = progress(0);\n for (const [i, trace] of traces.entries()) {\n const { start, end } = paths[i];\n const revealed = Math.max(0, Math.min(1, (e - start) / (end - start)));\n trace.setAttribute('stroke-dashoffset', String(1 - revealed));\n }\n },\n signal,\n });\n return finish;\n}\n\nexport interface GrowRevealLane {\n anchor: number;\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\n/** Reveals finished bars from their own baseline without distorting rounded corners. */\nexport function playGrowReveal(\n parent: SVGGElement,\n lanes: readonly GrowRevealLane[],\n paintFinal: () => void,\n motion: TransitionConfig & { duration: number },\n options: { axis: 'x' | 'y'; signal?: AbortSignal; stagger?: number },\n): () => void {\n cancelReveal(parent);\n paintFinal();\n if (motion.duration <= 0 || lanes.length === 0 || options.signal?.aborted) return () => {};\n\n const clipId = uniqueId('prism-reveal');\n const host = createSvgElement('defs');\n const clipPath = createSvgElement('clipPath', { id: clipId });\n const rects = lanes.map((lane) => {\n const rect = createSvgElement('rect', { height: 0, width: 0, x: lane.x, y: lane.y });\n clipPath.appendChild(rect);\n return rect;\n });\n host.appendChild(clipPath);\n parent.insertBefore(host, parent.firstChild);\n parent.setAttribute('clip-path', `url(#${clipId})`);\n\n let cancelTween: () => void = () => {};\n const finish = (): void => {\n activeReveals.delete(parent);\n parent.removeAttribute('clip-path');\n host.remove();\n options.signal?.removeEventListener('abort', finish);\n cancelTween();\n };\n activeReveals.set(parent, finish);\n options.signal?.addEventListener('abort', finish, { once: true });\n cancelTween = startTween({\n count: lanes.length,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete: finish,\n onFrame: (progress) => {\n for (const [i, rect] of rects.entries()) {\n const lane = lanes[i];\n const e = Math.max(0, Math.min(1, progress(i)));\n if (options.axis === 'y') {\n const top = lane.anchor + (lane.y - lane.anchor) * e;\n const bottom = lane.anchor + (lane.y + lane.height - lane.anchor) * e;\n setAttributes(rect, { height: Math.max(0, bottom - top), width: lane.width, y: top });\n } else {\n const left = lane.anchor + (lane.x - lane.anchor) * e;\n const right = lane.anchor + (lane.x + lane.width - lane.anchor) * e;\n setAttributes(rect, { height: lane.height, width: Math.max(0, right - left), x: left });\n }\n }\n },\n signal: options.signal,\n stagger: options.stagger,\n });\n return finish;\n}\n"],"mappings":"2MAMA,IAAM,EAAgB,IAAI,QAE1B,SAAgB,aAAa,EAAuB,CAClD,EAAc,IAAI,CAAM,CAAC,GAAG,CAC9B,CAGA,SAAgB,gBACd,EACA,EACA,EACA,EACA,EACA,EACY,CAEZ,GADA,aAAa,CAAM,EACf,EAAO,UAAY,GAAK,GAAQ,QAAS,UAAa,CAAC,EAE3D,IAAM,EAAS,EAAS,aAAa,EAC/B,EAAO,EAAiB,MAAM,EAC9B,EAAU,EAAc,EACxB,EAAO,EAAiB,OAAQ,CACpC,OAAQ,EAAO,OAAS,EACxB,GAAI,EACJ,iBAAkB,iBAClB,UAAW,iBACX,MAAO,EAAO,MAAQ,EACtB,EAAG,CAAC,EACJ,EAAG,CAAC,CACN,CAAC,EACK,EAAS,EAAM,KAAK,CAAE,OAAQ,CAClC,IAAM,EAAQ,EAAiB,OAAQ,CACrC,IACA,KAAM,OAC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CACF,CACF,EACA,OAAQ,EAAQ,OAChB,QAAS,EAAQ,OACnB,CAAC,EACM,MACT"}
@@ -1,2 +1,2 @@
1
- const e=require("../../svg/element.cjs"),t=require("../../axes/axis.cjs"),n=require("../../axes/grid.cjs"),r=require("../../core/cartesian-scales.cjs"),i=require("../../core/layout.cjs"),a=require("../../core/chart-scaffold.cjs"),o=require("../../core/series-id.cjs"),s=require("../../interaction/crosshair.cjs"),c=require("../../interaction/series-interaction.cjs"),l=require("../../theme/index.cjs"),u=require("./area-renderer.cjs");function createAreaChart(d,f){let p=null,m=null,h=f.series;return a.createChartScaffold(d,f,d=>{let{groups:g,legend:_,tooltip:v}=d,y=d.dimensions,b=i.chartArea(y.width,y.height,y.margin),x=h.map(e=>e.data),S=x.flat().map(e=>e.key),C=x.flat().map(e=>e.value);if(S.length===0){a.clearCartesianDom(g,_,v,p),m?.replaceChildren();return}f.crosshair&&!p&&(p=s.createCrosshair(d.chartArea,f.crosshair));let w=r.buildXScale(S,b.width),T=r.buildYScale(C,b.height),E=T.map(0);for(f.yAxis?.grid&&n.renderGrid(g.grid,T,f.yAxis.grid,b.width,`horizontal`,t.resolveTickCount(f.yAxis,b.height,`left`)),f.xAxis?.grid&&n.renderGrid(g.grid,w,f.xAxis.grid,b.height,`vertical`,t.resolveTickCount(f.xAxis,b.width,`bottom`)),f.xAxis&&(t.positionAxis(g.xAxis,f.xAxis.position??`bottom`,b.width,b.height),t.renderAxis(g.xAxis,w,f.xAxis,b.width,`bottom`)),f.yAxis&&(t.positionAxis(g.yAxis,f.yAxis.position??`left`,b.width,b.height),t.renderAxis(g.yAxis,T,f.yAxis,b.height,`left`));g.series.children.length>h.length;)g.series.removeChild(g.series.lastChild);let D=[];for(let t=0;t<h.length;t++){let n=h[t],r=g.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-area-series`}),g.series.appendChild(r)),r.setAttribute(`data-series-id`,o.seriesDomId(n,t));let i=u.computeAreaPoints(x[t],w,T);D.push(i),u.renderArea(r,i,E,{color:l.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:d.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:f.transition})}return _?.update(h.map((e,t)=>({color:l.seriesColor(t,e.color),name:e.name}))),v?.hide(),m=c.ensureMarkerGroup(d.chartArea,m),c.createSeriesInteraction({announcer:d.announcer,colors:()=>h.map((e,t)=>l.seriesColor(t,e.color)),crosshair:p,dims:()=>d.dimensions,getData:()=>x,getPoints:()=>D,getSeriesList:()=>h,margin:d.dimensions.margin,markers:m,onClick:f.onClick,onHover:f.onHover,seriesGroup:g.series,svg:d.svg,tooltip:v})},e=>{h=e})}exports.createAreaChart=createAreaChart;
1
+ const e=require("../../svg/element.cjs"),t=require("../../axes/axis.cjs"),n=require("../../axes/grid.cjs"),r=require("../../core/cartesian-scales.cjs"),i=require("../../core/layout.cjs"),a=require("../../core/chart-scaffold.cjs"),o=require("../../core/series-id.cjs"),s=require("../../interaction/crosshair.cjs"),c=require("../../interaction/series-interaction.cjs"),l=require("../../theme/index.cjs"),u=require("./area-renderer.cjs");function createAreaChart(d,f){let p=null,m=null,h=f.series;return a.createChartScaffold(d,f,d=>{let{groups:g,legend:_,tooltip:v}=d;_?.update(h.map((e,t)=>({color:l.seriesColor(t,e.color),name:e.name})));let y=d.dimensions,b=i.chartArea(y.width,y.height,y.margin),x=h.map(e=>e.data),S=x.flat().map(e=>e.key),C=x.flat().map(e=>e.value);if(S.length===0){a.clearCartesianDom(g,_,v,p),m?.replaceChildren();return}f.crosshair&&!p&&(p=s.createCrosshair(d.chartArea,f.crosshair));let w=r.buildXScale(S,b.width),T=r.buildYScale(C,b.height),E=T.map(0),D=f.xAxis===!1?!1:f.xAxis??{},O=f.yAxis===!1?!1:f.yAxis??{grid:!0};for(O&&O.grid&&n.renderGrid(g.grid,T,O.grid,b.width,`horizontal`,t.resolveTickCount(O,b.height,`left`)),D&&D.grid&&n.renderGrid(g.grid,w,D.grid,b.height,`vertical`,t.resolveTickCount(D,b.width,`bottom`)),D?(t.positionAxis(g.xAxis,D.position??`bottom`,b.width,b.height),t.renderAxis(g.xAxis,w,D,b.width,`bottom`)):g.xAxis.replaceChildren(),O?(t.positionAxis(g.yAxis,O.position??`left`,b.width,b.height),t.renderAxis(g.yAxis,T,O,b.height,`left`)):g.yAxis.replaceChildren();g.series.children.length>h.length;)g.series.removeChild(g.series.lastChild);let k=[];for(let t=0;t<h.length;t++){let n=h[t],r=g.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-area-series`}),g.series.appendChild(r)),r.setAttribute(`data-series-id`,o.seriesDomId(n,t));let i=u.computeAreaPoints(x[t],w,T);k.push(i),u.renderArea(r,i,E,{color:l.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:d.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:f.transition})}return v?.hide(),m=c.ensureMarkerGroup(d.chartArea,m),c.createSeriesInteraction({announcer:d.announcer,colors:()=>h.map((e,t)=>l.seriesColor(t,e.color)),crosshair:p,dims:()=>d.dimensions,getData:()=>x,getPoints:()=>k,getSeriesList:()=>h,margin:d.dimensions.margin,markers:m,onClick:f.onClick,onHover:f.onHover,seriesGroup:g.series,svg:d.svg,tooltip:v})},e=>{h=e})}exports.createAreaChart=createAreaChart;
2
2
  //# sourceMappingURL=area-chart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"area-chart.cjs","names":[],"sources":["../../../src/charts/area/area-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { seriesDomId } from '../../core/series-id';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction, ensureMarkerGroup } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { AreaChartConfig, AreaSeriesConfig, ChartHandle } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"mbAcA,SAAgB,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B,KAC9B,EAAa,EAAO,OAExB,OAAO,EAAA,oBACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAO,EAAA,UAAU,EAAK,MAAO,EAAK,OAAQ,EAAK,MAAM,EACrD,EAAU,EAAW,IAAK,GAAW,EAAO,IAAI,EAChD,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAU,EAAM,GAAG,EAC9C,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAM,EAAE,KAAK,EAE9C,GAAI,EA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EAAA,YAAY,EAAQ,CAAC,CAAC,EAE3D,IAAM,EAAS,EAAA,kBAAkB,EAAQ,GAAI,EAAQ,CAAM,EAE3D,EAAU,KAAK,CAAM,EAErB,EAAA,WAAW,EAAO,EAAQ,EAAW,CACnC,MAAO,EAAA,YAAY,EAAG,EAAO,KAAK,EAClC,MAAO,EAAO,OAAS,SACvB,eAAgB,EAAI,eACpB,KAAM,EAAO,MAAQ,WACrB,YAAa,EAAO,YACpB,MAAO,EAAO,KACd,SAAU,EAAO,WAAa,GAC9B,WAAY,EAAO,UACrB,CAAC,CACH,CAMA,OAJA,GAAQ,OAAO,EAAW,KAAK,EAAG,KAAO,CAAE,MAAO,EAAA,YAAY,EAAG,EAAE,KAAK,EAAG,KAAM,EAAE,IAAK,EAAE,CAAC,EAC3F,GAAS,KAAK,EACd,EAAU,EAAA,kBAAkB,EAAI,UAAW,CAAO,EAE3C,EAAA,wBAAwB,CAC7B,UAAW,EAAI,UACf,WAAc,EAAW,KAAK,EAAG,IAAM,EAAA,YAAY,EAAG,EAAE,KAAK,CAAC,EAC9D,YACA,SAAY,EAAI,WAChB,YAAe,EACf,cAAiB,EACjB,kBAAqB,EACrB,OAAQ,EAAI,WAAW,OACvB,UACA,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,YAAa,EAAO,OACpB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
1
+ {"version":3,"file":"area-chart.cjs","names":[],"sources":["../../../src/charts/area/area-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { seriesDomId } from '../../core/series-id';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction, ensureMarkerGroup } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { AreaChartConfig, AreaSeriesConfig, ChartHandle, XAxisConfig, YAxisConfig } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n // Axes render by default (value axis with gridlines); `false` opts out.\n const xAxisConfig: XAxisConfig | false = config.xAxis === false ? false : (config.xAxis ?? {});\n const yAxisConfig: YAxisConfig | false = config.yAxis === false ? false : (config.yAxis ?? { grid: true });\n\n if (yAxisConfig && yAxisConfig.grid) {\n renderGrid(\n groups.grid,\n yScale,\n yAxisConfig.grid,\n area.width,\n 'horizontal',\n resolveTickCount(yAxisConfig, area.height, 'left'),\n );\n }\n\n if (xAxisConfig && xAxisConfig.grid) {\n renderGrid(\n groups.grid,\n xScale,\n xAxisConfig.grid,\n area.height,\n 'vertical',\n resolveTickCount(xAxisConfig, area.width, 'bottom'),\n );\n }\n\n if (xAxisConfig) {\n positionAxis(groups.xAxis, xAxisConfig.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, xAxisConfig, area.width, 'bottom');\n } else {\n groups.xAxis.replaceChildren();\n }\n\n if (yAxisConfig) {\n positionAxis(groups.yAxis, yAxisConfig.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, yAxisConfig, area.height, 'left');\n } else {\n groups.yAxis.replaceChildren();\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"mbAcA,SAAgB,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B,KAC9B,EAAa,EAAO,OAExB,OAAO,EAAA,oBACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EACpC,GAAQ,OAAO,EAAW,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,CACf,CACF,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../src/charts/area/area-chart.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGlF,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,gBAAgB,EAAE,CAAC,CAyHhH"}
1
+ {"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../src/charts/area/area-chart.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAA4B,MAAM,aAAa,CAAC;AAG5G,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,gBAAgB,EAAE,CAAC,CAiIhH"}
@@ -1,2 +1,2 @@
1
- import{createSvgElement as e}from"../../svg/element.js";import{positionAxis as t,renderAxis as n,resolveTickCount as r}from"../../axes/axis.js";import{renderGrid as i}from"../../axes/grid.js";import{buildXScale as a,buildYScale as o}from"../../core/cartesian-scales.js";import{chartArea as s}from"../../core/layout.js";import{clearCartesianDom as c,createChartScaffold as l}from"../../core/chart-scaffold.js";import{seriesDomId as u}from"../../core/series-id.js";import{createCrosshair as d}from"../../interaction/crosshair.js";import{createSeriesInteraction as f,ensureMarkerGroup as p}from"../../interaction/series-interaction.js";import{seriesColor as m}from"../../theme/index.js";import{computeAreaPoints as h,renderArea as g}from"./area-renderer.js";function createAreaChart(_,v){let y=null,b=null,x=v.series;return l(_,v,l=>{let{groups:_,legend:S,tooltip:C}=l,w=l.dimensions,T=s(w.width,w.height,w.margin),E=x.map(e=>e.data),D=E.flat().map(e=>e.key),O=E.flat().map(e=>e.value);if(D.length===0){c(_,S,C,y),b?.replaceChildren();return}v.crosshair&&!y&&(y=d(l.chartArea,v.crosshair));let k=a(D,T.width),A=o(O,T.height),j=A.map(0);for(v.yAxis?.grid&&i(_.grid,A,v.yAxis.grid,T.width,`horizontal`,r(v.yAxis,T.height,`left`)),v.xAxis?.grid&&i(_.grid,k,v.xAxis.grid,T.height,`vertical`,r(v.xAxis,T.width,`bottom`)),v.xAxis&&(t(_.xAxis,v.xAxis.position??`bottom`,T.width,T.height),n(_.xAxis,k,v.xAxis,T.width,`bottom`)),v.yAxis&&(t(_.yAxis,v.yAxis.position??`left`,T.width,T.height),n(_.yAxis,A,v.yAxis,T.height,`left`));_.series.children.length>x.length;)_.series.removeChild(_.series.lastChild);let M=[];for(let t=0;t<x.length;t++){let n=x[t],r=_.series.children[t];r||(r=e(`g`,{class:`prism-area-series`}),_.series.appendChild(r)),r.setAttribute(`data-series-id`,u(n,t));let i=h(E[t],k,A);M.push(i),g(r,i,j,{color:m(t,n.color),curve:n.curve??`linear`,disposalSignal:l.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:v.transition})}return S?.update(x.map((e,t)=>({color:m(t,e.color),name:e.name}))),C?.hide(),b=p(l.chartArea,b),f({announcer:l.announcer,colors:()=>x.map((e,t)=>m(t,e.color)),crosshair:y,dims:()=>l.dimensions,getData:()=>E,getPoints:()=>M,getSeriesList:()=>x,margin:l.dimensions.margin,markers:b,onClick:v.onClick,onHover:v.onHover,seriesGroup:_.series,svg:l.svg,tooltip:C})},e=>{x=e})}export{createAreaChart};
1
+ import{createSvgElement as e}from"../../svg/element.js";import{positionAxis as t,renderAxis as n,resolveTickCount as r}from"../../axes/axis.js";import{renderGrid as i}from"../../axes/grid.js";import{buildXScale as a,buildYScale as o}from"../../core/cartesian-scales.js";import{chartArea as s}from"../../core/layout.js";import{clearCartesianDom as c,createChartScaffold as l}from"../../core/chart-scaffold.js";import{seriesDomId as u}from"../../core/series-id.js";import{createCrosshair as d}from"../../interaction/crosshair.js";import{createSeriesInteraction as f,ensureMarkerGroup as p}from"../../interaction/series-interaction.js";import{seriesColor as m}from"../../theme/index.js";import{computeAreaPoints as h,renderArea as g}from"./area-renderer.js";function createAreaChart(_,v){let y=null,b=null,x=v.series;return l(_,v,l=>{let{groups:_,legend:S,tooltip:C}=l;S?.update(x.map((e,t)=>({color:m(t,e.color),name:e.name})));let w=l.dimensions,T=s(w.width,w.height,w.margin),E=x.map(e=>e.data),D=E.flat().map(e=>e.key),O=E.flat().map(e=>e.value);if(D.length===0){c(_,S,C,y),b?.replaceChildren();return}v.crosshair&&!y&&(y=d(l.chartArea,v.crosshair));let k=a(D,T.width),A=o(O,T.height),j=A.map(0),M=v.xAxis===!1?!1:v.xAxis??{},N=v.yAxis===!1?!1:v.yAxis??{grid:!0};for(N&&N.grid&&i(_.grid,A,N.grid,T.width,`horizontal`,r(N,T.height,`left`)),M&&M.grid&&i(_.grid,k,M.grid,T.height,`vertical`,r(M,T.width,`bottom`)),M?(t(_.xAxis,M.position??`bottom`,T.width,T.height),n(_.xAxis,k,M,T.width,`bottom`)):_.xAxis.replaceChildren(),N?(t(_.yAxis,N.position??`left`,T.width,T.height),n(_.yAxis,A,N,T.height,`left`)):_.yAxis.replaceChildren();_.series.children.length>x.length;)_.series.removeChild(_.series.lastChild);let P=[];for(let t=0;t<x.length;t++){let n=x[t],r=_.series.children[t];r||(r=e(`g`,{class:`prism-area-series`}),_.series.appendChild(r)),r.setAttribute(`data-series-id`,u(n,t));let i=h(E[t],k,A);P.push(i),g(r,i,j,{color:m(t,n.color),curve:n.curve??`linear`,disposalSignal:l.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:v.transition})}return C?.hide(),b=p(l.chartArea,b),f({announcer:l.announcer,colors:()=>x.map((e,t)=>m(t,e.color)),crosshair:y,dims:()=>l.dimensions,getData:()=>E,getPoints:()=>P,getSeriesList:()=>x,margin:l.dimensions.margin,markers:b,onClick:v.onClick,onHover:v.onHover,seriesGroup:_.series,svg:l.svg,tooltip:C})},e=>{x=e})}export{createAreaChart};
2
2
  //# sourceMappingURL=area-chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"area-chart.js","names":[],"sources":["../../../src/charts/area/area-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { seriesDomId } from '../../core/series-id';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction, ensureMarkerGroup } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { AreaChartConfig, AreaSeriesConfig, ChartHandle } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"mvBAcA,SAAgB,gBAA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OAAS,EAAW,QAChD,EAAO,OAAO,YAAY,EAAO,OAAO,SAAU,EAGpD,IAAM,EAAuB,CAAC,EAE9B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,OAAQ,IAAK,CAC1C,IAAM,EAAS,EAAW,GACtB,EAAQ,EAAO,OAAO,SAAS,GAE9B,IACH,EAAQ,EAAiB,IAAK,CAAE,MAAO,mBAAoB,CAAC,EAC5D,EAAO,OAAO,YAAY,CAAK,GAGjC,EAAM,aAAa,iBAAkB,EAAY,EAAQ,CAAC,CAAC,EAE3D,IAAM,EAAS,EAAkB,EAAQ,GAAI,EAAQ,CAAM,EAE3D,EAAU,KAAK,CAAM,EAErB,EAAW,EAAO,EAAQ,EAAW,CACnC,MAAO,EAAY,EAAG,EAAO,KAAK,EAClC,MAAO,EAAO,OAAS,SACvB,eAAgB,EAAI,eACpB,KAAM,EAAO,MAAQ,WACrB,YAAa,EAAO,YACpB,MAAO,EAAO,KACd,SAAU,EAAO,WAAa,GAC9B,WAAY,EAAO,UACrB,CAAC,CACH,CAMA,OAJA,GAAQ,OAAO,EAAW,KAAK,EAAG,KAAO,CAAE,MAAO,EAAY,EAAG,EAAE,KAAK,EAAG,KAAM,EAAE,IAAK,EAAE,CAAC,EAC3F,GAAS,KAAK,EACd,EAAU,EAAkB,EAAI,UAAW,CAAO,EAE3C,EAAwB,CAC7B,UAAW,EAAI,UACf,WAAc,EAAW,KAAK,EAAG,IAAM,EAAY,EAAG,EAAE,KAAK,CAAC,EAC9D,YACA,SAAY,EAAI,WAChB,YAAe,EACf,cAAiB,EACjB,kBAAqB,EACrB,OAAQ,EAAI,WAAW,OACvB,UACA,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,YAAa,EAAO,OACpB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
1
+ {"version":3,"file":"area-chart.js","names":[],"sources":["../../../src/charts/area/area-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { seriesDomId } from '../../core/series-id';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction, ensureMarkerGroup } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { AreaChartConfig, AreaSeriesConfig, ChartHandle, XAxisConfig, YAxisConfig } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n // Axes render by default (value axis with gridlines); `false` opts out.\n const xAxisConfig: XAxisConfig | false = config.xAxis === false ? false : (config.xAxis ?? {});\n const yAxisConfig: YAxisConfig | false = config.yAxis === false ? false : (config.yAxis ?? { grid: true });\n\n if (yAxisConfig && yAxisConfig.grid) {\n renderGrid(\n groups.grid,\n yScale,\n yAxisConfig.grid,\n area.width,\n 'horizontal',\n resolveTickCount(yAxisConfig, area.height, 'left'),\n );\n }\n\n if (xAxisConfig && xAxisConfig.grid) {\n renderGrid(\n groups.grid,\n xScale,\n xAxisConfig.grid,\n area.height,\n 'vertical',\n resolveTickCount(xAxisConfig, area.width, 'bottom'),\n );\n }\n\n if (xAxisConfig) {\n positionAxis(groups.xAxis, xAxisConfig.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, xAxisConfig, area.width, 'bottom');\n } else {\n groups.xAxis.replaceChildren();\n }\n\n if (yAxisConfig) {\n positionAxis(groups.yAxis, yAxisConfig.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, yAxisConfig, area.height, 'left');\n } else {\n groups.yAxis.replaceChildren();\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: 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A,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,YAAa,EAAO,OACpB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- require("../../_dev.cjs");const e=require("../../svg/element.cjs"),t=require("../../animation/easing.cjs"),n=require("../../animation/motion.cjs"),r=require("../../animation/tween.cjs"),i=require("../../animation/transition.cjs"),a=require("../../core/datum-style.cjs"),o=require("../../core/ids.cjs"),s=require("../../svg/path.cjs");var c=new WeakMap,l=new WeakMap;function buildLinePath(e,t){return t===`monotone`?s.monotonePath(e):t===`step`?s.stepPath(e):s.linePath(e)}function applyAreaFill(t,n,r){let i=t.querySelector(`linearGradient`);if(r.fill===`gradient`){if(!i){let n=e.createSvgElement(`defs`);i=e.createSvgElement(`linearGradient`,{id:o.uniqueId(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),i.append(e.createSvgElement(`stop`,{class:`prism-area-stop-top`,offset:0}),e.createSvgElement(`stop`,{class:`prism-area-stop-bottom`,offset:1})),n.appendChild(i),t.insertBefore(n,t.firstChild)}for(let e of i.querySelectorAll(`stop`))e.setAttribute(`stop-color`,r.color),e.style.stopColor=r.color;e.setAttributes(n,{fill:`url(#${i.id})`})}else i?.parentElement?.remove(),e.setAttributes(n,{fill:r.color});e.setAttributes(n,{class:`prism-area-fill prism-area-fill--${r.fill}`,stroke:`none`}),n.style.fillOpacity=r.fillOpacity===void 0?``:String(r.fillOpacity)}function renderArea(o,u,d,f){let p=n.resolveMotion(f.transition,0),m=p.duration,h=t.resolveEasing(p.easing),g=o.querySelector(`.prism-area-fill`);g||(g=e.createSvgElement(`path`,{class:`prism-area-fill`}),o.appendChild(g)),applyAreaFill(o,g,f);let _=null,v=[],y=[],b=a.hasStyledRuns(f.marks),x=f.marks??[];if(f.showLine){if(b){v=a.computeStyleRuns(x,u.length);let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(v.length))e.remove();y=v.map((n,r)=>{let i=t[r];if(i)return i;let a=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`});return o.appendChild(a),a});for(let[t,n]of v.entries())e.setAttributes(y[t],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});_=null}else{let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(1))e.remove();_=t[0]??null,_||(_=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`}),o.appendChild(_)),e.setAttributes(_,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of o.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=t=>{if(f.showLine){if(b)for(let[n,r]of v.entries())e.setAttributes(y[n],{d:buildLinePath(t.slice(r.start,r.end+1),f.curve)});else _&&e.setAttributes(_,{d:buildLinePath(t,f.curve)})}};if(m===0){let t=u.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(u,t,f.curve)}),drawLine(u);return}if(c.get(o)?.(),!g.hasAttribute(`d`)){let t=u.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(u,t,f.curve)}),drawLine(u),l.set(o,u);return}let S=l.get(o)??u,C=u.map((e,t)=>S[t]??S[S.length-1]??u[t]);l.set(o,C),c.set(o,i.startTween({count:1,duration:m,easing:h,onComplete:()=>{c.delete(o),l.set(o,u)},onFrame:t=>{let n=t(0),i=u.map((e,t)=>({x:r.tweenNumber(C[t].x,e.x,n),y:r.tweenNumber(C[t].y,e.y,n)})),a=i.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(i,a,f.curve)}),drawLine(i)},signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}exports.computeAreaPoints=computeAreaPoints,exports.renderArea=renderArea;
1
+ require("../../_dev.cjs");const e=require("../../svg/element.cjs"),t=require("../../animation/easing.cjs"),n=require("../../animation/motion.cjs"),r=require("../../animation/tween.cjs"),i=require("../../animation/transition.cjs"),a=require("../../core/datum-style.cjs"),o=require("../../core/ids.cjs"),s=require("../../svg/path.cjs");var c=new WeakMap,l=new WeakMap;function buildLinePath(e,t){return t===`monotone`?s.monotonePath(e):t===`step`?s.stepPath(e):s.linePath(e)}function applyAreaFill(t,n,r){let i=t.querySelector(`linearGradient`);if(r.fill===`gradient`){if(!i){let n=e.createSvgElement(`defs`);i=e.createSvgElement(`linearGradient`,{id:o.uniqueId(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),i.append(e.createSvgElement(`stop`,{class:`prism-area-stop-top`,offset:0}),e.createSvgElement(`stop`,{class:`prism-area-stop-bottom`,offset:1})),n.appendChild(i),t.insertBefore(n,t.firstChild)}for(let e of i.querySelectorAll(`stop`))e.setAttribute(`stop-color`,r.color),e.style.stopColor=r.color;e.setAttributes(n,{fill:`url(#${i.id})`})}else i?.parentElement?.remove(),e.setAttributes(n,{fill:r.color});e.setAttributes(n,{class:`prism-area-fill prism-area-fill--${r.fill}`,stroke:`none`}),n.style.fillOpacity=r.fillOpacity===void 0?``:String(r.fillOpacity)}function renderArea(o,u,d,f){let p=n.resolveMotion(f.transition),m=p.duration,h=t.resolveEasing(p.easing),g=o.querySelector(`.prism-area-fill`);g||(g=e.createSvgElement(`path`,{class:`prism-area-fill`}),o.appendChild(g)),applyAreaFill(o,g,f);let _=null,v=[],y=[],b=a.hasStyledRuns(f.marks),x=f.marks??[];if(f.showLine){if(b){v=a.computeStyleRuns(x,u.length);let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(v.length))e.remove();y=v.map((n,r)=>{let i=t[r];if(i)return i;let a=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`});return o.appendChild(a),a});for(let[t,n]of v.entries())e.setAttributes(y[t],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});_=null}else{let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(1))e.remove();_=t[0]??null,_||(_=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`}),o.appendChild(_)),e.setAttributes(_,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of o.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=t=>{if(f.showLine){if(b)for(let[n,r]of v.entries())e.setAttributes(y[n],{d:buildLinePath(t.slice(r.start,r.end+1),f.curve)});else _&&e.setAttributes(_,{d:buildLinePath(t,f.curve)})}};if(m===0){let t=u.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(u,t,f.curve)}),drawLine(u),l.set(o,u);return}c.get(o)?.();let S=l.has(o)?l.get(o)??u:u.map(e=>({x:e.x,y:d})),C=u.map((e,t)=>S[t]??S[S.length-1]??u[t]),paintFrame=t=>{let n=u.map((e,n)=>({x:r.tweenNumber(C[n].x,e.x,t),y:r.tweenNumber(C[n].y,e.y,t)})),i=n.map(e=>({x:e.x,y:d}));l.set(o,n),e.setAttributes(g,{d:s.areaPath(n,i,f.curve)}),drawLine(n)};paintFrame(0),c.set(o,i.startTween({count:1,duration:m,easing:h,onComplete:()=>{c.delete(o),l.set(o,u)},onFrame:e=>paintFrame(e(0)),signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}exports.computeAreaPoints=computeAreaPoints,exports.renderArea=renderArea;
2
2
  //# sourceMappingURL=area-renderer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"area-renderer.cjs","names":[],"sources":["../../../src/charts/area/area-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { startTween } from '../../animation/transition';\nimport { tweenNumber } from '../../animation/tween';\nimport { computeStyleRuns, type DatumMark, hasStyledRuns, type StyleRun } from '../../core/datum-style';\nimport { uniqueId } from '../../core/ids';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { areaPath, linePath, monotonePath, stepPath } from '../../svg/path';\nimport type { ContinuousDatum, Scale, TransitionConfig } from '../../types';\n\nexport interface AreaRenderOptions {\n color: string;\n curve: 'linear' | 'monotone' | 'step';\n /** Aborted when the owning chart is disposed: stops the transition's `requestAnimationFrame` loop from rescheduling. */\n disposalSignal?: AbortSignal;\n fill: 'gradient' | 'solid';\n /** Explicit opacity beats the `--prism-area-opacity` theme token. */\n fillOpacity?: number;\n /** Per-datum presentation parallel to `points`; styled runs split the top line into subpaths. */\n marks?: readonly DatumMark[];\n showLine: boolean;\n transition?: TransitionConfig;\n}\n\nconst activeAreaAnimations = new WeakMap<SVGGElement, () => void>();\nconst previousPoints = new WeakMap<SVGGElement, Point[]>();\n\nfunction buildLinePath(pts: Point[], curve: AreaRenderOptions['curve']): string {\n return curve === 'monotone' ? monotonePath(pts) : curve === 'step' ? stepPath(pts) : linePath(pts);\n}\n\n/** A vertical gradient fading to transparent at the baseline, or a flat fill. */\nfunction applyAreaFill(parent: SVGGElement, fill: SVGPathElement, options: AreaRenderOptions): void {\n let gradient = parent.querySelector<SVGLinearGradientElement>('linearGradient');\n\n if (options.fill === 'gradient') {\n if (!gradient) {\n const defs = createSvgElement('defs');\n\n gradient = createSvgElement('linearGradient', { id: uniqueId('prism-area-fill'), x1: 0, x2: 0, y1: 0, y2: 1 });\n gradient.append(\n createSvgElement('stop', { class: 'prism-area-stop-top', offset: 0 }),\n createSvgElement('stop', { class: 'prism-area-stop-bottom', offset: 1 }),\n );\n defs.appendChild(gradient);\n parent.insertBefore(defs, parent.firstChild);\n }\n\n for (const stop of gradient.querySelectorAll('stop')) {\n stop.setAttribute('stop-color', options.color);\n stop.style.stopColor = options.color;\n }\n\n setAttributes(fill, { fill: `url(#${gradient.id})` });\n } else {\n gradient?.parentElement?.remove();\n setAttributes(fill, { fill: options.color });\n }\n\n setAttributes(fill, { class: `prism-area-fill prism-area-fill--${options.fill}`, stroke: 'none' });\n fill.style.fillOpacity = options.fillOpacity === undefined ? '' : String(options.fillOpacity);\n}\n\nexport function renderArea(parent: SVGGElement, points: Point[], baselineY: number, options: AreaRenderOptions): void {\n const motion = resolveMotion(options.transition, 0);\n const dur = motion.duration;\n const easing = resolveEasing(motion.easing);\n\n let fill = parent.querySelector<SVGPathElement>('.prism-area-fill');\n\n if (!fill) {\n fill = createSvgElement('path', { class: 'prism-area-fill' });\n parent.appendChild(fill);\n }\n\n applyAreaFill(parent, fill, options);\n\n let line: SVGPathElement | null = null;\n let runs: readonly StyleRun[] = [];\n let lines: SVGPathElement[] = [];\n const styled = hasStyledRuns(options.marks);\n const marks = options.marks ?? [];\n\n if (options.showLine) {\n if (styled) {\n runs = computeStyleRuns(marks, points.length);\n\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const extra of existing.slice(runs.length)) extra.remove();\n\n lines = runs.map((_, r) => {\n const reuse = existing[r];\n\n if (reuse) return reuse;\n\n const created = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n\n parent.appendChild(created);\n\n return created;\n });\n\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], {\n opacity: run.opacity,\n stroke: options.color,\n 'stroke-dasharray': run.dash,\n 'stroke-width': 2,\n });\n }\n\n line = null;\n } else {\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const stale of existing.slice(1)) stale.remove();\n\n line = existing[0] ?? null;\n\n if (!line) {\n line = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n parent.appendChild(line);\n }\n\n setAttributes(line, {\n opacity: undefined,\n stroke: options.color,\n 'stroke-dasharray': undefined,\n 'stroke-width': 2,\n });\n }\n } else {\n for (const stale of parent.querySelectorAll('.prism-area-line')) stale.remove();\n }\n\n const drawLine = (pts: Point[]): void => {\n if (!options.showLine) return;\n\n if (styled) {\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], { d: buildLinePath(pts.slice(run.start, run.end + 1), options.curve) });\n }\n } else if (line) {\n setAttributes(line, { d: buildLinePath(pts, options.curve) });\n }\n };\n\n if (dur === 0) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n return;\n }\n\n activeAreaAnimations.get(parent)?.();\n\n const hasExisting = fill.hasAttribute('d');\n\n if (!hasExisting) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n previousPoints.set(parent, points);\n\n return;\n }\n\n const rawFrom = previousPoints.get(parent) ?? points;\n const fromPoints: Point[] = points.map((_, i) => rawFrom[i] ?? rawFrom[rawFrom.length - 1] ?? points[i]);\n\n previousPoints.set(parent, fromPoints);\n\n activeAreaAnimations.set(\n parent,\n startTween({\n count: 1,\n duration: dur,\n easing,\n onComplete: () => {\n activeAreaAnimations.delete(parent);\n previousPoints.set(parent, points);\n },\n onFrame: (progress) => {\n const e = progress(0);\n const interpolated: Point[] = points.map((to, i) => ({\n x: tweenNumber(fromPoints[i].x, to.x, e),\n y: tweenNumber(fromPoints[i].y, to.y, e),\n }));\n const interpolatedBottom = interpolated.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill!, { d: areaPath(interpolated, interpolatedBottom, options.curve) });\n drawLine(interpolated);\n },\n signal: options.disposalSignal,\n }),\n );\n}\n\nexport function computeAreaPoints(\n data: ContinuousDatum[],\n xScale: Scale<Date | number>,\n yScale: Scale<number>,\n): Point[] {\n if (data.some((d) => d.key == null)) {\n warn(\n 'computeAreaPoints: datum.key is null or undefined: data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n } else if (data.some((d) => typeof d.key === 'string')) {\n warn('computeAreaPoints: string keys are not supported for line/area charts: use numeric or Date keys.');\n }\n\n return data.map((d) => ({\n x: xScale.map(d.key as Date | number),\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EACA,EAAA,WAAW,CACT,MAAO,EACP,SAAU,EACV,SACA,eAAkB,CAChB,EAAqB,OAAO,CAAM,EAClC,EAAe,IAAI,EAAQ,CAAM,CACnC,EACA,QAAU,GAAa,CACrB,IAAM,EAAI,EAAS,CAAC,EACd,EAAwB,EAAO,KAAK,EAAI,KAAO,CACnD,EAAG,EAAA,YAAY,EAAW,EAAE,CAAC,EAAG,EAAG,EAAG,CAAC,EACvC,EAAG,EAAA,YAAY,EAAW,EAAE,CAAC,EAAG,EAAG,EAAG,CAAC,CACzC,EAAE,EACI,EAAqB,EAAa,IAAK,IAAO,CAAE,EAAG,EAAE,EAAG,EAAG,CAAU,EAAE,EAE7E,EAAA,cAAc,EAAO,CAAE,EAAG,EAAA,SAAS,EAAc,EAAoB,EAAQ,KAAK,CAAE,CAAC,EACrF,SAAS,CAAY,CACvB,EACA,OAAQ,EAAQ,cAClB,CAAC,CACH,CACF,CAEA,SAAgB,kBACd,EACA,EACA,EACS,CAST,OARI,EAAK,KAAM,GAAM,EAAE,KAAO,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
1
+ {"version":3,"file":"area-renderer.cjs","names":[],"sources":["../../../src/charts/area/area-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { startTween } from '../../animation/transition';\nimport { tweenNumber } from '../../animation/tween';\nimport { computeStyleRuns, type DatumMark, hasStyledRuns, type StyleRun } from '../../core/datum-style';\nimport { uniqueId } from '../../core/ids';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { areaPath, linePath, monotonePath, stepPath } from '../../svg/path';\nimport type { ContinuousDatum, Scale, TransitionOption } from '../../types';\n\nexport interface AreaRenderOptions {\n color: string;\n curve: 'linear' | 'monotone' | 'step';\n /** Aborted when the owning chart is disposed: stops the transition's `requestAnimationFrame` loop from rescheduling. */\n disposalSignal?: AbortSignal;\n fill: 'gradient' | 'solid';\n /** Explicit opacity beats the `--prism-area-opacity` theme token. */\n fillOpacity?: number;\n /** Per-datum presentation parallel to `points`; styled runs split the top line into subpaths. */\n marks?: readonly DatumMark[];\n showLine: boolean;\n transition?: TransitionOption;\n}\n\nconst activeAreaAnimations = new WeakMap<SVGGElement, () => void>();\nconst drawnPoints = new WeakMap<SVGGElement, Point[]>();\n\nfunction buildLinePath(pts: Point[], curve: AreaRenderOptions['curve']): string {\n return curve === 'monotone' ? monotonePath(pts) : curve === 'step' ? stepPath(pts) : linePath(pts);\n}\n\n/** A vertical gradient fading to transparent at the baseline, or a flat fill. */\nfunction applyAreaFill(parent: SVGGElement, fill: SVGPathElement, options: AreaRenderOptions): void {\n let gradient = parent.querySelector<SVGLinearGradientElement>('linearGradient');\n\n if (options.fill === 'gradient') {\n if (!gradient) {\n const defs = createSvgElement('defs');\n\n gradient = createSvgElement('linearGradient', { id: uniqueId('prism-area-fill'), x1: 0, x2: 0, y1: 0, y2: 1 });\n gradient.append(\n createSvgElement('stop', { class: 'prism-area-stop-top', offset: 0 }),\n createSvgElement('stop', { class: 'prism-area-stop-bottom', offset: 1 }),\n );\n defs.appendChild(gradient);\n parent.insertBefore(defs, parent.firstChild);\n }\n\n for (const stop of gradient.querySelectorAll('stop')) {\n stop.setAttribute('stop-color', options.color);\n stop.style.stopColor = options.color;\n }\n\n setAttributes(fill, { fill: `url(#${gradient.id})` });\n } else {\n gradient?.parentElement?.remove();\n setAttributes(fill, { fill: options.color });\n }\n\n setAttributes(fill, { class: `prism-area-fill prism-area-fill--${options.fill}`, stroke: 'none' });\n fill.style.fillOpacity = options.fillOpacity === undefined ? '' : String(options.fillOpacity);\n}\n\nexport function renderArea(parent: SVGGElement, points: Point[], baselineY: number, options: AreaRenderOptions): void {\n const motion = resolveMotion(options.transition);\n const dur = motion.duration;\n const easing = resolveEasing(motion.easing);\n\n let fill = parent.querySelector<SVGPathElement>('.prism-area-fill');\n\n if (!fill) {\n fill = createSvgElement('path', { class: 'prism-area-fill' });\n parent.appendChild(fill);\n }\n\n applyAreaFill(parent, fill, options);\n\n let line: SVGPathElement | null = null;\n let runs: readonly StyleRun[] = [];\n let lines: SVGPathElement[] = [];\n const styled = hasStyledRuns(options.marks);\n const marks = options.marks ?? [];\n\n if (options.showLine) {\n if (styled) {\n runs = computeStyleRuns(marks, points.length);\n\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const extra of existing.slice(runs.length)) extra.remove();\n\n lines = runs.map((_, r) => {\n const reuse = existing[r];\n\n if (reuse) return reuse;\n\n const created = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n\n parent.appendChild(created);\n\n return created;\n });\n\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], {\n opacity: run.opacity,\n stroke: options.color,\n 'stroke-dasharray': run.dash,\n 'stroke-width': 2,\n });\n }\n\n line = null;\n } else {\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const stale of existing.slice(1)) stale.remove();\n\n line = existing[0] ?? null;\n\n if (!line) {\n line = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n parent.appendChild(line);\n }\n\n setAttributes(line, {\n opacity: undefined,\n stroke: options.color,\n 'stroke-dasharray': undefined,\n 'stroke-width': 2,\n });\n }\n } else {\n for (const stale of parent.querySelectorAll('.prism-area-line')) stale.remove();\n }\n\n const drawLine = (pts: Point[]): void => {\n if (!options.showLine) return;\n\n if (styled) {\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], { d: buildLinePath(pts.slice(run.start, run.end + 1), options.curve) });\n }\n } else if (line) {\n setAttributes(line, { d: buildLinePath(pts, options.curve) });\n }\n };\n\n if (dur === 0) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n drawnPoints.set(parent, points);\n\n return;\n }\n\n activeAreaAnimations.get(parent)?.();\n\n const hasExisting = drawnPoints.has(parent);\n // A first render has no drawn shape to interpolate from: the mount animation\n // grows the area out of its baseline instead.\n const rawFrom: Point[] = hasExisting\n ? (drawnPoints.get(parent) ?? points)\n : points.map((p) => ({ x: p.x, y: baselineY }));\n const fromPoints: Point[] = points.map((_, i) => rawFrom[i] ?? rawFrom[rawFrom.length - 1] ?? points[i]);\n\n const paintFrame = (e: number): void => {\n const interpolated: Point[] = points.map((to, i) => ({\n x: tweenNumber(fromPoints[i].x, to.x, e),\n y: tweenNumber(fromPoints[i].y, to.y, e),\n }));\n const interpolatedBottom = interpolated.map((p) => ({ x: p.x, y: baselineY }));\n\n drawnPoints.set(parent, interpolated);\n setAttributes(fill!, { d: areaPath(interpolated, interpolatedBottom, options.curve) });\n drawLine(interpolated);\n };\n\n // The starting geometry goes on screen immediately: `startTween` only paints on\n // the first frame callback, which would otherwise leave one blank frame.\n paintFrame(0);\n\n activeAreaAnimations.set(\n parent,\n startTween({\n count: 1,\n duration: dur,\n easing,\n onComplete: () => {\n activeAreaAnimations.delete(parent);\n drawnPoints.set(parent, points);\n },\n onFrame: (progress) => paintFrame(progress(0)),\n signal: options.disposalSignal,\n }),\n );\n}\n\nexport function computeAreaPoints(\n data: ContinuousDatum[],\n xScale: Scale<Date | number>,\n yScale: Scale<number>,\n): Point[] {\n if (data.some((d) => d.key == null)) {\n warn(\n 'computeAreaPoints: datum.key is null or undefined: data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n } else if (data.some((d) => typeof d.key === 'string')) {\n warn('computeAreaPoints: string keys are not supported for line/area charts: use numeric or Date keys.');\n }\n\n return data.map((d) => ({\n x: xScale.map(d.key as Date | number),\n y: yScale.map(d.value),\n }));\n}\n"],"mappings":"8UA0BA,IAAM,EAAuB,IAAI,QAC3B,EAAc,IAAI,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,IAAI,EAAQ,CAAY,EACpC,EAAA,cAAc,EAAO,CAAE,EAAG,EAAA,SAAS,EAAc,EAAoB,EAAQ,KAAK,CAAE,CAAC,EACrF,SAAS,CAAY,CACvB,EAIA,WAAW,CAAC,EAEZ,EAAqB,IACnB,EACA,EAAA,WAAW,CACT,MAAO,EACP,SAAU,EACV,SACA,eAAkB,CAChB,EAAqB,OAAO,CAAM,EAClC,EAAY,IAAI,EAAQ,CAAM,CAChC,EACA,QAAU,GAAa,WAAW,EAAS,CAAC,CAAC,EAC7C,OAAQ,EAAQ,cAClB,CAAC,CACH,CACF,CAEA,SAAgB,kBACd,EACA,EACA,EACS,CAST,OARI,EAAK,KAAM,GAAM,EAAE,KAAO,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
@@ -1,6 +1,6 @@
1
1
  import { type DatumMark } from '../../core/datum-style';
2
2
  import type { Point } from '../../svg/path';
3
- import type { ContinuousDatum, Scale, TransitionConfig } from '../../types';
3
+ import type { ContinuousDatum, Scale, TransitionOption } from '../../types';
4
4
  export interface AreaRenderOptions {
5
5
  color: string;
6
6
  curve: 'linear' | 'monotone' | 'step';
@@ -12,7 +12,7 @@ export interface AreaRenderOptions {
12
12
  /** Per-datum presentation parallel to `points`; styled runs split the top line into subpaths. */
13
13
  marks?: readonly DatumMark[];
14
14
  showLine: boolean;
15
- transition?: TransitionConfig;
15
+ transition?: TransitionOption;
16
16
  }
17
17
  export declare function renderArea(parent: SVGGElement, points: Point[], baselineY: number, options: AreaRenderOptions): void;
18
18
  export declare function computeAreaPoints(data: ContinuousDatum[], xScale: Scale<Date | number>, yScale: Scale<number>): Point[];
@@ -1 +1 @@
1
- {"version":3,"file":"area-renderer.d.ts","sourceRoot":"","sources":["../../../src/charts/area/area-renderer.ts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AAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACtC,wHAAwH;IACxH,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAyCD,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAwIpH;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EAAE,EACvB,MAAM,EAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,EAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GACpB,KAAK,EAAE,CAaT"}
@@ -1,2 +1,2 @@
1
- import"../../_dev.js";import{createSvgElement as e,setAttributes as t}from"../../svg/element.js";import{resolveEasing as n}from"../../animation/easing.js";import{resolveMotion as r}from"../../animation/motion.js";import{tweenNumber as i}from"../../animation/tween.js";import{startTween as a}from"../../animation/transition.js";import{computeStyleRuns as o,hasStyledRuns as s}from"../../core/datum-style.js";import{uniqueId as c}from"../../core/ids.js";import{areaPath as l,linePath as u,monotonePath as d,stepPath as f}from"../../svg/path.js";var p=new WeakMap,m=new WeakMap;function buildLinePath(e,t){return t===`monotone`?d(e):t===`step`?f(e):u(e)}function applyAreaFill(n,r,i){let a=n.querySelector(`linearGradient`);if(i.fill===`gradient`){if(!a){let t=e(`defs`);a=e(`linearGradient`,{id:c(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),a.append(e(`stop`,{class:`prism-area-stop-top`,offset:0}),e(`stop`,{class:`prism-area-stop-bottom`,offset:1})),t.appendChild(a),n.insertBefore(t,n.firstChild)}for(let e of a.querySelectorAll(`stop`))e.setAttribute(`stop-color`,i.color),e.style.stopColor=i.color;t(r,{fill:`url(#${a.id})`})}else a?.parentElement?.remove(),t(r,{fill:i.color});t(r,{class:`prism-area-fill prism-area-fill--${i.fill}`,stroke:`none`}),r.style.fillOpacity=i.fillOpacity===void 0?``:String(i.fillOpacity)}function renderArea(c,u,d,f){let h=r(f.transition,0),g=h.duration,_=n(h.easing),v=c.querySelector(`.prism-area-fill`);v||(v=e(`path`,{class:`prism-area-fill`}),c.appendChild(v)),applyAreaFill(c,v,f);let y=null,b=[],x=[],S=s(f.marks),C=f.marks??[];if(f.showLine){if(S){b=o(C,u.length);let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(b.length))e.remove();x=b.map((t,r)=>{let i=n[r];if(i)return i;let a=e(`path`,{class:`prism-area-line`,fill:`none`});return c.appendChild(a),a});for(let[e,n]of b.entries())t(x[e],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});y=null}else{let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(1))e.remove();y=n[0]??null,y||(y=e(`path`,{class:`prism-area-line`,fill:`none`}),c.appendChild(y)),t(y,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of c.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=e=>{if(f.showLine){if(S)for(let[n,r]of b.entries())t(x[n],{d:buildLinePath(e.slice(r.start,r.end+1),f.curve)});else y&&t(y,{d:buildLinePath(e,f.curve)})}};if(g===0){let e=u.map(e=>({x:e.x,y:d}));t(v,{d:l(u,e,f.curve)}),drawLine(u);return}if(p.get(c)?.(),!v.hasAttribute(`d`)){let e=u.map(e=>({x:e.x,y:d}));t(v,{d:l(u,e,f.curve)}),drawLine(u),m.set(c,u);return}let w=m.get(c)??u,T=u.map((e,t)=>w[t]??w[w.length-1]??u[t]);m.set(c,T),p.set(c,a({count:1,duration:g,easing:_,onComplete:()=>{p.delete(c),m.set(c,u)},onFrame:e=>{let n=e(0),r=u.map((e,t)=>({x:i(T[t].x,e.x,n),y:i(T[t].y,e.y,n)})),a=r.map(e=>({x:e.x,y:d}));t(v,{d:l(r,a,f.curve)}),drawLine(r)},signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}export{computeAreaPoints,renderArea};
1
+ import"../../_dev.js";import{createSvgElement as e,setAttributes as t}from"../../svg/element.js";import{resolveEasing as n}from"../../animation/easing.js";import{resolveMotion as r}from"../../animation/motion.js";import{tweenNumber as i}from"../../animation/tween.js";import{startTween as a}from"../../animation/transition.js";import{computeStyleRuns as o,hasStyledRuns as s}from"../../core/datum-style.js";import{uniqueId as c}from"../../core/ids.js";import{areaPath as l,linePath as u,monotonePath as d,stepPath as f}from"../../svg/path.js";var p=new WeakMap,m=new WeakMap;function buildLinePath(e,t){return t===`monotone`?d(e):t===`step`?f(e):u(e)}function applyAreaFill(n,r,i){let a=n.querySelector(`linearGradient`);if(i.fill===`gradient`){if(!a){let t=e(`defs`);a=e(`linearGradient`,{id:c(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),a.append(e(`stop`,{class:`prism-area-stop-top`,offset:0}),e(`stop`,{class:`prism-area-stop-bottom`,offset:1})),t.appendChild(a),n.insertBefore(t,n.firstChild)}for(let e of a.querySelectorAll(`stop`))e.setAttribute(`stop-color`,i.color),e.style.stopColor=i.color;t(r,{fill:`url(#${a.id})`})}else a?.parentElement?.remove(),t(r,{fill:i.color});t(r,{class:`prism-area-fill prism-area-fill--${i.fill}`,stroke:`none`}),r.style.fillOpacity=i.fillOpacity===void 0?``:String(i.fillOpacity)}function renderArea(c,u,d,f){let h=r(f.transition),g=h.duration,_=n(h.easing),v=c.querySelector(`.prism-area-fill`);v||(v=e(`path`,{class:`prism-area-fill`}),c.appendChild(v)),applyAreaFill(c,v,f);let y=null,b=[],x=[],S=s(f.marks),C=f.marks??[];if(f.showLine){if(S){b=o(C,u.length);let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(b.length))e.remove();x=b.map((t,r)=>{let i=n[r];if(i)return i;let a=e(`path`,{class:`prism-area-line`,fill:`none`});return c.appendChild(a),a});for(let[e,n]of b.entries())t(x[e],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});y=null}else{let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(1))e.remove();y=n[0]??null,y||(y=e(`path`,{class:`prism-area-line`,fill:`none`}),c.appendChild(y)),t(y,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of c.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=e=>{if(f.showLine){if(S)for(let[n,r]of b.entries())t(x[n],{d:buildLinePath(e.slice(r.start,r.end+1),f.curve)});else y&&t(y,{d:buildLinePath(e,f.curve)})}};if(g===0){let e=u.map(e=>({x:e.x,y:d}));t(v,{d:l(u,e,f.curve)}),drawLine(u),m.set(c,u);return}p.get(c)?.();let w=m.has(c)?m.get(c)??u:u.map(e=>({x:e.x,y:d})),T=u.map((e,t)=>w[t]??w[w.length-1]??u[t]),paintFrame=e=>{let n=u.map((t,n)=>({x:i(T[n].x,t.x,e),y:i(T[n].y,t.y,e)})),r=n.map(e=>({x:e.x,y:d}));m.set(c,n),t(v,{d:l(n,r,f.curve)}),drawLine(n)};paintFrame(0),p.set(c,a({count:1,duration:g,easing:_,onComplete:()=>{p.delete(c),m.set(c,u)},onFrame:e=>paintFrame(e(0)),signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}export{computeAreaPoints,renderArea};
2
2
  //# sourceMappingURL=area-renderer.js.map