@vielzeug/prism 26.10.2 → 26.10.4

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 (138) hide show
  1. package/README.md +1 -1
  2. package/dist/_dev.cjs.map +1 -1
  3. package/dist/_dev.js.map +1 -1
  4. package/dist/_tappers.cjs +2 -0
  5. package/dist/_tappers.cjs.map +1 -0
  6. package/dist/_tappers.d.ts +10 -0
  7. package/dist/_tappers.d.ts.map +1 -0
  8. package/dist/_tappers.js +2 -0
  9. package/dist/_tappers.js.map +1 -0
  10. package/dist/animation/easing.cjs +1 -1
  11. package/dist/animation/easing.cjs.map +1 -1
  12. package/dist/animation/easing.d.ts +15 -1
  13. package/dist/animation/easing.d.ts.map +1 -1
  14. package/dist/animation/easing.js +1 -1
  15. package/dist/animation/easing.js.map +1 -1
  16. package/dist/animation/motion.cjs +1 -1
  17. package/dist/animation/motion.cjs.map +1 -1
  18. package/dist/animation/motion.d.ts +17 -2
  19. package/dist/animation/motion.d.ts.map +1 -1
  20. package/dist/animation/motion.js +1 -1
  21. package/dist/animation/motion.js.map +1 -1
  22. package/dist/animation/transition.cjs +1 -1
  23. package/dist/animation/transition.cjs.map +1 -1
  24. package/dist/animation/transition.d.ts +32 -3
  25. package/dist/animation/transition.d.ts.map +1 -1
  26. package/dist/animation/transition.js +1 -1
  27. package/dist/animation/transition.js.map +1 -1
  28. package/dist/charts/area/area-chart.cjs +1 -1
  29. package/dist/charts/area/area-chart.cjs.map +1 -1
  30. package/dist/charts/area/area-chart.d.ts.map +1 -1
  31. package/dist/charts/area/area-chart.js +1 -1
  32. package/dist/charts/area/area-chart.js.map +1 -1
  33. package/dist/charts/area/area-renderer.cjs +1 -1
  34. package/dist/charts/area/area-renderer.cjs.map +1 -1
  35. package/dist/charts/area/area-renderer.d.ts +2 -2
  36. package/dist/charts/area/area-renderer.d.ts.map +1 -1
  37. package/dist/charts/area/area-renderer.js +1 -1
  38. package/dist/charts/area/area-renderer.js.map +1 -1
  39. package/dist/charts/bar/bar-chart.cjs +1 -1
  40. package/dist/charts/bar/bar-chart.cjs.map +1 -1
  41. package/dist/charts/bar/bar-chart.d.ts.map +1 -1
  42. package/dist/charts/bar/bar-chart.js +1 -1
  43. package/dist/charts/bar/bar-chart.js.map +1 -1
  44. package/dist/charts/bar/bar-renderer.cjs +1 -1
  45. package/dist/charts/bar/bar-renderer.cjs.map +1 -1
  46. package/dist/charts/bar/bar-renderer.d.ts +2 -2
  47. package/dist/charts/bar/bar-renderer.d.ts.map +1 -1
  48. package/dist/charts/bar/bar-renderer.js +1 -1
  49. package/dist/charts/bar/bar-renderer.js.map +1 -1
  50. package/dist/charts/line/line-chart.cjs +1 -1
  51. package/dist/charts/line/line-chart.cjs.map +1 -1
  52. package/dist/charts/line/line-chart.d.ts.map +1 -1
  53. package/dist/charts/line/line-chart.js +1 -1
  54. package/dist/charts/line/line-chart.js.map +1 -1
  55. package/dist/charts/line/line-renderer.cjs +1 -1
  56. package/dist/charts/line/line-renderer.cjs.map +1 -1
  57. package/dist/charts/line/line-renderer.d.ts +4 -2
  58. package/dist/charts/line/line-renderer.d.ts.map +1 -1
  59. package/dist/charts/line/line-renderer.js +1 -1
  60. package/dist/charts/line/line-renderer.js.map +1 -1
  61. package/dist/charts/pie/pie-chart.cjs +1 -1
  62. package/dist/charts/pie/pie-chart.cjs.map +1 -1
  63. package/dist/charts/pie/pie-chart.d.ts.map +1 -1
  64. package/dist/charts/pie/pie-chart.js +1 -1
  65. package/dist/charts/pie/pie-chart.js.map +1 -1
  66. package/dist/charts/radar/radar-chart.cjs +1 -1
  67. package/dist/charts/radar/radar-chart.cjs.map +1 -1
  68. package/dist/charts/radar/radar-chart.d.ts.map +1 -1
  69. package/dist/charts/radar/radar-chart.js +1 -1
  70. package/dist/charts/radar/radar-chart.js.map +1 -1
  71. package/dist/charts/sparkline/sparkline.cjs +1 -1
  72. package/dist/charts/sparkline/sparkline.cjs.map +1 -1
  73. package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
  74. package/dist/charts/sparkline/sparkline.js +1 -1
  75. package/dist/charts/sparkline/sparkline.js.map +1 -1
  76. package/dist/core/chart-scaffold.cjs +1 -1
  77. package/dist/core/chart-scaffold.cjs.map +1 -1
  78. package/dist/core/chart-scaffold.d.ts.map +1 -1
  79. package/dist/core/chart-scaffold.js +1 -1
  80. package/dist/core/chart-scaffold.js.map +1 -1
  81. package/dist/core/responsive.cjs +1 -1
  82. package/dist/core/responsive.cjs.map +1 -1
  83. package/dist/core/responsive.d.ts.map +1 -1
  84. package/dist/core/responsive.js +1 -1
  85. package/dist/core/responsive.js.map +1 -1
  86. package/dist/index.d.ts +2 -2
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/interaction/crosshair.cjs +1 -1
  89. package/dist/interaction/crosshair.cjs.map +1 -1
  90. package/dist/interaction/crosshair.d.ts +7 -0
  91. package/dist/interaction/crosshair.d.ts.map +1 -1
  92. package/dist/interaction/crosshair.js +1 -1
  93. package/dist/interaction/crosshair.js.map +1 -1
  94. package/dist/interaction/series-interaction.cjs +1 -1
  95. package/dist/interaction/series-interaction.cjs.map +1 -1
  96. package/dist/interaction/series-interaction.d.ts +3 -1
  97. package/dist/interaction/series-interaction.d.ts.map +1 -1
  98. package/dist/interaction/series-interaction.js +1 -1
  99. package/dist/interaction/series-interaction.js.map +1 -1
  100. package/dist/interaction/tooltip.cjs +1 -1
  101. package/dist/interaction/tooltip.cjs.map +1 -1
  102. package/dist/interaction/tooltip.d.ts.map +1 -1
  103. package/dist/interaction/tooltip.js +1 -1
  104. package/dist/interaction/tooltip.js.map +1 -1
  105. package/dist/prism.cjs +1 -1
  106. package/dist/prism.cjs.map +1 -1
  107. package/dist/prism.iife.js +1 -1
  108. package/dist/prism.iife.js.map +1 -1
  109. package/dist/prism.js +1 -1
  110. package/dist/prism.js.map +1 -1
  111. package/dist/theme/index.cjs +1 -1
  112. package/dist/theme/index.cjs.map +1 -1
  113. package/dist/theme/index.d.ts +9 -4
  114. package/dist/theme/index.d.ts.map +1 -1
  115. package/dist/theme/index.js +1 -1
  116. package/dist/theme/index.js.map +1 -1
  117. package/dist/theme/prism.css +18 -4
  118. package/dist/types.d.ts +76 -9
  119. package/dist/types.d.ts.map +1 -1
  120. package/package.json +3 -18
  121. package/dist/animation/index.d.ts +0 -6
  122. package/dist/animation/index.d.ts.map +0 -1
  123. package/dist/axes/index.d.ts +0 -3
  124. package/dist/axes/index.d.ts.map +0 -1
  125. package/dist/core/index.d.ts +0 -7
  126. package/dist/core/index.d.ts.map +0 -1
  127. package/dist/devtools/index.d.ts +0 -52
  128. package/dist/devtools/index.d.ts.map +0 -1
  129. package/dist/devtools.cjs +0 -2
  130. package/dist/devtools.cjs.map +0 -1
  131. package/dist/devtools.js +0 -2
  132. package/dist/devtools.js.map +0 -1
  133. package/dist/interaction/index.d.ts +0 -8
  134. package/dist/interaction/index.d.ts.map +0 -1
  135. package/dist/scales/index.d.ts +0 -4
  136. package/dist/scales/index.d.ts.map +0 -1
  137. package/dist/svg/index.d.ts +0 -5
  138. package/dist/svg/index.d.ts.map +0 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ yarn add @vielzeug/prism
14
14
 
15
15
  ```ts
16
16
  import { createLineChart, setTheme } from '@vielzeug/prism';
17
- import '@vielzeug/prism/theme';
17
+ import '@vielzeug/prism/theme.css';
18
18
 
19
19
  // Optional: apply a custom color palette at startup
20
20
  setTheme({ colors: ['#6366f1', '#22d3ee', '#f59e0b', '#10b981'] });
package/dist/_dev.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal: Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC,CAWA,SAAgB,QAAQ,EAAsB,CAE9C"}
1
+ {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/** @internal: Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC,CAGA,SAAgB,QAAQ,EAAsB,CAE9C"}
package/dist/_dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/**\n * Emits a `console.error` in development builds only.\n * @internal\n */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/prism] ${msg}`, ...args);\n}\n\n/** @internal: Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC,CAWA,SAAgB,QAAQ,EAAsB,CAE9C"}
1
+ {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["/** @internal */\nconst isDev = !(globalThis as { __PRISM_PROD__?: boolean }).__PRISM_PROD__;\n\n/**\n * Emits a `console.warn` in development builds only.\n * @internal\n * @security Messages may include user-supplied data (e.g. category names, x-values).\n * Never pass PII, tokens, or secrets as chart data labels.\n */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/prism] ${msg}`);\n}\n\n/** @internal: Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AASA,SAAgB,KAAK,EAAmB,CAExC,CAGA,SAAgB,QAAQ,EAAsB,CAE9C"}
@@ -0,0 +1,2 @@
1
+ function createTappers(){let e=new Set,t=!1;return{emit(t){if(e.size!==0)for(let n of e)try{n(t)}catch{}},stop(){t=!0,e.clear()},tap(n,r){if(t||r?.signal?.aborted)return()=>{};e.add(n);let detach=()=>{e.delete(n)};return r?.signal?.addEventListener(`abort`,detach,{once:!0}),detach}}}exports.createTappers=createTappers;
2
+ //# sourceMappingURL=_tappers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_tappers.cjs","names":[],"sources":["../src/_tappers.ts"],"sourcesContent":["/**\n * Shared `tap()` machinery for chart handles.\n *\n * @internal Private to the package: consumers observe charts through\n * `ChartHandle.tap()`, never through this module.\n */\n\nexport interface Tappers<E extends { readonly type: string }> {\n /** Delivers `event` to every registered handler, swallowing handler errors. */\n emit(event: E): void;\n /** Clears every handler; later `tap()` calls return a no-op unsubscribe. */\n stop(): void;\n tap(handler: (event: E) => void, options?: { readonly signal?: AbortSignal }): () => void;\n}\n\nexport function createTappers<E extends { readonly type: string }>(): Tappers<E> {\n const tappers = new Set<(event: E) => void>();\n let stopped = false;\n\n return {\n emit(event) {\n // Zero-overhead guard: observation costs nothing while nobody is watching.\n if (tappers.size === 0) return;\n\n for (const handler of tappers) {\n try {\n handler(event);\n } catch {\n // Observability must never affect chart behavior.\n }\n }\n },\n stop() {\n stopped = true;\n tappers.clear();\n },\n tap(handler, options) {\n if (stopped || options?.signal?.aborted) return () => {};\n\n tappers.add(handler);\n\n const detach = (): void => {\n tappers.delete(handler);\n };\n\n options?.signal?.addEventListener('abort', detach, { once: true });\n\n return detach;\n },\n };\n}\n"],"mappings":"AAeA,SAAgB,eAAiE,CAC/E,IAAM,EAAU,IAAI,IAChB,EAAU,GAEd,MAAO,CACL,KAAK,EAAO,CAEN,KAAQ,OAAS,EAErB,IAAK,IAAM,KAAW,EACpB,GAAI,CACF,EAAQ,CAAK,CACf,MAAQ,CAER,CAEJ,EACA,MAAO,CACL,EAAU,GACV,EAAQ,MAAM,CAChB,EACA,IAAI,EAAS,EAAS,CACpB,GAAI,GAAW,GAAS,QAAQ,QAAS,UAAa,CAAC,EAEvD,EAAQ,IAAI,CAAO,EAEnB,IAAM,WAAqB,CACzB,EAAQ,OAAO,CAAO,CACxB,EAIA,OAFA,GAAS,QAAQ,iBAAiB,QAAS,OAAQ,CAAE,KAAM,EAAK,CAAC,EAE1D,MACT,CACF,CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared `tap()` machinery for chart handles.
3
+ *
4
+ * @internal Private to the package: consumers observe charts through
5
+ * `ChartHandle.tap()`, never through this module.
6
+ */
7
+ export declare function createTappers<E extends {
8
+ readonly type: string;
9
+ }>(): Tappers<E>;
10
+ //# sourceMappingURL=_tappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_tappers.d.ts","sourceRoot":"","sources":["../src/_tappers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAmC/E"}
@@ -0,0 +1,2 @@
1
+ function createTappers(){let e=new Set,t=!1;return{emit(t){if(e.size!==0)for(let n of e)try{n(t)}catch{}},stop(){t=!0,e.clear()},tap(n,r){if(t||r?.signal?.aborted)return()=>{};e.add(n);let detach=()=>{e.delete(n)};return r?.signal?.addEventListener(`abort`,detach,{once:!0}),detach}}}export{createTappers};
2
+ //# sourceMappingURL=_tappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_tappers.js","names":[],"sources":["../src/_tappers.ts"],"sourcesContent":["/**\n * Shared `tap()` machinery for chart handles.\n *\n * @internal Private to the package: consumers observe charts through\n * `ChartHandle.tap()`, never through this module.\n */\n\nexport interface Tappers<E extends { readonly type: string }> {\n /** Delivers `event` to every registered handler, swallowing handler errors. */\n emit(event: E): void;\n /** Clears every handler; later `tap()` calls return a no-op unsubscribe. */\n stop(): void;\n tap(handler: (event: E) => void, options?: { readonly signal?: AbortSignal }): () => void;\n}\n\nexport function createTappers<E extends { readonly type: string }>(): Tappers<E> {\n const tappers = new Set<(event: E) => void>();\n let stopped = false;\n\n return {\n emit(event) {\n // Zero-overhead guard: observation costs nothing while nobody is watching.\n if (tappers.size === 0) return;\n\n for (const handler of tappers) {\n try {\n handler(event);\n } catch {\n // Observability must never affect chart behavior.\n }\n }\n },\n stop() {\n stopped = true;\n tappers.clear();\n },\n tap(handler, options) {\n if (stopped || options?.signal?.aborted) return () => {};\n\n tappers.add(handler);\n\n const detach = (): void => {\n tappers.delete(handler);\n };\n\n options?.signal?.addEventListener('abort', detach, { once: true });\n\n return detach;\n },\n };\n}\n"],"mappings":"AAeA,SAAgB,eAAiE,CAC/E,IAAM,EAAU,IAAI,IAChB,EAAU,GAEd,MAAO,CACL,KAAK,EAAO,CAEN,KAAQ,OAAS,EAErB,IAAK,IAAM,KAAW,EACpB,GAAI,CACF,EAAQ,CAAK,CACf,MAAQ,CAER,CAEJ,EACA,MAAO,CACL,EAAU,GACV,EAAQ,MAAM,CAChB,EACA,IAAI,EAAS,EAAS,CACpB,GAAI,GAAW,GAAS,QAAQ,QAAS,UAAa,CAAC,EAEvD,EAAQ,IAAI,CAAO,EAEnB,IAAM,WAAqB,CACzB,EAAQ,OAAO,CAAO,CACxB,EAIA,OAFA,GAAS,QAAQ,iBAAiB,QAAS,OAAQ,CAAE,KAAM,EAAK,CAAC,EAE1D,MACT,CACF,CACF"}
@@ -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"}
@@ -1,2 +1,2 @@
1
- const e=require("./easing.cjs"),t=require("./motion.cjs"),n=require("./tween.cjs");function animate(r,i,a,o){let s=t.resolveMotion(i),c=s.duration,l=e.resolveEasing(s.easing),u=s.stagger;if(c===0||r.length===0){for(let e of r)for(let[t,{to:n}]of Object.entries(e.attrs))e.el.setAttribute(t,String(n));return a?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(r.length-1));function frame(e){if(f||o?.aborted)return;d===null&&(d=e);let t=e-d;for(let e=0;e<r.length;e++){let i=r[e],a=u*e,o=Math.max(0,t-a),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n.tweenNumber(t,r,d)))}t<p?requestAnimationFrame(frame):a?.()}return requestAnimationFrame(frame),()=>{f=!0}}exports.animate=animate;
1
+ const e=require("./easing.cjs"),t=require("./motion.cjs"),n=require("./tween.cjs");function startTween(e){let{count:t,duration:n,easing:r,stagger:i=0,signal:a,onFrame:o,onComplete:s}=e;if(a?.aborted)return()=>{};if(n<=0)return o(()=>1),s?.(),()=>{};if(t===0)return s?.(),()=>{};let c=n+i*(t-1),l=null,u=null,d=!1,cancel=()=>{d=!0,u!==null&&(cancelAnimationFrame(u),u=null),a?.removeEventListener(`abort`,cancel)},frame=e=>{if(d||a?.aborted)return;l===null&&(l=e);let t=e-l;o(e=>r(Math.max(0,Math.min(1,(t-e*i)/n)))),t<c?u=requestAnimationFrame(frame):(u=null,a?.removeEventListener(`abort`,cancel),s?.())};return a?.addEventListener(`abort`,cancel,{once:!0}),u=requestAnimationFrame(frame),cancel}function animate(r,i,a,o){let s=t.resolveMotion(i);return startTween({count:r.length,duration:s.duration,easing:e.resolveEasing(s.easing),onComplete:a,onFrame:e=>{for(let[t,i]of r.entries()){let r=e(t);for(let[e,{from:t,to:a}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n.tweenNumber(t,a,r)))}},signal:o,stagger:s.stagger})}exports.animate=animate,exports.startTween=startTween;
2
2
  //# sourceMappingURL=transition.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transition.cjs","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":"mFAgBA,SAAgB,QACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAA,cAAc,CAAM,EAC7B,EAAW,EAAO,SAClB,EAAS,EAAA,cAAc,EAAO,MAAM,EACpC,EAAU,EAAO,QAEvB,GAAI,IAAa,GAAK,EAAQ,SAAW,EAAG,CAC1C,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,CAAE,SAAS,OAAO,QAAQ,EAAO,KAAK,EACtD,EAAO,GAAG,aAAa,EAAM,OAAO,CAAE,CAAC,EAM3C,OAFA,IAAa,MAEA,CAAC,CAChB,CAEA,IAAI,EAA2B,KAC3B,EAAY,GACV,EAAgB,KAAK,IAAI,EAAU,EAAW,GAAW,EAAQ,OAAS,EAAE,EAElF,SAAS,MAAM,EAAmB,CAChC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GACjB,EAAQ,EAAU,EAClB,EAAe,KAAK,IAAI,EAAG,EAAU,CAAK,EAC1C,EAAI,KAAK,IAAI,EAAG,EAAe,CAAQ,EACvC,EAAQ,EAAO,CAAC,EAEtB,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAA,YAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CAEI,EAAU,EACZ,sBAAsB,KAAK,EAE3B,IAAa,CAEjB,CAIA,OAFA,sBAAsB,KAAK,MAEd,CACX,EAAY,EACd,CACF"}
1
+ {"version":3,"file":"transition.cjs","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\nimport type { EasingFn } from './easing';\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\nexport interface TweenOptions {\n /** Number of staggered lanes; the loop runs until the last lane finishes. */\n count: number;\n /** Milliseconds per lane. A non-positive value completes synchronously. */\n duration: number;\n easing: EasingFn;\n onComplete?: () => void;\n /**\n * Runs once per frame (and once synchronously for a zero-length tween). Receives a\n * `progress(lane)` resolver returning that lane's eased 0-1 value, so callers\n * interpolate their own values without re-deriving elapsed time.\n */\n onFrame: (progress: (lane: number) => number) => void;\n /** Aborted when the owning chart is disposed: cancels the in-flight frame. */\n signal?: AbortSignal;\n /** Per-lane delay in milliseconds; each lane starts `stagger` ms after the previous. */\n stagger?: number;\n}\n\n/**\n * The package's single `requestAnimationFrame` tween loop. Every animated surface\n * (bar, line, area, pie, radar, sparkline) drives its transition through here, so\n * disposal-correctness is enforced in exactly one place: an aborted `signal` cancels\n * the in-flight frame and stops rescheduling.\n *\n * Elapsed time comes from the timestamp the browser passes to the frame callback,\n * never a captured `performance.now()`. Returns a `cancel()` function for superseding\n * a tween before it ends.\n */\nexport function startTween(options: TweenOptions): () => void {\n const { count, duration, easing, stagger = 0, signal, onFrame, onComplete } = options;\n\n if (signal?.aborted) return () => {};\n\n // A zero-length (or reduced-motion) tween applies its final frame synchronously: no rAF.\n if (duration <= 0) {\n onFrame(() => 1);\n onComplete?.();\n\n return () => {};\n }\n\n if (count === 0) {\n onComplete?.();\n\n return () => {};\n }\n\n const totalDuration = duration + stagger * (count - 1);\n let startTime: number | null = null;\n let rafId: number | null = null;\n let cancelled = false;\n\n const cancel = (): void => {\n cancelled = true;\n\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n rafId = null;\n }\n\n signal?.removeEventListener('abort', cancel);\n };\n\n const frame = (timestamp: number): void => {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n onFrame((lane) => easing(Math.max(0, Math.min(1, (elapsed - lane * stagger) / duration))));\n\n if (elapsed < totalDuration) {\n rafId = requestAnimationFrame(frame);\n } else {\n rafId = null;\n signal?.removeEventListener('abort', cancel);\n onComplete?.();\n }\n };\n\n signal?.addEventListener('abort', cancel, { once: true });\n rafId = requestAnimationFrame(frame);\n\n return cancel;\n}\n\n/**\n * Runs a batch of numeric-attribute tweens through {@link startTween}, sharing one\n * `requestAnimationFrame` loop. Returns the loop's `cancel()` function.\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n\n return startTween({\n count: targets.length,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete,\n onFrame: (progress) => {\n for (const [lane, target] of targets.entries()) {\n const eased = progress(lane);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n },\n signal,\n stagger: motion.stagger,\n });\n}\n"],"mappings":"mFAwCA,SAAgB,WAAW,EAAmC,CAC5D,GAAM,CAAE,QAAO,WAAU,SAAQ,UAAU,EAAG,SAAQ,UAAS,cAAe,EAE9E,GAAI,GAAQ,QAAS,UAAa,CAAC,EAGnC,GAAI,GAAY,EAId,OAHA,MAAc,CAAC,EACf,IAAa,MAEA,CAAC,EAGhB,GAAI,IAAU,EAGZ,OAFA,IAAa,MAEA,CAAC,EAGhB,IAAM,EAAgB,EAAW,GAAW,EAAQ,GAChD,EAA2B,KAC3B,EAAuB,KACvB,EAAY,GAEV,WAAqB,CACzB,EAAY,GAER,IAAU,OACZ,qBAAqB,CAAK,EAC1B,EAAQ,MAGV,GAAQ,oBAAoB,QAAS,MAAM,CAC7C,EAEM,MAAS,GAA4B,CACzC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,EAAS,GAAS,EAAO,KAAK,IAAI,EAAG,KAAK,IAAI,GAAI,EAAU,EAAO,GAAW,CAAQ,CAAC,CAAC,CAAC,EAErF,EAAU,EACZ,EAAQ,sBAAsB,KAAK,GAEnC,EAAQ,KACR,GAAQ,oBAAoB,QAAS,MAAM,EAC3C,IAAa,EAEjB,EAKA,OAHA,GAAQ,iBAAiB,QAAS,OAAQ,CAAE,KAAM,EAAK,CAAC,EACxD,EAAQ,sBAAsB,KAAK,EAE5B,MACT,CAMA,SAAgB,QACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAA,cAAc,CAAM,EAEnC,OAAO,WAAW,CAChB,MAAO,EAAQ,OACf,SAAU,EAAO,SACjB,OAAQ,EAAA,cAAc,EAAO,MAAM,EACnC,aACA,QAAU,GAAa,CACrB,IAAK,GAAM,CAAC,EAAM,KAAW,EAAQ,QAAQ,EAAG,CAC9C,IAAM,EAAQ,EAAS,CAAI,EAE3B,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAA,YAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CACF,EACA,SACA,QAAS,EAAO,OAClB,CAAC,CACH"}
@@ -1,4 +1,5 @@
1
1
  import type { TransitionConfig } from '../types';
2
+ import type { EasingFn } from './easing';
2
3
  export interface AnimationTarget {
3
4
  attrs: Record<string, {
4
5
  from: number;
@@ -6,10 +7,38 @@ export interface AnimationTarget {
6
7
  }>;
7
8
  el: SVGElement;
8
9
  }
10
+ export interface TweenOptions {
11
+ /** Number of staggered lanes; the loop runs until the last lane finishes. */
12
+ count: number;
13
+ /** Milliseconds per lane. A non-positive value completes synchronously. */
14
+ duration: number;
15
+ easing: EasingFn;
16
+ onComplete?: () => void;
17
+ /**
18
+ * Runs once per frame (and once synchronously for a zero-length tween). Receives a
19
+ * `progress(lane)` resolver returning that lane's eased 0-1 value, so callers
20
+ * interpolate their own values without re-deriving elapsed time.
21
+ */
22
+ onFrame: (progress: (lane: number) => number) => void;
23
+ /** Aborted when the owning chart is disposed: cancels the in-flight frame. */
24
+ signal?: AbortSignal;
25
+ /** Per-lane delay in milliseconds; each lane starts `stagger` ms after the previous. */
26
+ stagger?: number;
27
+ }
28
+ /**
29
+ * The package's single `requestAnimationFrame` tween loop. Every animated surface
30
+ * (bar, line, area, pie, radar, sparkline) drives its transition through here, so
31
+ * disposal-correctness is enforced in exactly one place: an aborted `signal` cancels
32
+ * the in-flight frame and stops rescheduling.
33
+ *
34
+ * Elapsed time comes from the timestamp the browser passes to the frame callback,
35
+ * never a captured `performance.now()`. Returns a `cancel()` function for superseding
36
+ * a tween before it ends.
37
+ */
38
+ export declare function startTween(options: TweenOptions): () => void;
9
39
  /**
10
- * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.
11
- * Returns a `cancel()` function the caller can invoke to stop the loop early
12
- * (e.g. a fresh render superseding this batch, or `signal` aborting).
40
+ * Runs a batch of numeric-attribute tweens through {@link startTween}, sharing one
41
+ * `requestAnimationFrame` loop. Returns the loop's `cancel()` function.
13
42
  */
14
43
  export declare function animate(targets: AnimationTarget[], config?: TransitionConfig, onComplete?: () => void, signal?: AbortSignal): () => void;
15
44
  //# sourceMappingURL=transition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/animation/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMjD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,EAAE,EAAE,UAAU,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,CAAC,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,MAAM,IAAI,EACvB,MAAM,CAAC,EAAE,WAAW,GACnB,MAAM,IAAI,CAqDZ"}
1
+ {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/animation/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;;;OAIG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,KAAK,IAAI,CAAC;IACtD,8EAA8E;IAC9E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,IAAI,CAyD5D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,CAAC,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,MAAM,IAAI,EACvB,MAAM,CAAC,EAAE,WAAW,GACnB,MAAM,IAAI,CAoBZ"}
@@ -1,2 +1,2 @@
1
- import{resolveEasing as e}from"./easing.js";import{resolveMotion as t}from"./motion.js";import{tweenNumber as n}from"./tween.js";function animate(r,i,a,o){let s=t(i),c=s.duration,l=e(s.easing),u=s.stagger;if(c===0||r.length===0){for(let e of r)for(let[t,{to:n}]of Object.entries(e.attrs))e.el.setAttribute(t,String(n));return a?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(r.length-1));function frame(e){if(f||o?.aborted)return;d===null&&(d=e);let t=e-d;for(let e=0;e<r.length;e++){let i=r[e],a=u*e,o=Math.max(0,t-a),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n(t,r,d)))}t<p?requestAnimationFrame(frame):a?.()}return requestAnimationFrame(frame),()=>{f=!0}}export{animate};
1
+ import{resolveEasing as e}from"./easing.js";import{resolveMotion as t}from"./motion.js";import{tweenNumber as n}from"./tween.js";function startTween(e){let{count:t,duration:n,easing:r,stagger:i=0,signal:a,onFrame:o,onComplete:s}=e;if(a?.aborted)return()=>{};if(n<=0)return o(()=>1),s?.(),()=>{};if(t===0)return s?.(),()=>{};let c=n+i*(t-1),l=null,u=null,d=!1,cancel=()=>{d=!0,u!==null&&(cancelAnimationFrame(u),u=null),a?.removeEventListener(`abort`,cancel)},frame=e=>{if(d||a?.aborted)return;l===null&&(l=e);let t=e-l;o(e=>r(Math.max(0,Math.min(1,(t-e*i)/n)))),t<c?u=requestAnimationFrame(frame):(u=null,a?.removeEventListener(`abort`,cancel),s?.())};return a?.addEventListener(`abort`,cancel,{once:!0}),u=requestAnimationFrame(frame),cancel}function animate(r,i,a,o){let s=t(i);return startTween({count:r.length,duration:s.duration,easing:e(s.easing),onComplete:a,onFrame:e=>{for(let[t,i]of r.entries()){let r=e(t);for(let[e,{from:t,to:a}]of Object.entries(i.attrs))i.el.setAttribute(e,String(n(t,a,r)))}},signal:o,stagger:s.stagger})}export{animate,startTween};
2
2
  //# sourceMappingURL=transition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transition.js","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\n\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\n/**\n * Runs a batch of attribute tweens, sharing one `requestAnimationFrame` loop.\n * Returns a `cancel()` function the caller can invoke to stop the loop early\n * (e.g. a fresh render superseding this batch, or `signal` aborting).\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n const duration = motion.duration;\n const easing = resolveEasing(motion.easing);\n const stagger = motion.stagger;\n\n if (duration === 0 || targets.length === 0) {\n for (const target of targets) {\n for (const [attr, { to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(to));\n }\n }\n\n onComplete?.();\n\n return () => {};\n }\n\n let startTime: number | null = null;\n let cancelled = false;\n const totalDuration = Math.max(duration, duration + stagger * (targets.length - 1));\n\n function frame(timestamp: number) {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const delay = stagger * i;\n const localElapsed = Math.max(0, elapsed - delay);\n const t = Math.min(1, localElapsed / duration);\n const eased = easing(t);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n\n if (elapsed < totalDuration) {\n requestAnimationFrame(frame);\n } else {\n onComplete?.();\n }\n }\n\n requestAnimationFrame(frame);\n\n return () => {\n cancelled = true;\n };\n}\n"],"mappings":"iIAgBA,SAAgB,QACd,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAS,EAAc,CAAM,EAC7B,EAAW,EAAO,SAClB,EAAS,EAAc,EAAO,MAAM,EACpC,EAAU,EAAO,QAEvB,GAAI,IAAa,GAAK,EAAQ,SAAW,EAAG,CAC1C,IAAK,IAAM,KAAU,EACnB,IAAK,GAAM,CAAC,EAAM,CAAE,SAAS,OAAO,QAAQ,EAAO,KAAK,EACtD,EAAO,GAAG,aAAa,EAAM,OAAO,CAAE,CAAC,EAM3C,OAFA,IAAa,MAEA,CAAC,CAChB,CAEA,IAAI,EAA2B,KAC3B,EAAY,GACV,EAAgB,KAAK,IAAI,EAAU,EAAW,GAAW,EAAQ,OAAS,EAAE,EAElF,SAAS,MAAM,EAAmB,CAChC,GAAI,GAAa,GAAQ,QAAS,OAE9B,IAAc,OAAM,EAAY,GAEpC,IAAM,EAAU,EAAY,EAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GACjB,EAAQ,EAAU,EAClB,EAAe,KAAK,IAAI,EAAG,EAAU,CAAK,EAC1C,EAAI,KAAK,IAAI,EAAG,EAAe,CAAQ,EACvC,EAAQ,EAAO,CAAC,EAEtB,IAAK,GAAM,CAAC,EAAM,CAAE,OAAM,SAAS,OAAO,QAAQ,EAAO,KAAK,EAC5D,EAAO,GAAG,aAAa,EAAM,OAAO,EAAY,EAAM,EAAI,CAAK,CAAC,CAAC,CAErE,CAEI,EAAU,EACZ,sBAAsB,KAAK,EAE3B,IAAa,CAEjB,CAIA,OAFA,sBAAsB,KAAK,MAEd,CACX,EAAY,EACd,CACF"}
1
+ {"version":3,"file":"transition.js","names":[],"sources":["../../src/animation/transition.ts"],"sourcesContent":["import type { TransitionConfig } from '../types';\nimport type { EasingFn } from './easing';\nimport { resolveEasing } from './easing';\nimport { resolveMotion } from './motion';\nimport { tweenNumber } from './tween';\n\nexport interface AnimationTarget {\n attrs: Record<string, { from: number; to: number }>;\n el: SVGElement;\n}\n\nexport interface TweenOptions {\n /** Number of staggered lanes; the loop runs until the last lane finishes. */\n count: number;\n /** Milliseconds per lane. A non-positive value completes synchronously. */\n duration: number;\n easing: EasingFn;\n onComplete?: () => void;\n /**\n * Runs once per frame (and once synchronously for a zero-length tween). Receives a\n * `progress(lane)` resolver returning that lane's eased 0-1 value, so callers\n * interpolate their own values without re-deriving elapsed time.\n */\n onFrame: (progress: (lane: number) => number) => void;\n /** Aborted when the owning chart is disposed: cancels the in-flight frame. */\n signal?: AbortSignal;\n /** Per-lane delay in milliseconds; each lane starts `stagger` ms after the previous. */\n stagger?: number;\n}\n\n/**\n * The package's single `requestAnimationFrame` tween loop. Every animated surface\n * (bar, line, area, pie, radar, sparkline) drives its transition through here, so\n * disposal-correctness is enforced in exactly one place: an aborted `signal` cancels\n * the in-flight frame and stops rescheduling.\n *\n * Elapsed time comes from the timestamp the browser passes to the frame callback,\n * never a captured `performance.now()`. Returns a `cancel()` function for superseding\n * a tween before it ends.\n */\nexport function startTween(options: TweenOptions): () => void {\n const { count, duration, easing, stagger = 0, signal, onFrame, onComplete } = options;\n\n if (signal?.aborted) return () => {};\n\n // A zero-length (or reduced-motion) tween applies its final frame synchronously: no rAF.\n if (duration <= 0) {\n onFrame(() => 1);\n onComplete?.();\n\n return () => {};\n }\n\n if (count === 0) {\n onComplete?.();\n\n return () => {};\n }\n\n const totalDuration = duration + stagger * (count - 1);\n let startTime: number | null = null;\n let rafId: number | null = null;\n let cancelled = false;\n\n const cancel = (): void => {\n cancelled = true;\n\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n rafId = null;\n }\n\n signal?.removeEventListener('abort', cancel);\n };\n\n const frame = (timestamp: number): void => {\n if (cancelled || signal?.aborted) return;\n\n if (startTime === null) startTime = timestamp;\n\n const elapsed = timestamp - startTime;\n\n onFrame((lane) => easing(Math.max(0, Math.min(1, (elapsed - lane * stagger) / duration))));\n\n if (elapsed < totalDuration) {\n rafId = requestAnimationFrame(frame);\n } else {\n rafId = null;\n signal?.removeEventListener('abort', cancel);\n onComplete?.();\n }\n };\n\n signal?.addEventListener('abort', cancel, { once: true });\n rafId = requestAnimationFrame(frame);\n\n return cancel;\n}\n\n/**\n * Runs a batch of numeric-attribute tweens through {@link startTween}, sharing one\n * `requestAnimationFrame` loop. Returns the loop's `cancel()` function.\n */\nexport function animate(\n targets: AnimationTarget[],\n config?: TransitionConfig,\n onComplete?: () => void,\n signal?: AbortSignal,\n): () => void {\n const motion = resolveMotion(config);\n\n return startTween({\n count: targets.length,\n duration: motion.duration,\n easing: resolveEasing(motion.easing),\n onComplete,\n onFrame: (progress) => {\n for (const [lane, target] of targets.entries()) {\n const eased = progress(lane);\n\n for (const [attr, { from, to }] of Object.entries(target.attrs)) {\n target.el.setAttribute(attr, String(tweenNumber(from, to, eased)));\n }\n }\n },\n signal,\n stagger: motion.stagger,\n });\n}\n"],"mappings":"iIAwCA,SAAgB,WAAW,EAAmC,C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,CAAC,CAAC,CAErE,CACF,EACA,SACA,QAAS,EAAO,OAClB,CAAC,CACH"}
@@ -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,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,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 _?.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:()=>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 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,EAAK,SAAW,EAAG,CACrB,EAAA,kBAAkB,EAAQ,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,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,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 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 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,EA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":["../../../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,CAwHhH"}
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,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,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 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:()=>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 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,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B,KAC9B,EAAa,EAAO,OAExB,OAAO,EACL,EACA,EACC,GAAQ,CACP,G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G,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,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 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 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,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B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,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("../../core/datum-style.cjs"),a=require("../../core/ids.cjs"),o=require("../../svg/path.cjs");var s=new WeakMap,c=new WeakMap;function buildLinePath(e,t){return t===`monotone`?o.monotonePath(e):t===`step`?o.stepPath(e):o.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:a.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(a,l,u,d){let f=n.resolveMotion(d.transition,0),p=f.duration,m=t.resolveEasing(f.easing),h=a.querySelector(`.prism-area-fill`);h||(h=e.createSvgElement(`path`,{class:`prism-area-fill`}),a.appendChild(h)),applyAreaFill(a,h,d);let g=null,_=[],v=[],y=i.hasStyledRuns(d.marks),b=d.marks??[];if(d.showLine){if(y){_=i.computeStyleRuns(b,l.length);let t=[...a.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(_.length))e.remove();v=_.map((n,r)=>{let i=t[r];if(i)return i;let o=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`});return a.appendChild(o),o});for(let[t,n]of _.entries())e.setAttributes(v[t],{opacity:n.opacity,stroke:d.color,"stroke-dasharray":n.dash,"stroke-width":2});g=null}else{let t=[...a.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(1))e.remove();g=t[0]??null,g||(g=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`}),a.appendChild(g)),e.setAttributes(g,{opacity:void 0,stroke:d.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of a.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=t=>{if(d.showLine){if(y)for(let[n,r]of _.entries())e.setAttributes(v[n],{d:buildLinePath(t.slice(r.start,r.end+1),d.curve)});else g&&e.setAttributes(g,{d:buildLinePath(t,d.curve)})}};if(p===0){let t=l.map(e=>({x:e.x,y:u}));e.setAttributes(h,{d:o.areaPath(l,t,d.curve)}),drawLine(l);return}if(s.get(a)?.(),!h.hasAttribute(`d`)){let t=l.map(e=>({x:e.x,y:u}));e.setAttributes(h,{d:o.areaPath(l,t,d.curve)}),drawLine(l),c.set(a,l);return}let x=c.get(a)??l,S=l.map((e,t)=>x[t]??x[x.length-1]??l[t]),C=null;function frame(t){if(d.disposalSignal?.aborted){s.delete(a);return}C===null&&(C=t);let n=Math.min(1,(t-C)/p),i=m(n),f=l.map((e,t)=>({x:r.tweenNumber(S[t].x,e.x,i),y:r.tweenNumber(S[t].y,e.y,i)})),g=f.map(e=>({x:e.x,y:u}));if(e.setAttributes(h,{d:o.areaPath(f,g,d.curve)}),drawLine(f),n<1){let e=requestAnimationFrame(frame);s.set(a,()=>cancelAnimationFrame(e))}else s.delete(a),c.set(a,l)}c.set(a,S);let w=requestAnimationFrame(frame);s.set(a,()=>cancelAnimationFrame(w))}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 { 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 let startTime: number | null = null;\n\n function frame(ts: number) {\n if (options.disposalSignal?.aborted) {\n activeAreaAnimations.delete(parent);\n\n return;\n }\n\n if (startTime === null) startTime = ts;\n\n const t = Math.min(1, (ts - startTime) / dur);\n const e = easing(t);\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\n drawLine(interpolated);\n\n if (t < 1) {\n const id = requestAnimationFrame(frame);\n\n activeAreaAnimations.set(parent, () => cancelAnimationFrame(id));\n } else {\n activeAreaAnimations.delete(parent);\n previousPoints.set(parent, points);\n }\n }\n\n previousPoints.set(parent, fromPoints);\n\n const id = requestAnimationFrame(frame);\n\n activeAreaAnimations.set(parent, () => cancelAnimationFrame(id));\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":"kSAyBA,IAAM,EAAuB,IAAI,QAC3B,EAAiB,IAAI,QAE3B,SAAS,cAAc,EAAc,EAA2C,CAC9E,OAAO,IAAU,WAAa,EAAA,aAAa,CAAG,EAAI,IAAU,OAAS,EAAA,SAAS,CAAG,EAAI,EAAA,SAAS,CAAG,CACnG,CAGA,SAAS,cAAc,EAAqB,EAAsB,EAAkC,CAClG,IAAI,EAAW,EAAO,cAAwC,gBAAgB,EAE9E,GAAI,EAAQ,OAAS,WAAY,CAC/B,GAAI,CAAC,EAAU,CACb,IAAM,EAAO,EAAA,iBAAiB,MAAM,EAEpC,EAAW,EAAA,iBAAiB,iBAAkB,CAAE,GAAI,EAAA,SAAS,iBAAiB,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAAE,CAAC,EAC7G,EAAS,OACP,EAAA,iBAAiB,OAAQ,CAAE,MAAO,sBAAuB,OAAQ,CAAE,CAAC,EACpE,EAAA,iBAAiB,OAAQ,CAAE,MAAO,yBAA0B,OAAQ,CAAE,CAAC,CACzE,EACA,EAAK,YAAY,CAAQ,EACzB,EAAO,aAAa,EAAM,EAAO,UAAU,CAC7C,CAEA,IAAK,IAAM,KAAQ,EAAS,iBAAiB,MAAM,EACjD,EAAK,aAAa,aAAc,EAAQ,KAAK,EAC7C,EAAK,MAAM,UAAY,EAAQ,MAGjC,EAAA,cAAc,EAAM,CAAE,KAAM,QAAQ,EAAS,GAAG,EAAG,CAAC,CACtD,MACE,GAAU,eAAe,OAAO,EAChC,EAAA,cAAc,EAAM,CAAE,KAAM,EAAQ,KAAM,CAAC,EAG7C,EAAA,cAAc,EAAM,CAAE,MAAO,oCAAoC,EAAQ,OAAQ,OAAQ,MAAO,CAAC,EACjG,EAAK,MAAM,YAAc,EA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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,QAExB,SAAS,cAAc,EAAc,EAA2C,CAC9E,OAAO,IAAU,WAAa,EAAA,aAAa,CAAG,EAAI,IAAU,OAAS,EAAA,SAAS,CAAG,EAAI,EAAA,SAAS,CAAG,CACnG,CAGA,SAAS,cAAc,EAAqB,EAAsB,EAAkC,CAClG,IAAI,EAAW,EAAO,cAAwC,gBAAgB,EAE9E,GAAI,EAAQ,OAAS,WAAY,CAC/B,GAAI,CAAC,EAAU,CACb,IAAM,EAAO,EAAA,iBAAiB,MAAM,EAEpC,EAAW,EAAA,iBAAiB,iBAAkB,CAAE,GAAI,EAAA,SAAS,iBAAiB,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAAE,CAAC,EAC7G,EAAS,OACP,EAAA,iBAAiB,OAAQ,CAAE,MAAO,sBAAuB,OAAQ,CAAE,CAAC,EACpE,EAAA,iBAAiB,OAAQ,CAAE,MAAO,yBAA0B,OAAQ,CAAE,CAAC,CACzE,EACA,EAAK,YAAY,CAAQ,EACzB,EAAO,aAAa,EAAM,EAAO,UAAU,CAC7C,CAEA,IAAK,IAAM,KAAQ,EAAS,iBAAiB,MAAM,EACjD,EAAK,aAAa,aAAc,EAAQ,KAAK,EAC7C,EAAK,MAAM,UAAY,EAAQ,MAGjC,EAAA,cAAc,EAAM,CAAE,KAAM,QAAQ,EAAS,GAAG,EAAG,CAAC,CACtD,MACE,GAAU,eAAe,OAAO,EAChC,EA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