@vielzeug/prism 26.10.2 → 26.10.3

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 (89) hide show
  1. package/dist/_dev.cjs.map +1 -1
  2. package/dist/_dev.js.map +1 -1
  3. package/dist/_tappers.cjs +2 -0
  4. package/dist/_tappers.cjs.map +1 -0
  5. package/dist/_tappers.d.ts +10 -0
  6. package/dist/_tappers.d.ts.map +1 -0
  7. package/dist/_tappers.js +2 -0
  8. package/dist/_tappers.js.map +1 -0
  9. package/dist/animation/transition.cjs +1 -1
  10. package/dist/animation/transition.cjs.map +1 -1
  11. package/dist/animation/transition.d.ts +32 -3
  12. package/dist/animation/transition.d.ts.map +1 -1
  13. package/dist/animation/transition.js +1 -1
  14. package/dist/animation/transition.js.map +1 -1
  15. package/dist/charts/area/area-chart.cjs +1 -1
  16. package/dist/charts/area/area-chart.cjs.map +1 -1
  17. package/dist/charts/area/area-chart.d.ts.map +1 -1
  18. package/dist/charts/area/area-chart.js +1 -1
  19. package/dist/charts/area/area-chart.js.map +1 -1
  20. package/dist/charts/area/area-renderer.cjs +1 -1
  21. package/dist/charts/area/area-renderer.cjs.map +1 -1
  22. package/dist/charts/area/area-renderer.d.ts.map +1 -1
  23. package/dist/charts/area/area-renderer.js +1 -1
  24. package/dist/charts/area/area-renderer.js.map +1 -1
  25. package/dist/charts/line/line-chart.cjs +1 -1
  26. package/dist/charts/line/line-chart.cjs.map +1 -1
  27. package/dist/charts/line/line-chart.d.ts.map +1 -1
  28. package/dist/charts/line/line-chart.js +1 -1
  29. package/dist/charts/line/line-chart.js.map +1 -1
  30. package/dist/charts/line/line-renderer.cjs +1 -1
  31. package/dist/charts/line/line-renderer.cjs.map +1 -1
  32. package/dist/charts/line/line-renderer.d.ts.map +1 -1
  33. package/dist/charts/line/line-renderer.js +1 -1
  34. package/dist/charts/line/line-renderer.js.map +1 -1
  35. package/dist/charts/pie/pie-chart.cjs +1 -1
  36. package/dist/charts/pie/pie-chart.cjs.map +1 -1
  37. package/dist/charts/pie/pie-chart.d.ts.map +1 -1
  38. package/dist/charts/pie/pie-chart.js +1 -1
  39. package/dist/charts/pie/pie-chart.js.map +1 -1
  40. package/dist/charts/radar/radar-chart.cjs +1 -1
  41. package/dist/charts/radar/radar-chart.cjs.map +1 -1
  42. package/dist/charts/radar/radar-chart.d.ts.map +1 -1
  43. package/dist/charts/radar/radar-chart.js +1 -1
  44. package/dist/charts/radar/radar-chart.js.map +1 -1
  45. package/dist/charts/sparkline/sparkline.cjs +1 -1
  46. package/dist/charts/sparkline/sparkline.cjs.map +1 -1
  47. package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
  48. package/dist/charts/sparkline/sparkline.js +1 -1
  49. package/dist/charts/sparkline/sparkline.js.map +1 -1
  50. package/dist/core/chart-scaffold.cjs +1 -1
  51. package/dist/core/chart-scaffold.cjs.map +1 -1
  52. package/dist/core/chart-scaffold.d.ts.map +1 -1
  53. package/dist/core/chart-scaffold.js +1 -1
  54. package/dist/core/chart-scaffold.js.map +1 -1
  55. package/dist/index.d.ts +1 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/interaction/series-interaction.cjs +1 -1
  58. package/dist/interaction/series-interaction.cjs.map +1 -1
  59. package/dist/interaction/series-interaction.d.ts +3 -1
  60. package/dist/interaction/series-interaction.d.ts.map +1 -1
  61. package/dist/interaction/series-interaction.js +1 -1
  62. package/dist/interaction/series-interaction.js.map +1 -1
  63. package/dist/prism.cjs +1 -1
  64. package/dist/prism.cjs.map +1 -1
  65. package/dist/prism.iife.js +1 -1
  66. package/dist/prism.iife.js.map +1 -1
  67. package/dist/prism.js +1 -1
  68. package/dist/prism.js.map +1 -1
  69. package/dist/types.d.ts +37 -4
  70. package/dist/types.d.ts.map +1 -1
  71. package/package.json +2 -14
  72. package/dist/animation/index.d.ts +0 -6
  73. package/dist/animation/index.d.ts.map +0 -1
  74. package/dist/axes/index.d.ts +0 -3
  75. package/dist/axes/index.d.ts.map +0 -1
  76. package/dist/core/index.d.ts +0 -7
  77. package/dist/core/index.d.ts.map +0 -1
  78. package/dist/devtools/index.d.ts +0 -52
  79. package/dist/devtools/index.d.ts.map +0 -1
  80. package/dist/devtools.cjs +0 -2
  81. package/dist/devtools.cjs.map +0 -1
  82. package/dist/devtools.js +0 -2
  83. package/dist/devtools.js.map +0 -1
  84. package/dist/interaction/index.d.ts +0 -8
  85. package/dist/interaction/index.d.ts.map +0 -1
  86. package/dist/scales/index.d.ts +0 -4
  87. package/dist/scales/index.d.ts.map +0 -1
  88. package/dist/svg/index.d.ts +0 -5
  89. package/dist/svg/index.d.ts.map +0 -1
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
- 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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AAI,CAAK,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);for(f.yAxis?.grid&&n.renderGrid(g.grid,T,f.yAxis.grid,b.width,`horizontal`,t.resolveTickCount(f.yAxis,b.height,`left`)),f.xAxis?.grid&&n.renderGrid(g.grid,w,f.xAxis.grid,b.height,`vertical`,t.resolveTickCount(f.xAxis,b.width,`bottom`)),f.xAxis&&(t.positionAxis(g.xAxis,f.xAxis.position??`bottom`,b.width,b.height),t.renderAxis(g.xAxis,w,f.xAxis,b.width,`bottom`)),f.yAxis&&(t.positionAxis(g.yAxis,f.yAxis.position??`left`,b.width,b.height),t.renderAxis(g.yAxis,T,f.yAxis,b.height,`left`));g.series.children.length>h.length;)g.series.removeChild(g.series.lastChild);let D=[];for(let t=0;t<h.length;t++){let n=h[t],r=g.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-area-series`}),g.series.appendChild(r)),r.setAttribute(`data-series-id`,o.seriesDomId(n,t));let i=u.computeAreaPoints(x[t],w,T);D.push(i),u.renderArea(r,i,E,{color:l.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:d.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:f.transition})}return _?.update(h.map((e,t)=>({color:l.seriesColor(t,e.color),name:e.name}))),v?.hide(),m=c.ensureMarkerGroup(d.chartArea,m),c.createSeriesInteraction({announcer:d.announcer,colors:()=>h.map((e,t)=>l.seriesColor(t,e.color)),crosshair:p,dims:()=>d.dimensions,getData:()=>x,getPoints:()=>D,getSeriesList:()=>h,margin:d.dimensions.margin,markers:m,onClick:f.onClick,onHover:f.onHover,seriesGroup:g.series,svg:d.svg,tooltip:v})},e=>{h=e})}exports.createAreaChart=createAreaChart;
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,EAAQ,EAAS,CAAS,E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,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 } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"mbAcA,SAAgB,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B,KAC9B,EAAa,EAAO,OAExB,OAAO,EAAA,oBACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAO,EAAA,UAAU,EAAK,MAAO,EAAK,OAAQ,EAAK,MAAM,EACrD,EAAU,EAAW,IAAK,GAAW,EAAO,IAAI,EAChD,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAU,EAAM,GAAG,EAC9C,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAM,EAAE,KAAK,EAE9C,GAAI,EAAK,SAAW,EAAG,CACrB,EAAA,kBAAkB,EAAQ,EAAQ,EAAS,CAAS,EACpD,GAAS,gBAAgB,EAEzB,MACF,CAEI,EA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,KAAK,CAAM,EAErB,EAAA,WAAW,EAAO,EAAQ,EAAW,CACnC,MAAO,EAAA,YAAY,EAAG,EAAO,KAAK,EAClC,MAAO,EAAO,OAAS,SACvB,eAAgB,EAAI,eACpB,KAAM,EAAO,MAAQ,WACrB,YAAa,EAAO,YACpB,MAAO,EAAO,KACd,SAAU,EAAO,WAAa,GAC9B,WAAY,EAAO,UACrB,CAAC,CACH,CAMA,OAJA,GAAQ,OAAO,EAAW,KAAK,EAAG,KAAO,CAAE,MAAO,EAAA,YAAY,EAAG,EAAE,KAAK,EAAG,KAAM,EAAE,IAAK,EAAE,CAAC,EAC3F,GAAS,KAAK,EACd,EAAU,EAAA,kBAAkB,EAAI,UAAW,CAAO,EAE3C,EAAA,wBAAwB,CAC7B,UAAW,EAAI,UACf,WAAc,EAAW,KAAK,EAAG,IAAM,EAAA,YAAY,EAAG,EAAE,KAAK,CAAC,EAC9D,YACA,SAAY,EAAI,WAChB,YAAe,EACf,cAAiB,EACjB,kBAAqB,EACrB,OAAQ,EAAI,WAAW,OACvB,UACA,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,YAAa,EAAO,OACpB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../src/charts/area/area-chart.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGlF,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,gBAAgB,EAAE,CAAC,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,EAAE,MAAM,aAAa,CAAC;AAGlF,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,gBAAgB,EAAE,CAAC,CAyHhH"}
@@ -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);for(v.yAxis?.grid&&i(_.grid,A,v.yAxis.grid,T.width,`horizontal`,r(v.yAxis,T.height,`left`)),v.xAxis?.grid&&i(_.grid,k,v.xAxis.grid,T.height,`vertical`,r(v.xAxis,T.width,`bottom`)),v.xAxis&&(t(_.xAxis,v.xAxis.position??`bottom`,T.width,T.height),n(_.xAxis,k,v.xAxis,T.width,`bottom`)),v.yAxis&&(t(_.yAxis,v.yAxis.position??`left`,T.width,T.height),n(_.yAxis,A,v.yAxis,T.height,`left`));_.series.children.length>x.length;)_.series.removeChild(_.series.lastChild);let M=[];for(let t=0;t<x.length;t++){let n=x[t],r=_.series.children[t];r||(r=e(`g`,{class:`prism-area-series`}),_.series.appendChild(r)),r.setAttribute(`data-series-id`,u(n,t));let i=h(E[t],k,A);M.push(i),g(r,i,j,{color:m(t,n.color),curve:n.curve??`linear`,disposalSignal:l.disposalSignal,fill:n.fill??`gradient`,fillOpacity:n.fillOpacity,marks:n.data,showLine:n.showLine!==!1,transition:v.transition})}return S?.update(x.map((e,t)=>({color:m(t,e.color),name:e.name}))),C?.hide(),b=p(l.chartArea,b),f({announcer:l.announcer,colors:()=>x.map((e,t)=>m(t,e.color)),crosshair:y,dims:()=>l.dimensions,getData:()=>E,getPoints:()=>M,getSeriesList:()=>x,margin:l.dimensions.margin,markers:b,onClick:v.onClick,onHover:v.onHover,seriesGroup:_.series,svg:l.svg,tooltip:C})},e=>{x=e})}export{createAreaChart};
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,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAO,EAAU,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,EAAkB,EAAQ,EAAQ,EAAS,CAAS,EACpD,GAAS,gBAAgB,EAEzB,MACF,CAEI,EAAO,WAAa,CAAC,IACvB,EAAY,EAAgB,EAAI,UA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M,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 } from '../../types';\nimport { computeAreaPoints, renderArea } from './area-renderer';\n\nexport function createAreaChart(container: HTMLElement, config: AreaChartConfig): ChartHandle<AreaSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n const baselineY = yScale.map(0);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-area-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computeAreaPoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderArea(group, points, baselineY, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n fill: series.fill ?? 'gradient',\n fillOpacity: series.fillOpacity,\n marks: series.data,\n showLine: series.showLine !== false,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n markers = ensureMarkerGroup(ctx.chartArea, markers);\n\n return createSeriesInteraction({\n announcer: ctx.announcer,\n colors: () => seriesList.map((s, i) => seriesColor(i, s.color)),\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n margin: ctx.dimensions.margin,\n markers,\n onClick: config.onClick,\n onHover: config.onHover,\n seriesGroup: groups.series,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"mvBAcA,SAAgB,gBAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAA8B,KAC9B,EAAa,EAAO,OAExB,OAAO,EACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAO,EAAU,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,EAAkB,EAAQ,EAAQ,EAAS,CAAS,EACpD,GAAS,gBAAgB,EAEzB,MACF,CAEI,EAAO,WAAa,CAAC,IACvB,EAAY,EAAgB,EAAI,UAAW,EAAO,SAAS,GAG7D,IAAM,EAAS,EAAY,EAAM,EAAK,KAAK,EACrC,EAAS,EAAY,EAAM,EAAK,MAAM,EACtC,EAAY,EAAO,IAAI,CAAC,EAkC9B,IAhCI,EAAO,OAAO,MAChB,EACE,EAAO,KACP,EACA,EAAO,MAAM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KAAK,EAAG,KAAM,EAAE,IAAK,EAAE,CAAC,EAC3F,GAAS,KAAK,EACd,EAAU,EAAkB,EAAI,UAAW,CAAO,EAE3C,EAAwB,CAC7B,UAAW,EAAI,UACf,WAAc,EAAW,KAAK,EAAG,IAAM,EAAY,EAAG,EAAE,KAAK,CAAC,EAC9D,YACA,SAAY,EAAI,WAChB,YAAe,EACf,cAAiB,EACjB,kBAAqB,EACrB,OAAQ,EAAI,WAAW,OACvB,UACA,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,YAAa,EAAO,OACpB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- require("../../_dev.cjs");const e=require("../../svg/element.cjs"),t=require("../../animation/easing.cjs"),n=require("../../animation/motion.cjs"),r=require("../../animation/tween.cjs"),i=require("../../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,0),m=p.duration,h=t.resolveEasing(p.easing),g=o.querySelector(`.prism-area-fill`);g||(g=e.createSvgElement(`path`,{class:`prism-area-fill`}),o.appendChild(g)),applyAreaFill(o,g,f);let _=null,v=[],y=[],b=a.hasStyledRuns(f.marks),x=f.marks??[];if(f.showLine){if(b){v=a.computeStyleRuns(x,u.length);let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(v.length))e.remove();y=v.map((n,r)=>{let i=t[r];if(i)return i;let a=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`});return o.appendChild(a),a});for(let[t,n]of v.entries())e.setAttributes(y[t],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});_=null}else{let t=[...o.querySelectorAll(`.prism-area-line`)];for(let e of t.slice(1))e.remove();_=t[0]??null,_||(_=e.createSvgElement(`path`,{class:`prism-area-line`,fill:`none`}),o.appendChild(_)),e.setAttributes(_,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of o.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=t=>{if(f.showLine){if(b)for(let[n,r]of v.entries())e.setAttributes(y[n],{d:buildLinePath(t.slice(r.start,r.end+1),f.curve)});else _&&e.setAttributes(_,{d:buildLinePath(t,f.curve)})}};if(m===0){let t=u.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(u,t,f.curve)}),drawLine(u);return}if(c.get(o)?.(),!g.hasAttribute(`d`)){let t=u.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(u,t,f.curve)}),drawLine(u),l.set(o,u);return}let S=l.get(o)??u,C=u.map((e,t)=>S[t]??S[S.length-1]??u[t]);l.set(o,C),c.set(o,i.startTween({count:1,duration:m,easing:h,onComplete:()=>{c.delete(o),l.set(o,u)},onFrame:t=>{let n=t(0),i=u.map((e,t)=>({x:r.tweenNumber(C[t].x,e.x,n),y:r.tweenNumber(C[t].y,e.y,n)})),a=i.map(e=>({x:e.x,y:d}));e.setAttributes(g,{d:s.areaPath(i,a,f.curve)}),drawLine(i)},signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}exports.computeAreaPoints=computeAreaPoints,exports.renderArea=renderArea;
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,yB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AM,EAClC,EAAe,IAAI,EAAQ,CAAM,CAErC,CAEA,EAAe,IAAI,EAAQ,CAAU,EAErC,IAAM,EAAK,sBAAsB,KAAK,EAEtC,EAAqB,IAAI,MAAc,qBAAqB,CAAE,CAAC,CACjE,CAEA,SAAgB,kBACd,EACA,EACA,EACS,CAST,OARI,EAAK,KAAM,GAAM,EAAE,KAAO,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
1
+ {"version":3,"file":"area-renderer.cjs","names":[],"sources":["../../../src/charts/area/area-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { startTween } from '../../animation/transition';\nimport { tweenNumber } from '../../animation/tween';\nimport { computeStyleRuns, type DatumMark, hasStyledRuns, type StyleRun } from '../../core/datum-style';\nimport { uniqueId } from '../../core/ids';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { areaPath, linePath, monotonePath, stepPath } from '../../svg/path';\nimport type { ContinuousDatum, Scale, TransitionConfig } from '../../types';\n\nexport interface AreaRenderOptions {\n color: string;\n curve: 'linear' | 'monotone' | 'step';\n /** Aborted when the owning chart is disposed: stops the transition's `requestAnimationFrame` loop from rescheduling. */\n disposalSignal?: AbortSignal;\n fill: 'gradient' | 'solid';\n /** Explicit opacity beats the `--prism-area-opacity` theme token. */\n fillOpacity?: number;\n /** Per-datum presentation parallel to `points`; styled runs split the top line into subpaths. */\n marks?: readonly DatumMark[];\n showLine: boolean;\n transition?: TransitionConfig;\n}\n\nconst activeAreaAnimations = new WeakMap<SVGGElement, () => void>();\nconst previousPoints = new WeakMap<SVGGElement, Point[]>();\n\nfunction buildLinePath(pts: Point[], curve: AreaRenderOptions['curve']): string {\n return curve === 'monotone' ? monotonePath(pts) : curve === 'step' ? stepPath(pts) : linePath(pts);\n}\n\n/** A vertical gradient fading to transparent at the baseline, or a flat fill. */\nfunction applyAreaFill(parent: SVGGElement, fill: SVGPathElement, options: AreaRenderOptions): void {\n let gradient = parent.querySelector<SVGLinearGradientElement>('linearGradient');\n\n if (options.fill === 'gradient') {\n if (!gradient) {\n const defs = createSvgElement('defs');\n\n gradient = createSvgElement('linearGradient', { id: uniqueId('prism-area-fill'), x1: 0, x2: 0, y1: 0, y2: 1 });\n gradient.append(\n createSvgElement('stop', { class: 'prism-area-stop-top', offset: 0 }),\n createSvgElement('stop', { class: 'prism-area-stop-bottom', offset: 1 }),\n );\n defs.appendChild(gradient);\n parent.insertBefore(defs, parent.firstChild);\n }\n\n for (const stop of gradient.querySelectorAll('stop')) {\n stop.setAttribute('stop-color', options.color);\n stop.style.stopColor = options.color;\n }\n\n setAttributes(fill, { fill: `url(#${gradient.id})` });\n } else {\n gradient?.parentElement?.remove();\n setAttributes(fill, { fill: options.color });\n }\n\n setAttributes(fill, { class: `prism-area-fill prism-area-fill--${options.fill}`, stroke: 'none' });\n fill.style.fillOpacity = options.fillOpacity === undefined ? '' : String(options.fillOpacity);\n}\n\nexport function renderArea(parent: SVGGElement, points: Point[], baselineY: number, options: AreaRenderOptions): void {\n const motion = resolveMotion(options.transition, 0);\n const dur = motion.duration;\n const easing = resolveEasing(motion.easing);\n\n let fill = parent.querySelector<SVGPathElement>('.prism-area-fill');\n\n if (!fill) {\n fill = createSvgElement('path', { class: 'prism-area-fill' });\n parent.appendChild(fill);\n }\n\n applyAreaFill(parent, fill, options);\n\n let line: SVGPathElement | null = null;\n let runs: readonly StyleRun[] = [];\n let lines: SVGPathElement[] = [];\n const styled = hasStyledRuns(options.marks);\n const marks = options.marks ?? [];\n\n if (options.showLine) {\n if (styled) {\n runs = computeStyleRuns(marks, points.length);\n\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const extra of existing.slice(runs.length)) extra.remove();\n\n lines = runs.map((_, r) => {\n const reuse = existing[r];\n\n if (reuse) return reuse;\n\n const created = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n\n parent.appendChild(created);\n\n return created;\n });\n\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], {\n opacity: run.opacity,\n stroke: options.color,\n 'stroke-dasharray': run.dash,\n 'stroke-width': 2,\n });\n }\n\n line = null;\n } else {\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const stale of existing.slice(1)) stale.remove();\n\n line = existing[0] ?? null;\n\n if (!line) {\n line = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n parent.appendChild(line);\n }\n\n setAttributes(line, {\n opacity: undefined,\n stroke: options.color,\n 'stroke-dasharray': undefined,\n 'stroke-width': 2,\n });\n }\n } else {\n for (const stale of parent.querySelectorAll('.prism-area-line')) stale.remove();\n }\n\n const drawLine = (pts: Point[]): void => {\n if (!options.showLine) return;\n\n if (styled) {\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], { d: buildLinePath(pts.slice(run.start, run.end + 1), options.curve) });\n }\n } else if (line) {\n setAttributes(line, { d: buildLinePath(pts, options.curve) });\n }\n };\n\n if (dur === 0) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n return;\n }\n\n activeAreaAnimations.get(parent)?.();\n\n const hasExisting = fill.hasAttribute('d');\n\n if (!hasExisting) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n previousPoints.set(parent, points);\n\n return;\n }\n\n const rawFrom = previousPoints.get(parent) ?? points;\n const fromPoints: Point[] = points.map((_, i) => rawFrom[i] ?? rawFrom[rawFrom.length - 1] ?? points[i]);\n\n previousPoints.set(parent, fromPoints);\n\n activeAreaAnimations.set(\n parent,\n startTween({\n count: 1,\n duration: dur,\n easing,\n onComplete: () => {\n activeAreaAnimations.delete(parent);\n previousPoints.set(parent, points);\n },\n onFrame: (progress) => {\n const e = progress(0);\n const interpolated: Point[] = points.map((to, i) => ({\n x: tweenNumber(fromPoints[i].x, to.x, e),\n y: tweenNumber(fromPoints[i].y, to.y, e),\n }));\n const interpolatedBottom = interpolated.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill!, { d: areaPath(interpolated, interpolatedBottom, options.curve) });\n drawLine(interpolated);\n },\n signal: options.disposalSignal,\n }),\n );\n}\n\nexport function computeAreaPoints(\n data: ContinuousDatum[],\n xScale: Scale<Date | number>,\n yScale: Scale<number>,\n): Point[] {\n if (data.some((d) => d.key == null)) {\n warn(\n 'computeAreaPoints: datum.key is null or undefined: data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n } else if (data.some((d) => typeof d.key === 'string')) {\n warn('computeAreaPoints: string keys are not supported for line/area charts: use numeric or Date keys.');\n }\n\n return data.map((d) => ({\n x: xScale.map(d.key as Date | number),\n y: yScale.map(d.value),\n }));\n}\n"],"mappings":"8UA0BA,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,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AAC,MAAM,CAAC,GACpB,KAAK,EAAE,CAaT"}
1
+ {"version":3,"file":"area-renderer.d.ts","sourceRoot":"","sources":["../../../src/charts/area/area-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAAgC,MAAM,wBAAwB,CAAC;AAGxG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE5E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACtC,wHAAwH;IACxH,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAyCD,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CA4IpH;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EAAE,EACvB,MAAM,EAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,EAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GACpB,KAAK,EAAE,CAaT"}
@@ -1,2 +1,2 @@
1
- import"../../_dev.js";import{createSvgElement as e,setAttributes as t}from"../../svg/element.js";import{resolveEasing as n}from"../../animation/easing.js";import{resolveMotion as r}from"../../animation/motion.js";import{tweenNumber as i}from"../../animation/tween.js";import{computeStyleRuns as a,hasStyledRuns as o}from"../../core/datum-style.js";import{uniqueId as s}from"../../core/ids.js";import{areaPath as c,linePath as l,monotonePath as u,stepPath as d}from"../../svg/path.js";var f=new WeakMap,p=new WeakMap;function buildLinePath(e,t){return t===`monotone`?u(e):t===`step`?d(e):l(e)}function applyAreaFill(n,r,i){let a=n.querySelector(`linearGradient`);if(i.fill===`gradient`){if(!a){let t=e(`defs`);a=e(`linearGradient`,{id:s(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),a.append(e(`stop`,{class:`prism-area-stop-top`,offset:0}),e(`stop`,{class:`prism-area-stop-bottom`,offset:1})),t.appendChild(a),n.insertBefore(t,n.firstChild)}for(let e of a.querySelectorAll(`stop`))e.setAttribute(`stop-color`,i.color),e.style.stopColor=i.color;t(r,{fill:`url(#${a.id})`})}else a?.parentElement?.remove(),t(r,{fill:i.color});t(r,{class:`prism-area-fill prism-area-fill--${i.fill}`,stroke:`none`}),r.style.fillOpacity=i.fillOpacity===void 0?``:String(i.fillOpacity)}function renderArea(s,l,u,d){let m=r(d.transition,0),h=m.duration,g=n(m.easing),_=s.querySelector(`.prism-area-fill`);_||(_=e(`path`,{class:`prism-area-fill`}),s.appendChild(_)),applyAreaFill(s,_,d);let v=null,y=[],b=[],x=o(d.marks),S=d.marks??[];if(d.showLine){if(x){y=a(S,l.length);let n=[...s.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(y.length))e.remove();b=y.map((t,r)=>{let i=n[r];if(i)return i;let a=e(`path`,{class:`prism-area-line`,fill:`none`});return s.appendChild(a),a});for(let[e,n]of y.entries())t(b[e],{opacity:n.opacity,stroke:d.color,"stroke-dasharray":n.dash,"stroke-width":2});v=null}else{let n=[...s.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(1))e.remove();v=n[0]??null,v||(v=e(`path`,{class:`prism-area-line`,fill:`none`}),s.appendChild(v)),t(v,{opacity:void 0,stroke:d.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of s.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=e=>{if(d.showLine){if(x)for(let[n,r]of y.entries())t(b[n],{d:buildLinePath(e.slice(r.start,r.end+1),d.curve)});else v&&t(v,{d:buildLinePath(e,d.curve)})}};if(h===0){let e=l.map(e=>({x:e.x,y:u}));t(_,{d:c(l,e,d.curve)}),drawLine(l);return}if(f.get(s)?.(),!_.hasAttribute(`d`)){let e=l.map(e=>({x:e.x,y:u}));t(_,{d:c(l,e,d.curve)}),drawLine(l),p.set(s,l);return}let C=p.get(s)??l,w=l.map((e,t)=>C[t]??C[C.length-1]??l[t]),T=null;function frame(e){if(d.disposalSignal?.aborted){f.delete(s);return}T===null&&(T=e);let n=Math.min(1,(e-T)/h),r=g(n),a=l.map((e,t)=>({x:i(w[t].x,e.x,r),y:i(w[t].y,e.y,r)})),o=a.map(e=>({x:e.x,y:u}));if(t(_,{d:c(a,o,d.curve)}),drawLine(a),n<1){let e=requestAnimationFrame(frame);f.set(s,()=>cancelAnimationFrame(e))}else f.delete(s),p.set(s,l)}p.set(s,w);let E=requestAnimationFrame(frame);f.set(s,()=>cancelAnimationFrame(E))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}export{computeAreaPoints,renderArea};
1
+ import"../../_dev.js";import{createSvgElement as e,setAttributes as t}from"../../svg/element.js";import{resolveEasing as n}from"../../animation/easing.js";import{resolveMotion as r}from"../../animation/motion.js";import{tweenNumber as i}from"../../animation/tween.js";import{startTween as a}from"../../animation/transition.js";import{computeStyleRuns as o,hasStyledRuns as s}from"../../core/datum-style.js";import{uniqueId as c}from"../../core/ids.js";import{areaPath as l,linePath as u,monotonePath as d,stepPath as f}from"../../svg/path.js";var p=new WeakMap,m=new WeakMap;function buildLinePath(e,t){return t===`monotone`?d(e):t===`step`?f(e):u(e)}function applyAreaFill(n,r,i){let a=n.querySelector(`linearGradient`);if(i.fill===`gradient`){if(!a){let t=e(`defs`);a=e(`linearGradient`,{id:c(`prism-area-fill`),x1:0,x2:0,y1:0,y2:1}),a.append(e(`stop`,{class:`prism-area-stop-top`,offset:0}),e(`stop`,{class:`prism-area-stop-bottom`,offset:1})),t.appendChild(a),n.insertBefore(t,n.firstChild)}for(let e of a.querySelectorAll(`stop`))e.setAttribute(`stop-color`,i.color),e.style.stopColor=i.color;t(r,{fill:`url(#${a.id})`})}else a?.parentElement?.remove(),t(r,{fill:i.color});t(r,{class:`prism-area-fill prism-area-fill--${i.fill}`,stroke:`none`}),r.style.fillOpacity=i.fillOpacity===void 0?``:String(i.fillOpacity)}function renderArea(c,u,d,f){let h=r(f.transition,0),g=h.duration,_=n(h.easing),v=c.querySelector(`.prism-area-fill`);v||(v=e(`path`,{class:`prism-area-fill`}),c.appendChild(v)),applyAreaFill(c,v,f);let y=null,b=[],x=[],S=s(f.marks),C=f.marks??[];if(f.showLine){if(S){b=o(C,u.length);let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(b.length))e.remove();x=b.map((t,r)=>{let i=n[r];if(i)return i;let a=e(`path`,{class:`prism-area-line`,fill:`none`});return c.appendChild(a),a});for(let[e,n]of b.entries())t(x[e],{opacity:n.opacity,stroke:f.color,"stroke-dasharray":n.dash,"stroke-width":2});y=null}else{let n=[...c.querySelectorAll(`.prism-area-line`)];for(let e of n.slice(1))e.remove();y=n[0]??null,y||(y=e(`path`,{class:`prism-area-line`,fill:`none`}),c.appendChild(y)),t(y,{opacity:void 0,stroke:f.color,"stroke-dasharray":void 0,"stroke-width":2})}}else for(let e of c.querySelectorAll(`.prism-area-line`))e.remove();let drawLine=e=>{if(f.showLine){if(S)for(let[n,r]of b.entries())t(x[n],{d:buildLinePath(e.slice(r.start,r.end+1),f.curve)});else y&&t(y,{d:buildLinePath(e,f.curve)})}};if(g===0){let e=u.map(e=>({x:e.x,y:d}));t(v,{d:l(u,e,f.curve)}),drawLine(u);return}if(p.get(c)?.(),!v.hasAttribute(`d`)){let e=u.map(e=>({x:e.x,y:d}));t(v,{d:l(u,e,f.curve)}),drawLine(u),m.set(c,u);return}let w=m.get(c)??u,T=u.map((e,t)=>w[t]??w[w.length-1]??u[t]);m.set(c,T),p.set(c,a({count:1,duration:g,easing:_,onComplete:()=>{p.delete(c),m.set(c,u)},onFrame:e=>{let n=e(0),r=u.map((e,t)=>({x:i(T[t].x,e.x,n),y:i(T[t].y,e.y,n)})),a=r.map(e=>({x:e.x,y:d}));t(v,{d:l(r,a,f.curve)}),drawLine(r)},signal:f.disposalSignal}))}function computeAreaPoints(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}export{computeAreaPoints,renderArea};
2
2
  //# sourceMappingURL=area-renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"area-renderer.js","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":"oeAyBA,IAAM,EAAuB,IAAI,QAC3B,EAAiB,IAAI,QAE3B,SAAS,cAAc,EAAc,EAA2C,CAC9E,OAAO,IAAU,WAAa,EAAa,CAAG,EAAI,IAAU,OAAS,EAAS,CAAG,EAAI,EAAS,CAAG,CACnG,CAGA,SAAS,cAAc,EAAqB,EAAsB,EAAkC,CAClG,IAAI,EAAW,EAAO,cAAwC,gBAAgB,EAE9E,GAAI,EAAQ,OAAS,WAAY,CAC/B,GAAI,CAAC,EAA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,EAAI,EAAG,CACT,IAAM,EAAK,sBAAsB,KAAK,EAEtC,EAAqB,IAAI,MAAc,qBAAqB,CAAE,CAAC,CACjE,MACE,EAAqB,OAAO,CAAM,EAClC,EAAe,IAAI,EAAQ,CAAM,CAErC,CAEA,EAAe,IAAI,EAAQ,CAAU,EAErC,IAAM,EAAK,sBAAsB,KAAK,EAEtC,EAAqB,IAAI,MAAc,qBAAqB,CAAE,CAAC,CACjE,CAEA,SAAgB,kBACd,EACA,EACA,EACS,CAST,OARI,EAAK,KAAM,GAAM,EAAE,KAAO,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
1
+ {"version":3,"file":"area-renderer.js","names":[],"sources":["../../../src/charts/area/area-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { startTween } from '../../animation/transition';\nimport { tweenNumber } from '../../animation/tween';\nimport { computeStyleRuns, type DatumMark, hasStyledRuns, type StyleRun } from '../../core/datum-style';\nimport { uniqueId } from '../../core/ids';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { areaPath, linePath, monotonePath, stepPath } from '../../svg/path';\nimport type { ContinuousDatum, Scale, TransitionConfig } from '../../types';\n\nexport interface AreaRenderOptions {\n color: string;\n curve: 'linear' | 'monotone' | 'step';\n /** Aborted when the owning chart is disposed: stops the transition's `requestAnimationFrame` loop from rescheduling. */\n disposalSignal?: AbortSignal;\n fill: 'gradient' | 'solid';\n /** Explicit opacity beats the `--prism-area-opacity` theme token. */\n fillOpacity?: number;\n /** Per-datum presentation parallel to `points`; styled runs split the top line into subpaths. */\n marks?: readonly DatumMark[];\n showLine: boolean;\n transition?: TransitionConfig;\n}\n\nconst activeAreaAnimations = new WeakMap<SVGGElement, () => void>();\nconst previousPoints = new WeakMap<SVGGElement, Point[]>();\n\nfunction buildLinePath(pts: Point[], curve: AreaRenderOptions['curve']): string {\n return curve === 'monotone' ? monotonePath(pts) : curve === 'step' ? stepPath(pts) : linePath(pts);\n}\n\n/** A vertical gradient fading to transparent at the baseline, or a flat fill. */\nfunction applyAreaFill(parent: SVGGElement, fill: SVGPathElement, options: AreaRenderOptions): void {\n let gradient = parent.querySelector<SVGLinearGradientElement>('linearGradient');\n\n if (options.fill === 'gradient') {\n if (!gradient) {\n const defs = createSvgElement('defs');\n\n gradient = createSvgElement('linearGradient', { id: uniqueId('prism-area-fill'), x1: 0, x2: 0, y1: 0, y2: 1 });\n gradient.append(\n createSvgElement('stop', { class: 'prism-area-stop-top', offset: 0 }),\n createSvgElement('stop', { class: 'prism-area-stop-bottom', offset: 1 }),\n );\n defs.appendChild(gradient);\n parent.insertBefore(defs, parent.firstChild);\n }\n\n for (const stop of gradient.querySelectorAll('stop')) {\n stop.setAttribute('stop-color', options.color);\n stop.style.stopColor = options.color;\n }\n\n setAttributes(fill, { fill: `url(#${gradient.id})` });\n } else {\n gradient?.parentElement?.remove();\n setAttributes(fill, { fill: options.color });\n }\n\n setAttributes(fill, { class: `prism-area-fill prism-area-fill--${options.fill}`, stroke: 'none' });\n fill.style.fillOpacity = options.fillOpacity === undefined ? '' : String(options.fillOpacity);\n}\n\nexport function renderArea(parent: SVGGElement, points: Point[], baselineY: number, options: AreaRenderOptions): void {\n const motion = resolveMotion(options.transition, 0);\n const dur = motion.duration;\n const easing = resolveEasing(motion.easing);\n\n let fill = parent.querySelector<SVGPathElement>('.prism-area-fill');\n\n if (!fill) {\n fill = createSvgElement('path', { class: 'prism-area-fill' });\n parent.appendChild(fill);\n }\n\n applyAreaFill(parent, fill, options);\n\n let line: SVGPathElement | null = null;\n let runs: readonly StyleRun[] = [];\n let lines: SVGPathElement[] = [];\n const styled = hasStyledRuns(options.marks);\n const marks = options.marks ?? [];\n\n if (options.showLine) {\n if (styled) {\n runs = computeStyleRuns(marks, points.length);\n\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const extra of existing.slice(runs.length)) extra.remove();\n\n lines = runs.map((_, r) => {\n const reuse = existing[r];\n\n if (reuse) return reuse;\n\n const created = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n\n parent.appendChild(created);\n\n return created;\n });\n\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], {\n opacity: run.opacity,\n stroke: options.color,\n 'stroke-dasharray': run.dash,\n 'stroke-width': 2,\n });\n }\n\n line = null;\n } else {\n const existing = [...parent.querySelectorAll<SVGPathElement>('.prism-area-line')];\n\n for (const stale of existing.slice(1)) stale.remove();\n\n line = existing[0] ?? null;\n\n if (!line) {\n line = createSvgElement('path', { class: 'prism-area-line', fill: 'none' });\n parent.appendChild(line);\n }\n\n setAttributes(line, {\n opacity: undefined,\n stroke: options.color,\n 'stroke-dasharray': undefined,\n 'stroke-width': 2,\n });\n }\n } else {\n for (const stale of parent.querySelectorAll('.prism-area-line')) stale.remove();\n }\n\n const drawLine = (pts: Point[]): void => {\n if (!options.showLine) return;\n\n if (styled) {\n for (const [r, run] of runs.entries()) {\n setAttributes(lines[r], { d: buildLinePath(pts.slice(run.start, run.end + 1), options.curve) });\n }\n } else if (line) {\n setAttributes(line, { d: buildLinePath(pts, options.curve) });\n }\n };\n\n if (dur === 0) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n return;\n }\n\n activeAreaAnimations.get(parent)?.();\n\n const hasExisting = fill.hasAttribute('d');\n\n if (!hasExisting) {\n const bottomPoints = points.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill, { d: areaPath(points, bottomPoints, options.curve) });\n\n drawLine(points);\n\n previousPoints.set(parent, points);\n\n return;\n }\n\n const rawFrom = previousPoints.get(parent) ?? points;\n const fromPoints: Point[] = points.map((_, i) => rawFrom[i] ?? rawFrom[rawFrom.length - 1] ?? points[i]);\n\n previousPoints.set(parent, fromPoints);\n\n activeAreaAnimations.set(\n parent,\n startTween({\n count: 1,\n duration: dur,\n easing,\n onComplete: () => {\n activeAreaAnimations.delete(parent);\n previousPoints.set(parent, points);\n },\n onFrame: (progress) => {\n const e = progress(0);\n const interpolated: Point[] = points.map((to, i) => ({\n x: tweenNumber(fromPoints[i].x, to.x, e),\n y: tweenNumber(fromPoints[i].y, to.y, e),\n }));\n const interpolatedBottom = interpolated.map((p) => ({ x: p.x, y: baselineY }));\n\n setAttributes(fill!, { d: areaPath(interpolated, interpolatedBottom, options.curve) });\n drawLine(interpolated);\n },\n signal: options.disposalSignal,\n }),\n );\n}\n\nexport function computeAreaPoints(\n data: ContinuousDatum[],\n xScale: Scale<Date | number>,\n yScale: Scale<number>,\n): Point[] {\n if (data.some((d) => d.key == null)) {\n warn(\n 'computeAreaPoints: datum.key is null or undefined: data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n } else if (data.some((d) => typeof d.key === 'string')) {\n warn('computeAreaPoints: string keys are not supported for line/area charts: use numeric or Date keys.');\n }\n\n return data.map((d) => ({\n x: xScale.map(d.key as Date | number),\n y: yScale.map(d.value),\n }));\n}\n"],"mappings":"+hBA0BA,IAAM,EAAuB,IAAI,QAC3B,EAAiB,IAAI,QAE3B,SAAS,cAAc,EAAc,EAA2C,CAC9E,OAAO,IAAU,WAAa,EAAa,CAAG,EAAI,IAAU,OAAS,EAAS,CAAG,EAAI,EAAS,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,EAAiB,MAAM,EAEpC,EAAW,EAAiB,iBAAkB,CAAE,GAAI,EAAS,iBAAiB,EAAG,GAAI,EA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O,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
@@ -1,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("./line-renderer.cjs");function createLineChart(d,f){let p=null,m=null,h=null,g=f.series;return a.createChartScaffold(d,f,d=>{let{groups:_,legend:v,tooltip:y}=d,b=d.dimensions,x=g.some(e=>e.yAxis===`right`),S=g.some(e=>e.yAxis!==`right`&&e.data.length>0);b.margin.right=f.margin?.right??(x?f.rightYAxis?.label?72:50:i.resolveMargin(f.margin).right);let C=i.chartArea(b.width,b.height,b.margin),w=g.map(e=>e.data),T=w.flat().map(e=>e.key),E=g.filter(e=>e.yAxis!==`right`).flatMap(e=>e.data.map(e=>e.value)),D=g.filter(e=>e.yAxis===`right`).flatMap(e=>e.data.map(e=>e.value));if(T.length===0){a.clearCartesianDom(_,v,y,p),m?.replaceChildren(),h?.replaceChildren();return}f.crosshair&&!p&&(p=s.createCrosshair(d.chartArea,f.crosshair));let O=r.buildXScale(T,C.width),k=r.buildYScale(E,C.height),A=r.buildYScale(D,C.height);if(f.yAxis?.grid&&(!x||S)?n.renderGrid(_.grid,k,f.yAxis.grid,C.width,`horizontal`,t.resolveTickCount(f.yAxis,C.height,`left`)):_.grid.replaceChildren(),f.xAxis?.grid&&n.renderGrid(_.grid,O,f.xAxis.grid,C.height,`vertical`,t.resolveTickCount(f.xAxis,C.width,`bottom`)),f.xAxis&&(t.positionAxis(_.xAxis,f.xAxis.position??`bottom`,C.width,C.height),t.renderAxis(_.xAxis,O,f.xAxis,C.width,`bottom`)),f.yAxis&&(!x||S)){let e={...f.yAxis,position:x?`left`:f.yAxis.position??`left`};t.positionAxis(_.yAxis,e.position,C.width,C.height),t.renderAxis(_.yAxis,k,e,C.height,`left`)}else _.yAxis.replaceChildren();if(x){h||(h=e.createSvgElement(`g`,{class:`prism-y-axis-right`}),d.chartArea.appendChild(h));let n={...f.rightYAxis,position:`right`};t.positionAxis(h,`right`,C.width,C.height),t.renderAxis(h,A,n,C.height,`right`)}else h?.replaceChildren();for(;_.series.children.length>g.length;)_.series.removeChild(_.series.lastChild);let j=[];for(let t=0;t<g.length;t++){let n=g[t],r=_.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-line-series`}),_.series.appendChild(r)),r.setAttribute(`data-series-id`,o.seriesDomId(n,t));let i=u.computePoints(w[t],O,n.yAxis===`right`?A:k);j.push(i),u.renderLine(r,i,{color:l.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:d.disposalSignal,marks:n.data,pointRadius:n.pointRadius??3,showPoints:n.showPoints??!1,strokeWidth:n.strokeWidth,transition:f.transition})}return v?.update(g.map((e,t)=>({color:l.seriesColor(t,e.color),name:e.name}))),y?.hide(),m=c.ensureMarkerGroup(d.chartArea,m),c.createSeriesInteraction({announcer:d.announcer,colors:()=>g.map((e,t)=>l.seriesColor(t,e.color)),crosshair:p,dims:()=>d.dimensions,getData:()=>w,getPoints:()=>j,getSeriesList:()=>g,markers:m,onClick:f.onClick,onHover:f.onHover,seriesGroup:_.series,svg:d.svg,tooltip:y})},e=>{g=e})}exports.createLineChart=createLineChart;
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("./line-renderer.cjs");function createLineChart(d,f){let p=null,m=null,h=null,g=f.series;return a.createChartScaffold(d,f,d=>{let{groups:_,legend:v,tooltip:y}=d,b=d.dimensions,x=g.some(e=>e.yAxis===`right`),S=g.some(e=>e.yAxis!==`right`&&e.data.length>0),C={...i.resolveMargin(f.margin),right:f.margin?.right??(x?f.rightYAxis?.label?72:50:i.resolveMargin(f.margin).right)},w=i.chartArea(b.width,b.height,C),T=g.map(e=>e.data),E=T.flat().map(e=>e.key),D=g.filter(e=>e.yAxis!==`right`).flatMap(e=>e.data.map(e=>e.value)),O=g.filter(e=>e.yAxis===`right`).flatMap(e=>e.data.map(e=>e.value));if(E.length===0){a.clearCartesianDom(_,v,y,p),m?.replaceChildren(),h?.replaceChildren();return}f.crosshair&&!p&&(p=s.createCrosshair(d.chartArea,f.crosshair));let k=r.buildXScale(E,w.width),A=r.buildYScale(D,w.height),j=r.buildYScale(O,w.height);if(f.yAxis?.grid&&(!x||S)?n.renderGrid(_.grid,A,f.yAxis.grid,w.width,`horizontal`,t.resolveTickCount(f.yAxis,w.height,`left`)):_.grid.replaceChildren(),f.xAxis?.grid&&n.renderGrid(_.grid,k,f.xAxis.grid,w.height,`vertical`,t.resolveTickCount(f.xAxis,w.width,`bottom`)),f.xAxis&&(t.positionAxis(_.xAxis,f.xAxis.position??`bottom`,w.width,w.height),t.renderAxis(_.xAxis,k,f.xAxis,w.width,`bottom`)),f.yAxis&&(!x||S)){let e={...f.yAxis,position:x?`left`:f.yAxis.position??`left`};t.positionAxis(_.yAxis,e.position,w.width,w.height),t.renderAxis(_.yAxis,A,e,w.height,`left`)}else _.yAxis.replaceChildren();if(x){h||(h=e.createSvgElement(`g`,{class:`prism-y-axis-right`}),d.chartArea.appendChild(h));let n={...f.rightYAxis,position:`right`};t.positionAxis(h,`right`,w.width,w.height),t.renderAxis(h,j,n,w.height,`right`)}else h?.replaceChildren();for(;_.series.children.length>g.length;)_.series.removeChild(_.series.lastChild);let M=[];for(let t=0;t<g.length;t++){let n=g[t],r=_.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-line-series`}),_.series.appendChild(r)),r.setAttribute(`data-series-id`,o.seriesDomId(n,t));let i=u.computePoints(T[t],k,n.yAxis===`right`?j:A);M.push(i),u.renderLine(r,i,{color:l.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:d.disposalSignal,marks:n.data,pointRadius:n.pointRadius??3,showPoints:n.showPoints??!1,strokeWidth:n.strokeWidth,transition:f.transition})}return v?.update(g.map((e,t)=>({color:l.seriesColor(t,e.color),name:e.name}))),y?.hide(),m=c.ensureMarkerGroup(d.chartArea,m),c.createSeriesInteraction({announcer:d.announcer,colors:()=>g.map((e,t)=>l.seriesColor(t,e.color)),crosshair:p,dims:()=>d.dimensions,getData:()=>T,getPoints:()=>M,getSeriesList:()=>g,margin:C,markers:m,onClick:f.onClick,onHover:f.onHover,seriesGroup:_.series,svg:d.svg,tooltip:y})},e=>{g=e})}exports.createLineChart=createLineChart;
2
2
  //# sourceMappingURL=line-chart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"line-chart.cjs","names":[],"sources":["../../../src/charts/line/line-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, resolveMargin } 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 { ChartHandle, LineChartConfig, LineSeriesConfig } from '../../types';\nimport { computePoints, renderLine } from './line-renderer';\n\nexport function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle<LineSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let rightAxis: 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 hasRight = seriesList.some((series) => series.yAxis === 'right');\n const hasLeftData = seriesList.some((series) => series.yAxis !== 'right' && series.data.length > 0);\n dims.margin.right =\n config.margin?.right ?? (hasRight ? (config.rightYAxis?.label ? 72 : 50) : resolveMargin(config.margin).right);\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 leftY = seriesList\n .filter((series) => series.yAxis !== 'right')\n .flatMap((series) => series.data.map((datum) => datum.value));\n const rightY = seriesList\n .filter((series) => series.yAxis === 'right')\n .flatMap((series) => series.data.map((datum) => datum.value));\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n rightAxis?.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(leftY, area.height);\n const rightYScale = buildYScale(rightY, area.height);\n\n if (config.yAxis?.grid && (!hasRight || hasLeftData)) {\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 } else {\n groups.grid.replaceChildren();\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 && (!hasRight || hasLeftData)) {\n const axis = { ...config.yAxis, position: hasRight ? ('left' as const) : (config.yAxis.position ?? 'left') };\n positionAxis(groups.yAxis, axis.position, area.width, area.height);\n renderAxis(groups.yAxis, yScale, axis, area.height, 'left');\n } else {\n groups.yAxis.replaceChildren();\n }\n\n if (hasRight) {\n if (!rightAxis) {\n rightAxis = createSvgElement('g', { class: 'prism-y-axis-right' });\n ctx.chartArea.appendChild(rightAxis);\n }\n const axis = { ...config.rightYAxis, position: 'right' as const };\n positionAxis(rightAxis, 'right', area.width, area.height);\n renderAxis(rightAxis, rightYScale, axis, area.height, 'right');\n } else {\n rightAxis?.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-line-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computePoints(allData[i], xScale, series.yAxis === 'right' ? rightYScale : yScale);\n\n allPoints.push(points);\n\n renderLine(group, points, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n marks: series.data,\n pointRadius: series.pointRadius ?? 3,\n showPoints: series.showPoints ?? false,\n strokeWidth: series.strokeWidth,\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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EAAS,EAAW,GACtB,EAAQ,EAAO,OAAO,SAAS,GAE9B,IACH,EAAQ,EAAA,iBAAiB,IAAK,CAAE,MAAO,mBAAoB,CAAC,EAC5D,EAAO,OAAO,YAAY,CAAK,GAGjC,EAAM,aAAa,iBAAkB,EAAA,YAAY,EAAQ,CAAC,CAAC,EAE3D,IAAM,EAAS,EAAA,cAAc,EAAQ,GAAI,EAAQ,EAAO,QAAU,QAAU,EAAc,CAAM,EAEhG,EAAU,KAAK,CAAM,EAErB,EAAA,WAAW,EAAO,EAAQ,CACxB,MAAO,EAAA,YAAY,EAAG,EAAO,KAAK,EAClC,MAAO,EAAO,OAAS,SACvB,eAAgB,EAAI,eACpB,MAAO,EAAO,KACd,YAAa,EAAO,aAAe,EACnC,WAAY,EAAO,YAAc,GACjC,YAAa,EAAO,YACpB,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":"line-chart.cjs","names":[],"sources":["../../../src/charts/line/line-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, resolveMargin } 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 { ChartHandle, LineChartConfig, LineSeriesConfig } from '../../types';\nimport { computePoints, renderLine } from './line-renderer';\n\nexport function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle<LineSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let markers: SVGGElement | null = null;\n let rightAxis: 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 hasRight = seriesList.some((series) => series.yAxis === 'right');\n const hasLeftData = seriesList.some((series) => series.yAxis !== 'right' && series.data.length > 0);\n // The right axis widens the right margin; the effective margin stays local to this\n // render pass (and is handed to the interaction layer) instead of mutating shared dims.\n const margin = {\n ...resolveMargin(config.margin),\n right:\n config.margin?.right ??\n (hasRight ? (config.rightYAxis?.label ? 72 : 50) : resolveMargin(config.margin).right),\n };\n const area = chartArea(dims.width, dims.height, margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const leftY = seriesList\n .filter((series) => series.yAxis !== 'right')\n .flatMap((series) => series.data.map((datum) => datum.value));\n const rightY = seriesList\n .filter((series) => series.yAxis === 'right')\n .flatMap((series) => series.data.map((datum) => datum.value));\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n markers?.replaceChildren();\n rightAxis?.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(leftY, area.height);\n const rightYScale = buildYScale(rightY, area.height);\n\n if (config.yAxis?.grid && (!hasRight || hasLeftData)) {\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 } else {\n groups.grid.replaceChildren();\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 && (!hasRight || hasLeftData)) {\n const axis = { ...config.yAxis, position: hasRight ? ('left' as const) : (config.yAxis.position ?? 'left') };\n positionAxis(groups.yAxis, axis.position, area.width, area.height);\n renderAxis(groups.yAxis, yScale, axis, area.height, 'left');\n } else {\n groups.yAxis.replaceChildren();\n }\n\n if (hasRight) {\n if (!rightAxis) {\n rightAxis = createSvgElement('g', { class: 'prism-y-axis-right' });\n ctx.chartArea.appendChild(rightAxis);\n }\n const axis = { ...config.rightYAxis, position: 'right' as const };\n positionAxis(rightAxis, 'right', area.width, area.height);\n renderAxis(rightAxis, rightYScale, axis, area.height, 'right');\n } else {\n rightAxis?.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-line-series' });\n groups.series.appendChild(group);\n }\n\n group.setAttribute('data-series-id', seriesDomId(series, i));\n\n const points = computePoints(allData[i], xScale, series.yAxis === 'right' ? rightYScale : yScale);\n\n allPoints.push(points);\n\n renderLine(group, points, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n marks: series.data,\n pointRadius: series.pointRadius ?? 3,\n showPoints: series.showPoints ?? false,\n strokeWidth: series.strokeWidth,\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,\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,EAAgC,KAChC,EAAa,EAAO,OAExB,OAAO,EAAA,oBACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAW,EAAW,KAAM,GAAW,EAAO,QAAU,OAAO,EAC/D,EAAc,EAAW,KAAM,GAAW,EAAO,QAAU,SAAW,EAAO,KAAK,OAAS,CAAC,EAG5F,EAAS,CACb,GAAG,EAAA,cAAc,EAAO,MAAM,EAC9B,MACE,EAAO,QAAQ,QACd,EAAY,EAAO,YAAY,MAAQ,GAAK,GAAM,EAAA,cAAc,EAAO,MAAM,CAAC,CAAC,MACpF,EACM,EAAO,EAAA,UAAU,EAAK,MAAO,EAAK,OAAQ,CAAM,EAChD,EAAU,EAAW,IAAK,GAAW,EAAO,IAAI,EAChD,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAU,EAAM,GAAG,EAC9C,EAAQ,EACX,OAAQ,GAAW,EAAO,QAAU,OAAO,CAAC,CAC5C,QAAS,GAAW,EAAO,KAAK,IAAK,GAAU,EAAM,K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