minerva-design 1.13.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/custom-elements.json +194 -12
  3. package/dist/angular/fesm2022/minerva-angular.mjs +20 -0
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +10 -1
  6. package/dist/charts/canvas.d.cts +1 -0
  7. package/dist/charts/canvas.d.ts +1 -0
  8. package/dist/charts/engine/canvas.cjs +1 -1
  9. package/dist/charts/engine/canvas.cjs.map +1 -1
  10. package/dist/charts/engine/canvas.js +152 -128
  11. package/dist/charts/engine/canvas.js.map +1 -1
  12. package/dist/charts/engine/chart.cjs +1 -1
  13. package/dist/charts/engine/chart.cjs.map +1 -1
  14. package/dist/charts/engine/chart.js +475 -405
  15. package/dist/charts/engine/chart.js.map +1 -1
  16. package/dist/charts/engine/controller.cjs +2 -2
  17. package/dist/charts/engine/controller.cjs.map +1 -1
  18. package/dist/charts/engine/controller.js +263 -248
  19. package/dist/charts/engine/controller.js.map +1 -1
  20. package/dist/charts/engine/dom.cjs +1 -1
  21. package/dist/charts/engine/dom.cjs.map +1 -1
  22. package/dist/charts/engine/dom.d.cts +34 -0
  23. package/dist/charts/engine/dom.d.ts +34 -0
  24. package/dist/charts/engine/dom.js +62 -51
  25. package/dist/charts/engine/dom.js.map +1 -1
  26. package/dist/charts/engine/graph/chart.cjs +1 -1
  27. package/dist/charts/engine/graph/chart.cjs.map +1 -1
  28. package/dist/charts/engine/graph/chart.js +835 -821
  29. package/dist/charts/engine/graph/chart.js.map +1 -1
  30. package/dist/charts/engine/graph/dom.cjs +1 -1
  31. package/dist/charts/engine/graph/dom.cjs.map +1 -1
  32. package/dist/charts/engine/graph/dom.js +44 -51
  33. package/dist/charts/engine/graph/dom.js.map +1 -1
  34. package/dist/charts/engine/hover-rect.cjs +2 -0
  35. package/dist/charts/engine/hover-rect.cjs.map +1 -0
  36. package/dist/charts/engine/hover-rect.d.cts +10 -0
  37. package/dist/charts/engine/hover-rect.d.ts +10 -0
  38. package/dist/charts/engine/hover-rect.js +47 -0
  39. package/dist/charts/engine/hover-rect.js.map +1 -0
  40. package/dist/charts/engine/items.cjs +1 -1
  41. package/dist/charts/engine/items.cjs.map +1 -1
  42. package/dist/charts/engine/items.js +8 -8
  43. package/dist/charts/engine/model.cjs +1 -1
  44. package/dist/charts/engine/model.cjs.map +1 -1
  45. package/dist/charts/engine/model.js +191 -191
  46. package/dist/charts/engine/model.js.map +1 -1
  47. package/dist/charts/engine/orderbook/depth.cjs +1 -1
  48. package/dist/charts/engine/orderbook/depth.cjs.map +1 -1
  49. package/dist/charts/engine/orderbook/depth.js +63 -63
  50. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  51. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  52. package/dist/charts/engine/orderbook/heatmap.js +155 -155
  53. package/dist/charts/engine/orderbook/host.cjs +1 -1
  54. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  55. package/dist/charts/engine/orderbook/host.js +87 -75
  56. package/dist/charts/engine/orderbook/host.js.map +1 -1
  57. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  58. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  59. package/dist/charts/engine/orderbook/ladder.js +41 -41
  60. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  61. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  62. package/dist/charts/engine/orderbook/tape.js +31 -31
  63. package/dist/charts/engine/presets.cjs +2 -2
  64. package/dist/charts/engine/presets.cjs.map +1 -1
  65. package/dist/charts/engine/presets.js +15 -15
  66. package/dist/charts/engine/renderers/vector-gpu.cjs +24 -0
  67. package/dist/charts/engine/renderers/vector-gpu.cjs.map +1 -0
  68. package/dist/charts/engine/renderers/vector-gpu.d.cts +22 -0
  69. package/dist/charts/engine/renderers/vector-gpu.d.ts +22 -0
  70. package/dist/charts/engine/renderers/vector-gpu.js +301 -0
  71. package/dist/charts/engine/renderers/vector-gpu.js.map +1 -0
  72. package/dist/charts/engine/renderers/vector.cjs +2 -0
  73. package/dist/charts/engine/renderers/vector.cjs.map +1 -0
  74. package/dist/charts/engine/renderers/vector.d.cts +140 -0
  75. package/dist/charts/engine/renderers/vector.d.ts +140 -0
  76. package/dist/charts/engine/renderers/vector.js +568 -0
  77. package/dist/charts/engine/renderers/vector.js.map +1 -0
  78. package/dist/charts/engine/scene.cjs +1 -1
  79. package/dist/charts/engine/scene.cjs.map +1 -1
  80. package/dist/charts/engine/scene.d.cts +43 -3
  81. package/dist/charts/engine/scene.d.ts +43 -3
  82. package/dist/charts/engine/scene.js +411 -338
  83. package/dist/charts/engine/scene.js.map +1 -1
  84. package/dist/charts/engine/shapes/bullet.cjs +1 -1
  85. package/dist/charts/engine/shapes/bullet.cjs.map +1 -1
  86. package/dist/charts/engine/shapes/bullet.js +36 -36
  87. package/dist/charts/engine/shapes/calendar.cjs +1 -1
  88. package/dist/charts/engine/shapes/calendar.cjs.map +1 -1
  89. package/dist/charts/engine/shapes/calendar.js +53 -53
  90. package/dist/charts/engine/shapes/chart.cjs +1 -1
  91. package/dist/charts/engine/shapes/chart.cjs.map +1 -1
  92. package/dist/charts/engine/shapes/chart.d.cts +3 -2
  93. package/dist/charts/engine/shapes/chart.d.ts +3 -2
  94. package/dist/charts/engine/shapes/chart.js +192 -162
  95. package/dist/charts/engine/shapes/chart.js.map +1 -1
  96. package/dist/charts/engine/shapes/draw.cjs +1 -1
  97. package/dist/charts/engine/shapes/draw.cjs.map +1 -1
  98. package/dist/charts/engine/shapes/draw.js +87 -86
  99. package/dist/charts/engine/shapes/draw.js.map +1 -1
  100. package/dist/charts/engine/shapes/layout.cjs +2 -2
  101. package/dist/charts/engine/shapes/layout.cjs.map +1 -1
  102. package/dist/charts/engine/shapes/layout.d.cts +8 -7
  103. package/dist/charts/engine/shapes/layout.d.ts +8 -7
  104. package/dist/charts/engine/shapes/layout.js +262 -166
  105. package/dist/charts/engine/shapes/layout.js.map +1 -1
  106. package/dist/charts/engine/shapes/types.d.cts +13 -1
  107. package/dist/charts/engine/shapes/types.d.ts +13 -1
  108. package/dist/charts/engine/three-d/chart.cjs +1 -1
  109. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  110. package/dist/charts/engine/three-d/chart.js +266 -257
  111. package/dist/charts/engine/three-d/chart.js.map +1 -1
  112. package/dist/charts/engine/three-d/dom.cjs +1 -1
  113. package/dist/charts/engine/three-d/dom.cjs.map +1 -1
  114. package/dist/charts/engine/three-d/dom.js +28 -35
  115. package/dist/charts/engine/three-d/dom.js.map +1 -1
  116. package/dist/charts/engine/three-d/geometry.cjs +1 -1
  117. package/dist/charts/engine/three-d/geometry.cjs.map +1 -1
  118. package/dist/charts/engine/three-d/geometry.js +70 -70
  119. package/dist/charts/engine/three-d/overlay.cjs +1 -1
  120. package/dist/charts/engine/three-d/overlay.cjs.map +1 -1
  121. package/dist/charts/engine/three-d/overlay.js +15 -15
  122. package/dist/charts/engine/tooltip.cjs +2 -0
  123. package/dist/charts/engine/tooltip.cjs.map +1 -0
  124. package/dist/charts/engine/tooltip.d.cts +94 -0
  125. package/dist/charts/engine/tooltip.d.ts +94 -0
  126. package/dist/charts/engine/tooltip.js +242 -0
  127. package/dist/charts/engine/tooltip.js.map +1 -0
  128. package/dist/charts/engine/trading/chart.cjs +1 -1
  129. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  130. package/dist/charts/engine/trading/chart.js +135 -135
  131. package/dist/charts/react/shapes.cjs +1 -1
  132. package/dist/charts/react/shapes.cjs.map +1 -1
  133. package/dist/charts/react/shapes.d.cts +10 -1
  134. package/dist/charts/react/shapes.d.ts +10 -1
  135. package/dist/charts/react/shapes.js +24 -19
  136. package/dist/charts/react/shapes.js.map +1 -1
  137. package/dist/core/contracts.cjs +1 -1
  138. package/dist/core/contracts.cjs.map +1 -1
  139. package/dist/core/contracts.js +1 -1
  140. package/dist/core/contracts.js.map +1 -1
  141. package/dist/native/charts/src/canvas.cjs +1 -1
  142. package/dist/native/charts/src/canvas.js +8 -7
  143. package/dist/native/charts/src/engine/canvas.cjs +1 -1
  144. package/dist/native/charts/src/engine/canvas.js +2 -0
  145. package/dist/native/charts/src/engine/controller.cjs +2 -2
  146. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  147. package/dist/native/charts/src/engine/controller.js +102 -87
  148. package/dist/native/charts/src/engine/controller.js.map +1 -1
  149. package/dist/native/charts/src/engine/hover-rect.cjs +2 -0
  150. package/dist/native/charts/src/engine/hover-rect.cjs.map +1 -0
  151. package/dist/native/charts/src/engine/hover-rect.js +47 -0
  152. package/dist/native/charts/src/engine/hover-rect.js.map +1 -0
  153. package/dist/native/charts/src/engine/scene.cjs +1 -1
  154. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  155. package/dist/native/charts/src/engine/scene.js +318 -245
  156. package/dist/native/charts/src/engine/scene.js.map +1 -1
  157. package/dist/native/charts/src/engine/shapes/draw.cjs +1 -1
  158. package/dist/native/charts/src/engine/shapes/draw.cjs.map +1 -1
  159. package/dist/native/charts/src/engine/shapes/draw.js +81 -80
  160. package/dist/native/charts/src/engine/shapes/draw.js.map +1 -1
  161. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  162. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  163. package/dist/native/charts/src/engine/shapes/layout.js +239 -143
  164. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  165. package/dist/native/charts/src/engine/tooltip.cjs +2 -0
  166. package/dist/native/charts/src/engine/tooltip.cjs.map +1 -0
  167. package/dist/native/charts/src/engine/tooltip.js +164 -0
  168. package/dist/native/charts/src/engine/tooltip.js.map +1 -0
  169. package/dist/native/components/Chart/scene.cjs +1 -1
  170. package/dist/native/components/Chart/scene.cjs.map +1 -1
  171. package/dist/native/components/Chart/scene.js +210 -187
  172. package/dist/native/components/Chart/scene.js.map +1 -1
  173. package/dist/native/source/components/Chart/scene.tsx +55 -2
  174. package/dist/taro/index.js +2026 -1626
  175. package/dist/uni/charts-canvas.js +1 -0
  176. package/dist/vue/components/Chart/BulletChart.vue.d.ts +2 -0
  177. package/dist/vue/components/Chart/CalendarHeatmap.vue.d.ts +2 -0
  178. package/dist/vue/components/Chart/ChordChart.vue.d.ts +2 -0
  179. package/dist/vue/components/Chart/DonutChart.vue.d.ts +2 -0
  180. package/dist/vue/components/Chart/FunnelChart.vue.d.ts +2 -0
  181. package/dist/vue/components/Chart/GaugeChart.vue.d.ts +2 -0
  182. package/dist/vue/components/Chart/PieChart.vue.d.ts +2 -0
  183. package/dist/vue/components/Chart/RadarChart.vue.d.ts +2 -0
  184. package/dist/vue/components/Chart/RadialBarChart.vue.d.ts +2 -0
  185. package/dist/vue/components/Chart/SankeyChart.vue.d.ts +2 -0
  186. package/dist/vue/components/Chart/SunburstChart.vue.d.ts +2 -0
  187. package/dist/vue/components/Chart/TreemapChart.vue.d.ts +2 -0
  188. package/dist/vue/components/Chart/props.d.ts +2 -0
  189. package/dist/vue/components/Chart/props.js +1 -0
  190. package/dist/vue/components/Chart/props.js.map +1 -1
  191. package/dist/vue/components/Chart/shape.d.ts +2 -1
  192. package/dist/vue/components/Chart/shape.js +2 -0
  193. package/dist/vue/components/Chart/shape.js.map +1 -1
  194. package/dist/vue/components/Chart/types.d.ts +2 -0
  195. package/dist/weapp/charts/canvas.js +2576 -1969
  196. package/dist/weapp/charts/core.js +1 -0
  197. package/dist/web-components/components/chart/shape-chart.d.ts +9 -7
  198. package/dist/web-components/components/chart/shape-chart.js +3 -0
  199. package/dist/web-components/components/chart/shape-chart.js.map +1 -1
  200. package/dist/web-components/components/chart/shapes-extended.d.ts +6 -6
  201. package/dist/web-components/components/chart/shapes-extended.js.map +1 -1
  202. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":["NO_HIDDEN","NO_FOCUS","layoutShapeScene","o","input","bounds","from","t","clamp","palette","theme","locale","resolveLocale","labels","shapeLabels","c","target","start","key","localeFormat","localePercent","resolveWith","css","i","inset","result","layoutPie","layoutRadar","layoutGauge","layoutFunnel","layoutSankey","layoutSunburst","layoutRadialBar","layoutCalendar","layoutBullet","layoutChord","layoutTreemap","shapeValues","out","hidden","focus","blendValues","to","v","sameValues","a","b","w","legendConfig","config","shapeLegend","color","toCss","entries","shown","d","funnelOrder","seriesName","s","radialBarLabels","g","resolveSankey","calendarLegend","m","resolveChord","toggleCount","calendarModel","hoverEvent","hover","item","scene","it","k","ind","sameHover","tooltipContent","rows","row","describeItem","describeChart","l","interpolate","describeScene","SHAPE_LABELS","LEGEND_ROW","layoutShapeLegend","f","font","x","e","width","measure","height","top","position","chartHeight","boxes","last","offset","box","r","TIP_MARGIN","TIP_GAP","overlapArea","placeShapeTooltip","fit","y","h","ax","ay","anchor","radar","avoid","vertex","dx","dy","len","candidates","best","bestScore","cx0","cy0","p","score","px","py","label","ox","oy","dist","layoutShapeTooltip","lines","content","text","titleLines","value","line","titleFont","dot","maxTitle","wrapText","bw","bh","anchorX","anchorY"],"sources":["../../../../../charts/src/engine/shapes/layout.ts"],"sourcesContent":["// Layout of every shape chart type into a ShapeScene, plus what the hosts\n// share: animated values, legend entries, tooltip content, hover events and\n// accessible descriptions. Pure: no DOM, no canvas.\n\nimport { toCss } from \"../color\";\nimport { resolveLocale } from \"../locale\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport { bulletValues, layoutBullet } from \"./bullet\";\nimport {\n calendarLegend,\n calendarModel,\n calendarValues,\n layoutCalendar,\n} from \"./calendar\";\nimport { chordValues, layoutChord, resolveChord } from \"./chord\";\nimport { funnelOrder, funnelValues, layoutFunnel } from \"./funnel\";\nimport { gaugeValues, layoutGauge } from \"./gauge\";\nimport {\n interpolate,\n localeFormat,\n localePercent,\n SHAPE_LABELS,\n shapeLabels,\n} from \"./labels\";\nimport { layoutPie, pieValues } from \"./pie\";\nimport { layoutRadar, radarValues, seriesName } from \"./radar\";\nimport { layoutRadialBar, radialBarLabels, radialBarValues } from \"./radialBar\";\nimport { layoutSankey, resolveSankey, sankeyValues } from \"./sankey\";\nimport {\n clamp,\n inset,\n resolveWith,\n wrapText,\n type LayoutContext,\n type LayoutResult,\n type MeasureText,\n type ShapeHover,\n type ShapeLegendEntry,\n type ShapeRect,\n type ShapeScene,\n type ShapeTooltipRow,\n} from \"./scene\";\nimport { layoutSunburst, sunburstValues } from \"./sunburst\";\nimport { layoutTreemap, treemapValues } from \"./treemap\";\nimport type {\n ShapeChartOptions,\n ShapeHoverEvent,\n ShapeLegendOptions,\n} from \"./types\";\n\nexport interface ShapeLayoutInput {\n options: ShapeChartOptions;\n theme: ChartTheme;\n /** Size of the whole drawing, CSS pixels */\n width: number;\n height: number;\n /** Area of the chart (legend excluded); the whole drawing by default */\n bounds?: ShapeRect;\n measure: MeasureText;\n /** Hidden slices / stages / series (treemap: top-level nodes) */\n hidden?: ReadonlySet<number>;\n /** Entry animation progress, eased (1 = done) */\n enter?: number;\n /** Values at the start of an update animation (`shapeValues`) */\n from?: ReadonlyMap<string, number> | null;\n /** Update animation progress, eased (1 = done) */\n t?: number;\n /** Sunburst: names from the root to the focused node */\n focus?: readonly string[];\n}\n\nconst NO_HIDDEN: ReadonlySet<number> = new Set();\nconst NO_FOCUS: readonly string[] = [];\n\n/** Lays a shape chart out */\nexport const layoutShapeScene = (input: ShapeLayoutInput): ShapeScene => {\n const { options: o, theme, width, height } = input;\n const bounds = input.bounds ?? { x: 0, y: 0, width, height };\n const from = input.from ?? null;\n const t = clamp(input.t ?? 1, 0, 1);\n const palette = theme.palette.length ? theme.palette : [theme.primary];\n const locale = resolveLocale(o.locale);\n const labels = shapeLabels(o);\n const c: LayoutContext = {\n theme,\n measure: input.measure,\n hidden: input.hidden ?? NO_HIDDEN,\n enter: clamp(input.enter ?? 1, 0, 1),\n value: (key, target) => {\n if (!from || t >= 1) return target;\n const start = from.get(key) ?? 0;\n return start + (target - start) * t;\n },\n format: o.format ?? localeFormat(locale),\n percent: o.percentFormat ?? localePercent(locale),\n labels,\n locale,\n color: (css, i) => resolveWith(theme, css, palette[i % palette.length]),\n area: inset(bounds, o.padding),\n focus: input.focus ?? NO_FOCUS,\n };\n let result: LayoutResult;\n switch (o.type) {\n case \"pie\":\n result = layoutPie(o, c);\n break;\n case \"radar\":\n result = layoutRadar(o, c);\n break;\n case \"gauge\":\n result = layoutGauge(o, c);\n break;\n case \"funnel\":\n result = layoutFunnel(o, c);\n break;\n case \"sankey\":\n result = layoutSankey(o, c);\n break;\n case \"sunburst\":\n result = layoutSunburst(o, c);\n break;\n case \"radialBar\":\n result = layoutRadialBar(o, c);\n break;\n case \"calendarHeatmap\":\n result = layoutCalendar(o, c);\n break;\n case \"bullet\":\n result = layoutBullet(o, c);\n break;\n case \"chord\":\n result = layoutChord(o, c);\n break;\n default:\n result = layoutTreemap(o, c);\n break;\n }\n return { type: o.type, width, height, labels, locale, ...result };\n};\n\n/** Target values of the animated quantities, by key */\nexport const shapeValues = (\n o: ShapeChartOptions,\n hidden: ReadonlySet<number> = NO_HIDDEN,\n focus: readonly string[] = NO_FOCUS,\n): Map<string, number> => {\n const out = new Map<string, number>();\n switch (o.type) {\n case \"pie\":\n pieValues(o, hidden, out);\n break;\n case \"radar\":\n radarValues(o, hidden, out);\n break;\n case \"gauge\":\n gaugeValues(o, hidden, out);\n break;\n case \"funnel\":\n funnelValues(o, hidden, out);\n break;\n case \"sankey\":\n sankeyValues(o, hidden, out);\n break;\n case \"sunburst\":\n sunburstValues(o, hidden, focus, out);\n break;\n case \"radialBar\":\n radialBarValues(o, hidden, out);\n break;\n case \"calendarHeatmap\":\n calendarValues(o, hidden, out);\n break;\n case \"bullet\":\n bulletValues(o, hidden, out);\n break;\n case \"chord\":\n chordValues(o, hidden, out);\n break;\n default:\n treemapValues(o, hidden, out);\n break;\n }\n return out;\n};\n\n/** Values shown at progress `t` of an animation from `from` to `to` */\nexport const blendValues = (\n from: ReadonlyMap<string, number>,\n to: ReadonlyMap<string, number>,\n t: number,\n): Map<string, number> => {\n const out = new Map<string, number>();\n to.forEach((v, key) => {\n const start = from.get(key) ?? 0;\n out.set(key, start + (v - start) * t);\n });\n return out;\n};\n\nexport const sameValues = (\n a: ReadonlyMap<string, number>,\n b: ReadonlyMap<string, number>,\n) => {\n if (a.size !== b.size) return false;\n for (const [key, v] of a) {\n const w = b.get(key);\n if (w === undefined || Math.abs(w - v) > 1e-12) return false;\n }\n return true;\n};\n\n/** Legend position and toggling */\nexport const legendConfig = (\n o: ShapeChartOptions,\n): Required<ShapeLegendOptions> => {\n const config = typeof o.legend === \"object\" ? o.legend : {};\n return {\n position: config.position ?? \"bottom\",\n toggle: config.toggle ?? true,\n };\n};\n\n/** Legend entries, `null` when the legend is hidden */\nexport const shapeLegend = (\n o: ShapeChartOptions,\n theme: ChartTheme,\n hidden: ReadonlySet<number> = NO_HIDDEN,\n): ShapeLegendEntry[] | null => {\n if (o.legend === false) return null;\n const palette = theme.palette.length ? theme.palette : [theme.primary];\n const color = (css: string | undefined, i: number) =>\n toCss(resolveWith(theme, css, palette[i % palette.length]));\n let entries: ShapeLegendEntry[] = [];\n let shown = o.legend !== undefined;\n switch (o.type) {\n case \"pie\":\n shown = true;\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"funnel\":\n shown = true;\n entries = funnelOrder(o, NO_HIDDEN).map((i) => ({\n index: i,\n name: o.data[i].name,\n color: color(o.data[i].color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"radar\":\n shown ||= o.series.length > 1;\n entries = o.series.map((s, i) => ({\n index: i,\n name: seriesName(o, i, shapeLabels(o)),\n color: color(s.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"treemap\":\n case \"sunburst\":\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"radialBar\":\n shown ||= !radialBarLabels(o);\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"bullet\":\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"sankey\": {\n const g = resolveSankey(o);\n entries = g.names.map((name, i) => ({\n index: i,\n name,\n color: color(g.colors[i], i),\n hidden: hidden.has(i),\n }));\n break;\n }\n case \"calendarHeatmap\":\n shown = true;\n entries = calendarLegend(o, theme, hidden);\n break;\n case \"chord\": {\n shown = true;\n const m = resolveChord(o);\n entries = m.names.map((name, i) => ({\n index: i,\n name,\n color: color(m.colors[i], i),\n hidden: hidden.has(i),\n }));\n break;\n }\n default:\n break;\n }\n return shown && entries.length ? entries : null;\n};\n\n/**\n * Number of toggleable entries (slices, stages, series, top-level nodes,\n * sankey nodes, bars, rows, calendar levels, chord groups)\n */\nexport const toggleCount = (o: ShapeChartOptions): number => {\n switch (o.type) {\n case \"radar\":\n return o.series.length;\n case \"gauge\":\n return 0;\n case \"sankey\":\n return resolveSankey(o).names.length;\n case \"calendarHeatmap\":\n return calendarModel(o)?.count ?? 0;\n case \"chord\":\n return resolveChord(o).names.length;\n default:\n return o.data.length;\n }\n};\n\n/** Event of a hovered item */\nexport const hoverEvent = (\n scene: ShapeScene,\n hover: ShapeHover | null,\n): ShapeHoverEvent | null => {\n if (!hover) return null;\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return null;\n if (item.indicators) {\n const k = clamp(hover.indicator ?? 0, 0, item.indicators.length - 1);\n const ind = item.indicators[k];\n return {\n index: item.index,\n indicator: k,\n name: item.name,\n value: ind.value,\n percent: ind.percent,\n color: item.color,\n };\n }\n return {\n index: item.index,\n name: item.name,\n value: item.value,\n percent: item.percent,\n color: item.color,\n ...(item.path ? { path: item.path } : {}),\n ...item.event,\n };\n};\n\nexport const sameHover = (a: ShapeHover | null, b: ShapeHover | null) =>\n a === b || (!!a && !!b && a.index === b.index && a.indicator === b.indicator);\n\nexport interface ShapeTooltipContent {\n title: string;\n color?: string;\n rows: ShapeTooltipRow[];\n}\n\n/** Default tooltip of a hovered item */\nexport const tooltipContent = (\n scene: ShapeScene,\n hover: ShapeHover,\n): ShapeTooltipContent | null => {\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return null;\n const rows = item.indicators\n ? item.rows.map((row, k) =>\n k === (hover.indicator ?? -1) ? { ...row, strong: true } : row,\n )\n : item.rows;\n return {\n title: item.path ? item.path.join(\" / \") : item.name,\n color: item.color,\n rows,\n };\n};\n\n/** Text read by screen readers for a focused item */\nexport const describeItem = (scene: ShapeScene, hover: ShapeHover) => {\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return \"\";\n if (item.indicators) {\n const k = clamp(hover.indicator ?? 0, 0, item.indicators.length - 1);\n return `${item.name}, ${item.indicators[k].name}: ${item.rows[k]?.value ?? item.indicators[k].value}`;\n }\n const name = item.path ? item.path.join(\" / \") : item.name;\n return `${name}: ${item.rows[0]?.value ?? item.value} (${item.share ?? localePercent(scene.locale)(item.percent)})`;\n};\n\n/** Default accessible name of a chart (in its `locale`) */\nexport const describeChart = (o: ShapeChartOptions) => {\n const l = shapeLabels(o);\n switch (o.type) {\n case \"pie\":\n return o.rose\n ? l.roseChart\n : (o.innerRadius ?? 0) > 0\n ? l.donutChart\n : l.pieChart;\n case \"radar\":\n return l.radarChart;\n case \"gauge\":\n return o.label\n ? interpolate(l.gaugeChartNamed, { label: o.label })\n : l.gaugeChart;\n case \"funnel\":\n return l.funnelChart;\n case \"sankey\":\n return l.sankeyChart;\n case \"sunburst\":\n return l.sunburstChart;\n case \"radialBar\":\n return l.radialBarChart;\n case \"calendarHeatmap\":\n return l.calendarHeatmap;\n case \"bullet\":\n return l.bulletChart;\n case \"chord\":\n return l.chordChart;\n default:\n return l.treemapChart;\n }\n};\n\n/** Text summary of the data (screen readers) */\nexport const describeScene = (scene: ShapeScene) =>\n scene.empty\n ? (scene.labels ?? SHAPE_LABELS.en).noData\n : scene.items\n .slice(0, 12)\n .map((item) =>\n item.indicators\n ? `${item.name}: ${item.indicators\n .map(\n (ind, k) => `${ind.name} ${item.rows[k]?.value ?? ind.value}`,\n )\n .join(\", \")}`\n : describeItem(scene, { index: item.index }),\n )\n .join(\"; \");\n\n// ------------------------------------------------- canvas legend & tooltip\n\nexport interface ShapeLegendBox extends ShapeLegendEntry {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst LEGEND_ROW = 20;\n\n/** Centered legend rows drawn on a canvas; `height` includes the gap with the chart */\nexport const layoutShapeLegend = (\n entries: readonly ShapeLegendEntry[],\n width: number,\n position: \"top\" | \"bottom\",\n chartHeight: number,\n theme: ChartTheme,\n measure: MeasureText,\n): { boxes: ShapeLegendBox[]; height: number } => {\n const f = font(theme, 12);\n const gap = 14;\n const rows: ShapeLegendBox[][] = [[]];\n let x = 0;\n for (const e of entries) {\n const w = Math.min(width - 8, 16 + measure(e.name, f));\n let row = rows[rows.length - 1];\n if (row.length && x + gap + w > width - 8) {\n rows.push((row = []));\n x = 0;\n }\n if (row.length) x += gap;\n row.push({ ...e, x, y: 0, width: w, height: LEGEND_ROW });\n x += w;\n }\n const height = rows.length * LEGEND_ROW + 8;\n const top = position === \"top\" ? 2 : chartHeight - height + 6;\n const boxes: ShapeLegendBox[] = [];\n rows.forEach((row, r) => {\n const last = row[row.length - 1];\n const used = last ? last.x + last.width : 0;\n const offset = (width - used) / 2;\n for (const box of row) {\n boxes.push({ ...box, x: box.x + offset, y: top + r * LEGEND_ROW });\n }\n });\n return { boxes, height };\n};\n\nexport interface ShapeTooltipBox {\n x: number;\n y: number;\n width: number;\n height: number;\n padding: number;\n lineHeight: number;\n /** Default content */\n content?: ShapeTooltipContent;\n /** Lines of the content's title (long titles wrap) */\n titleLines?: string[];\n /** Custom text (`tooltip.render` returning a string) */\n text?: string[];\n}\n\n/** Margin between a tooltip and the edges of the drawing */\nconst TIP_MARGIN = 6;\n/** Distance between a tooltip and its anchor */\nconst TIP_GAP = 14;\n\nconst overlapArea = (a: ShapeRect, b: ShapeRect) =>\n Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x)) *\n Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));\n\n/**\n * Top-left corner of a `w` x `h` tooltip anchored at `anchor`, inside a\n * `width` x `height` drawing. Beside the anchor (right, else left) by\n * default; radar tooltips go outward, off the hovered vertex and, when\n * possible, off the indicator labels.\n */\nexport const placeShapeTooltip = (\n scene: ShapeScene | null,\n hover: ShapeHover | null,\n anchor: { x: number; y: number },\n w: number,\n h: number,\n width: number,\n height: number,\n): { x: number; y: number } => {\n const m = TIP_MARGIN;\n const fit = (x: number, y: number) => ({\n x: Math.max(m, Math.min(x, width - w - m)),\n y: Math.max(m, Math.min(y, height - h - m)),\n });\n const { x: ax, y: ay } = anchor;\n const radar = scene?.radar;\n if (!radar || !scene || !hover) {\n let x = ax + 16;\n if (x + w > width - m) x = ax - 16 - w;\n return fit(x, ay - h / 2);\n }\n\n // points the tooltip must not cover: the anchor and the hovered vertex\n const avoid: [number, number][] = [[ax, ay]];\n const item = scene.items.find((it) => it.index === hover.index);\n const vertex =\n item?.indicators && hover.indicator !== undefined\n ? item.indicators[hover.indicator]\n : undefined;\n if (vertex) avoid.push([vertex.x, vertex.y]);\n const labels = radar.labels ?? [];\n // outward direction, from the center through the anchor\n let dx = ax - radar.cx;\n let dy = ay - radar.cy;\n const len = Math.hypot(dx, dy);\n if (len > 1) {\n dx /= len;\n dy /= len;\n } else {\n dx = 1;\n dy = 0;\n }\n const g = TIP_GAP;\n const candidates: [number, number][] = [\n [ax + g, ay - h / 2],\n [ax - g - w, ay - h / 2],\n [ax - w / 2, ay - g - h],\n [ax - w / 2, ay + g],\n [ax + g, ay - g - h],\n [ax + g, ay + g],\n [ax - g - w, ay - g - h],\n [ax - g - w, ay + g],\n ];\n let best = fit(candidates[0][0], candidates[0][1]);\n let bestScore = Infinity;\n for (const [cx0, cy0] of candidates) {\n const p = fit(cx0, cy0);\n const box = { x: p.x, y: p.y, width: w, height: h };\n let score = 0;\n for (const [px, py] of avoid) {\n const covers =\n px > box.x - 8 &&\n px < box.x + w + 8 &&\n py > box.y - 8 &&\n py < box.y + h + 8;\n if (covers) score += 1e6;\n }\n for (const label of labels) score += overlapArea(box, label) * 4;\n const ox = p.x + w / 2 - ax;\n const oy = p.y + h / 2 - ay;\n const dist = Math.hypot(ox, oy) || 1;\n score += dist * 0.5;\n // prefer going outward, and candidates that fit without being pushed in\n score -= ((ox * dx + oy * dy) / dist) * 40;\n score += Math.abs(p.x - cx0) + Math.abs(p.y - cy0);\n if (score < bestScore) {\n bestScore = score;\n best = p;\n }\n }\n return best;\n};\n\n/** Box of a tooltip drawn on a canvas, next to the anchor and inside the drawing */\nexport const layoutShapeTooltip = (\n value: ShapeTooltipContent | string,\n anchorX: number,\n anchorY: number,\n width: number,\n height: number,\n theme: ChartTheme,\n measure: MeasureText,\n scene: ShapeScene | null = null,\n hover: ShapeHover | null = null,\n): ShapeTooltipBox => {\n const padding = 9;\n const lineHeight = 18;\n let w = 0;\n let lines: number;\n let content: ShapeTooltipContent | undefined;\n let text: string[] | undefined;\n let titleLines: string[] | undefined;\n if (typeof value === \"string\") {\n text = value.split(\"\\n\");\n const f = font(theme, 12);\n for (const line of text) w = Math.max(w, measure(line, f));\n lines = text.length;\n } else {\n content = value;\n // long titles (full names of truncated labels) wrap to 3 lines\n const titleFont = font(theme, 12, 600);\n const dot = value.color ? 14 : 0;\n const maxTitle = Math.max(\n 60,\n Math.min(260, width - 16 - padding * 2) - dot,\n );\n titleLines = wrapText(value.title, maxTitle, titleFont, measure, 3);\n if (!titleLines.length) titleLines = [value.title];\n for (const line of titleLines)\n w = Math.max(w, dot + measure(line, titleFont));\n for (const row of value.rows) {\n w = Math.max(\n w,\n (row.color ? 14 : 0) +\n measure(row.name, font(theme, 12)) +\n 16 +\n measure(row.value, font(theme, 12, 600)),\n );\n }\n lines = titleLines.length + value.rows.length;\n }\n const bw = Math.max(96, Math.ceil(w + padding * 2 + 4));\n const bh = lines * lineHeight + padding * 2;\n const { x, y } = placeShapeTooltip(\n scene,\n hover,\n { x: anchorX, y: anchorY },\n bw,\n bh,\n width,\n height,\n );\n return {\n x,\n y,\n width: bw,\n height: bh,\n padding,\n lineHeight,\n ...(content ? { content, titleLines } : {}),\n ...(text ? { text } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwEA,IAAMA,oBAAiC,IAAI,IAAI,GACzCC,IAA8B,CAAC,GAGxBC,KAAoB,MAAwC;CACvE,IAAM,EAAE,SAASC,GAAG,UAAO,UAAO,cAAWC,GACvCC,IAASD,EAAM,UAAU;EAAE,GAAG;EAAG,GAAG;EAAG;EAAO;CAAO,GACrDE,IAAOF,EAAM,QAAQ,MACrBG,IAAIC,EAAMJ,EAAM,KAAK,GAAG,GAAG,CAAC,GAC5BK,IAAUC,EAAM,QAAQ,SAASA,EAAM,UAAU,CAACA,EAAM,OAAO,GAC/DC,IAASC,EAAcT,EAAE,MAAM,GAC/BU,IAASC,EAAYX,CAAC,GACtBY,IAAmB;EACvB;EACA,SAASX,EAAM;EACf,QAAQA,EAAM,UAAUJ;EACxB,OAAOQ,EAAMJ,EAAM,SAAS,GAAG,GAAG,CAAC;EACnC,QAAQ,GAAK,MAAW;GACtB,IAAI,CAACE,KAAQC,KAAK,GAAG,OAAOS;GAC5B,IAAMC,IAAQX,EAAK,IAAIY,CAAG,KAAK;GAC/B,OAAOD,KAASD,IAASC,KAASV;EACpC;EACA,QAAQJ,EAAE,UAAUgB,EAAaR,CAAM;EACvC,SAASR,EAAE,iBAAiBiB,EAAcT,CAAM;EAChD;EACA;EACA,QAAQ,GAAK,MAAMU,EAAYX,GAAOY,GAAKb,EAAQc,IAAId,EAAQ,OAAO;EACtE,MAAMe,EAAMnB,GAAQF,EAAE,OAAO;EAC7B,OAAOC,EAAM,SAASH;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,GAAM,IAAI,KAAK,IAAItF,GAAG4C,EAAQ6C,GAAMlD,CAAC,CAAC;EACzD,IAAQ+C,EAAK;CACf,OAAO;EACL,IAAUE;EAEV,IAAME,IAAYlD,EAAK7E,GAAO,IAAI,GAAG,GAC/BgI,IAAMH,EAAM,QAAQ,KAAK,GACzBI,IAAW,KAAK,IACpB,IACA,KAAK,IAAI,KAAKjD,IAAQ,KAAK,EAAW,IAAIgD,CAC5C;EAEA,AADA,IAAaE,EAASL,EAAM,OAAOI,GAAUF,GAAW9C,GAAS,CAAC,GAC7D2C,EAAW,WAAQ,IAAa,CAACC,EAAM,KAAK;EACjD,KAAK,IAAMC,KAAQF,GACjB,IAAI,KAAK,IAAIvF,GAAG2F,IAAM/C,EAAQ6C,GAAMC,CAAS,CAAC;EAChD,KAAK,IAAM5D,KAAO0D,EAAM,MACtB,IAAI,KAAK,IACPxF,IACC8B,EAAI,QAAQ,KAAK,KAChBc,EAAQd,EAAI,MAAMU,EAAK7E,GAAO,EAAE,CAAC,IACjC,KACAiF,EAAQd,EAAI,OAAOU,EAAK7E,GAAO,IAAI,GAAG,CAAC,CAC3C;EAEF,IAAQ4H,EAAW,SAASC,EAAM,KAAK;CACzC;CACA,IAAMM,IAAK,KAAK,IAAI,IAAI,KAAK,KAAK9F,IAAI,KAAc,CAAC,CAAC,GAChD+F,IAAKX,IAAQ,KAAa,IAC1B,EAAE,MAAG,MAAM3B,EACflC,GACAF,GACA;EAAE,GAAG2E;EAAS,GAAGC;CAAQ,GACzBH,GACAC,GACApD,GACAE,CACF;CACA,OAAO;EACL;EACA;EACA,OAAOiD;EACP,QAAQC;EACR;EACA;EACA,GAAIV,IAAU;GAAE;GAAS;EAAW,IAAI,CAAC;EACzC,GAAIC,IAAO,EAAE,QAAK,IAAI,CAAC;CACzB;AACF"}
1
+ {"version":3,"file":"layout.js","names":["NO_HIDDEN","NO_FOCUS","layoutShapeScene","o","input","bounds","from","t","clamp","palette","theme","locale","resolveLocale","labels","shapeLabels","c","target","start","key","localeFormat","localePercent","resolveWith","css","i","inset","result","layoutPie","layoutRadar","layoutGauge","layoutFunnel","layoutSankey","layoutSunburst","layoutRadialBar","layoutCalendar","layoutBullet","layoutChord","layoutTreemap","shapeValues","out","hidden","focus","blendValues","to","v","sameValues","a","b","w","legendConfig","config","shapeLegend","color","toCss","entries","shown","d","funnelOrder","seriesName","s","radialBarLabels","g","resolveSankey","calendarLegend","m","resolveChord","toggleCount","calendarModel","hoverEvent","hover","item","scene","it","k","ind","sameHover","tooltipContent","rows","row","describeItem","describeChart","l","interpolate","describeScene","SHAPE_LABELS","LEGEND_ROW","layoutShapeLegend","f","font","x","e","width","measure","height","top","position","chartHeight","boxes","last","offset","box","r","TIP_MARGIN","TIP_GAP","TIP_POINTER","overlapArea","arcBox","xs","ys","add","r0","r1","cx","cy","a0","a1","y","itemBox","unionRect","node","index","p","x0","y0","x1","y1","half","textBox","size","estimateText","placeShapeTooltip","ax","ay","anchor","fallback","placeTooltip","h","fit","keep","vertex","texts","radar","dx","dy","len","candidates","area","best","bestScore","cx0","cy0","score","px","py","text","ox","oy","dist","layoutShapeTooltip","lines","content","titleLines","value","line","titleFont","dot","maxTitle","wrapText","bw","bh","anchorX","anchorY"],"sources":["../../../../../charts/src/engine/shapes/layout.ts"],"sourcesContent":["// Layout of every shape chart type into a ShapeScene, plus what the hosts\n// share: animated values, legend entries, tooltip content, hover events and\n// accessible descriptions. Pure: no DOM, no canvas.\n\nimport { toCss } from \"../color\";\nimport { resolveLocale } from \"../locale\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport { placeTooltip, unionRect, type TooltipPlacement } from \"../tooltip\";\nimport { bulletValues, layoutBullet } from \"./bullet\";\nimport {\n calendarLegend,\n calendarModel,\n calendarValues,\n layoutCalendar,\n} from \"./calendar\";\nimport { chordValues, layoutChord, resolveChord } from \"./chord\";\nimport { funnelOrder, funnelValues, layoutFunnel } from \"./funnel\";\nimport { gaugeValues, layoutGauge } from \"./gauge\";\nimport {\n interpolate,\n localeFormat,\n localePercent,\n SHAPE_LABELS,\n shapeLabels,\n} from \"./labels\";\nimport { layoutPie, pieValues } from \"./pie\";\nimport { layoutRadar, radarValues, seriesName } from \"./radar\";\nimport { layoutRadialBar, radialBarLabels, radialBarValues } from \"./radialBar\";\nimport { layoutSankey, resolveSankey, sankeyValues } from \"./sankey\";\nimport {\n clamp,\n estimateText,\n inset,\n resolveWith,\n wrapText,\n type LayoutContext,\n type LayoutResult,\n type MeasureText,\n type ShapeHover,\n type ShapeLegendEntry,\n type ShapeRect,\n type ShapeScene,\n type ShapeTooltipRow,\n} from \"./scene\";\nimport { layoutSunburst, sunburstValues } from \"./sunburst\";\nimport { layoutTreemap, treemapValues } from \"./treemap\";\nimport type {\n ShapeChartOptions,\n ShapeHoverEvent,\n ShapeLegendOptions,\n} from \"./types\";\n\nexport interface ShapeLayoutInput {\n options: ShapeChartOptions;\n theme: ChartTheme;\n /** Size of the whole drawing, CSS pixels */\n width: number;\n height: number;\n /** Area of the chart (legend excluded); the whole drawing by default */\n bounds?: ShapeRect;\n measure: MeasureText;\n /** Hidden slices / stages / series (treemap: top-level nodes) */\n hidden?: ReadonlySet<number>;\n /** Entry animation progress, eased (1 = done) */\n enter?: number;\n /** Values at the start of an update animation (`shapeValues`) */\n from?: ReadonlyMap<string, number> | null;\n /** Update animation progress, eased (1 = done) */\n t?: number;\n /** Sunburst: names from the root to the focused node */\n focus?: readonly string[];\n}\n\nconst NO_HIDDEN: ReadonlySet<number> = new Set();\nconst NO_FOCUS: readonly string[] = [];\n\n/** Lays a shape chart out */\nexport const layoutShapeScene = (input: ShapeLayoutInput): ShapeScene => {\n const { options: o, theme, width, height } = input;\n const bounds = input.bounds ?? { x: 0, y: 0, width, height };\n const from = input.from ?? null;\n const t = clamp(input.t ?? 1, 0, 1);\n const palette = theme.palette.length ? theme.palette : [theme.primary];\n const locale = resolveLocale(o.locale);\n const labels = shapeLabels(o);\n const c: LayoutContext = {\n theme,\n measure: input.measure,\n hidden: input.hidden ?? NO_HIDDEN,\n enter: clamp(input.enter ?? 1, 0, 1),\n value: (key, target) => {\n if (!from || t >= 1) return target;\n const start = from.get(key) ?? 0;\n return start + (target - start) * t;\n },\n format: o.format ?? localeFormat(locale),\n percent: o.percentFormat ?? localePercent(locale),\n labels,\n locale,\n color: (css, i) => resolveWith(theme, css, palette[i % palette.length]),\n area: inset(bounds, o.padding),\n focus: input.focus ?? NO_FOCUS,\n };\n let result: LayoutResult;\n switch (o.type) {\n case \"pie\":\n result = layoutPie(o, c);\n break;\n case \"radar\":\n result = layoutRadar(o, c);\n break;\n case \"gauge\":\n result = layoutGauge(o, c);\n break;\n case \"funnel\":\n result = layoutFunnel(o, c);\n break;\n case \"sankey\":\n result = layoutSankey(o, c);\n break;\n case \"sunburst\":\n result = layoutSunburst(o, c);\n break;\n case \"radialBar\":\n result = layoutRadialBar(o, c);\n break;\n case \"calendarHeatmap\":\n result = layoutCalendar(o, c);\n break;\n case \"bullet\":\n result = layoutBullet(o, c);\n break;\n case \"chord\":\n result = layoutChord(o, c);\n break;\n default:\n result = layoutTreemap(o, c);\n break;\n }\n return { type: o.type, width, height, labels, locale, ...result };\n};\n\n/** Target values of the animated quantities, by key */\nexport const shapeValues = (\n o: ShapeChartOptions,\n hidden: ReadonlySet<number> = NO_HIDDEN,\n focus: readonly string[] = NO_FOCUS,\n): Map<string, number> => {\n const out = new Map<string, number>();\n switch (o.type) {\n case \"pie\":\n pieValues(o, hidden, out);\n break;\n case \"radar\":\n radarValues(o, hidden, out);\n break;\n case \"gauge\":\n gaugeValues(o, hidden, out);\n break;\n case \"funnel\":\n funnelValues(o, hidden, out);\n break;\n case \"sankey\":\n sankeyValues(o, hidden, out);\n break;\n case \"sunburst\":\n sunburstValues(o, hidden, focus, out);\n break;\n case \"radialBar\":\n radialBarValues(o, hidden, out);\n break;\n case \"calendarHeatmap\":\n calendarValues(o, hidden, out);\n break;\n case \"bullet\":\n bulletValues(o, hidden, out);\n break;\n case \"chord\":\n chordValues(o, hidden, out);\n break;\n default:\n treemapValues(o, hidden, out);\n break;\n }\n return out;\n};\n\n/** Values shown at progress `t` of an animation from `from` to `to` */\nexport const blendValues = (\n from: ReadonlyMap<string, number>,\n to: ReadonlyMap<string, number>,\n t: number,\n): Map<string, number> => {\n const out = new Map<string, number>();\n to.forEach((v, key) => {\n const start = from.get(key) ?? 0;\n out.set(key, start + (v - start) * t);\n });\n return out;\n};\n\nexport const sameValues = (\n a: ReadonlyMap<string, number>,\n b: ReadonlyMap<string, number>,\n) => {\n if (a.size !== b.size) return false;\n for (const [key, v] of a) {\n const w = b.get(key);\n if (w === undefined || Math.abs(w - v) > 1e-12) return false;\n }\n return true;\n};\n\n/** Legend position and toggling */\nexport const legendConfig = (\n o: ShapeChartOptions,\n): Required<ShapeLegendOptions> => {\n const config = typeof o.legend === \"object\" ? o.legend : {};\n return {\n position: config.position ?? \"bottom\",\n toggle: config.toggle ?? true,\n };\n};\n\n/** Legend entries, `null` when the legend is hidden */\nexport const shapeLegend = (\n o: ShapeChartOptions,\n theme: ChartTheme,\n hidden: ReadonlySet<number> = NO_HIDDEN,\n): ShapeLegendEntry[] | null => {\n if (o.legend === false) return null;\n const palette = theme.palette.length ? theme.palette : [theme.primary];\n const color = (css: string | undefined, i: number) =>\n toCss(resolveWith(theme, css, palette[i % palette.length]));\n let entries: ShapeLegendEntry[] = [];\n let shown = o.legend !== undefined;\n switch (o.type) {\n case \"pie\":\n shown = true;\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"funnel\":\n shown = true;\n entries = funnelOrder(o, NO_HIDDEN).map((i) => ({\n index: i,\n name: o.data[i].name,\n color: color(o.data[i].color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"radar\":\n shown ||= o.series.length > 1;\n entries = o.series.map((s, i) => ({\n index: i,\n name: seriesName(o, i, shapeLabels(o)),\n color: color(s.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"treemap\":\n case \"sunburst\":\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"radialBar\":\n shown ||= !radialBarLabels(o);\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"bullet\":\n entries = o.data.map((d, i) => ({\n index: i,\n name: d.name,\n color: color(d.color, i),\n hidden: hidden.has(i),\n }));\n break;\n case \"sankey\": {\n const g = resolveSankey(o);\n entries = g.names.map((name, i) => ({\n index: i,\n name,\n color: color(g.colors[i], i),\n hidden: hidden.has(i),\n }));\n break;\n }\n case \"calendarHeatmap\":\n shown = true;\n entries = calendarLegend(o, theme, hidden);\n break;\n case \"chord\": {\n shown = true;\n const m = resolveChord(o);\n entries = m.names.map((name, i) => ({\n index: i,\n name,\n color: color(m.colors[i], i),\n hidden: hidden.has(i),\n }));\n break;\n }\n default:\n break;\n }\n return shown && entries.length ? entries : null;\n};\n\n/**\n * Number of toggleable entries (slices, stages, series, top-level nodes,\n * sankey nodes, bars, rows, calendar levels, chord groups)\n */\nexport const toggleCount = (o: ShapeChartOptions): number => {\n switch (o.type) {\n case \"radar\":\n return o.series.length;\n case \"gauge\":\n return 0;\n case \"sankey\":\n return resolveSankey(o).names.length;\n case \"calendarHeatmap\":\n return calendarModel(o)?.count ?? 0;\n case \"chord\":\n return resolveChord(o).names.length;\n default:\n return o.data.length;\n }\n};\n\n/** Event of a hovered item */\nexport const hoverEvent = (\n scene: ShapeScene,\n hover: ShapeHover | null,\n): ShapeHoverEvent | null => {\n if (!hover) return null;\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return null;\n if (item.indicators) {\n const k = clamp(hover.indicator ?? 0, 0, item.indicators.length - 1);\n const ind = item.indicators[k];\n return {\n index: item.index,\n indicator: k,\n name: item.name,\n value: ind.value,\n percent: ind.percent,\n color: item.color,\n };\n }\n return {\n index: item.index,\n name: item.name,\n value: item.value,\n percent: item.percent,\n color: item.color,\n ...(item.path ? { path: item.path } : {}),\n ...item.event,\n };\n};\n\nexport const sameHover = (a: ShapeHover | null, b: ShapeHover | null) =>\n a === b || (!!a && !!b && a.index === b.index && a.indicator === b.indicator);\n\nexport interface ShapeTooltipContent {\n title: string;\n color?: string;\n rows: ShapeTooltipRow[];\n}\n\n/** Default tooltip of a hovered item */\nexport const tooltipContent = (\n scene: ShapeScene,\n hover: ShapeHover,\n): ShapeTooltipContent | null => {\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return null;\n const rows = item.indicators\n ? item.rows.map((row, k) =>\n k === (hover.indicator ?? -1) ? { ...row, strong: true } : row,\n )\n : item.rows;\n return {\n title: item.path ? item.path.join(\" / \") : item.name,\n color: item.color,\n rows,\n };\n};\n\n/** Text read by screen readers for a focused item */\nexport const describeItem = (scene: ShapeScene, hover: ShapeHover) => {\n const item = scene.items.find((it) => it.index === hover.index);\n if (!item) return \"\";\n if (item.indicators) {\n const k = clamp(hover.indicator ?? 0, 0, item.indicators.length - 1);\n return `${item.name}, ${item.indicators[k].name}: ${item.rows[k]?.value ?? item.indicators[k].value}`;\n }\n const name = item.path ? item.path.join(\" / \") : item.name;\n return `${name}: ${item.rows[0]?.value ?? item.value} (${item.share ?? localePercent(scene.locale)(item.percent)})`;\n};\n\n/** Default accessible name of a chart (in its `locale`) */\nexport const describeChart = (o: ShapeChartOptions) => {\n const l = shapeLabels(o);\n switch (o.type) {\n case \"pie\":\n return o.rose\n ? l.roseChart\n : (o.innerRadius ?? 0) > 0\n ? l.donutChart\n : l.pieChart;\n case \"radar\":\n return l.radarChart;\n case \"gauge\":\n return o.label\n ? interpolate(l.gaugeChartNamed, { label: o.label })\n : l.gaugeChart;\n case \"funnel\":\n return l.funnelChart;\n case \"sankey\":\n return l.sankeyChart;\n case \"sunburst\":\n return l.sunburstChart;\n case \"radialBar\":\n return l.radialBarChart;\n case \"calendarHeatmap\":\n return l.calendarHeatmap;\n case \"bullet\":\n return l.bulletChart;\n case \"chord\":\n return l.chordChart;\n default:\n return l.treemapChart;\n }\n};\n\n/** Text summary of the data (screen readers) */\nexport const describeScene = (scene: ShapeScene) =>\n scene.empty\n ? (scene.labels ?? SHAPE_LABELS.en).noData\n : scene.items\n .slice(0, 12)\n .map((item) =>\n item.indicators\n ? `${item.name}: ${item.indicators\n .map(\n (ind, k) => `${ind.name} ${item.rows[k]?.value ?? ind.value}`,\n )\n .join(\", \")}`\n : describeItem(scene, { index: item.index }),\n )\n .join(\"; \");\n\n// ------------------------------------------------- canvas legend & tooltip\n\nexport interface ShapeLegendBox extends ShapeLegendEntry {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst LEGEND_ROW = 20;\n\n/** Centered legend rows drawn on a canvas; `height` includes the gap with the chart */\nexport const layoutShapeLegend = (\n entries: readonly ShapeLegendEntry[],\n width: number,\n position: \"top\" | \"bottom\",\n chartHeight: number,\n theme: ChartTheme,\n measure: MeasureText,\n): { boxes: ShapeLegendBox[]; height: number } => {\n const f = font(theme, 12);\n const gap = 14;\n const rows: ShapeLegendBox[][] = [[]];\n let x = 0;\n for (const e of entries) {\n const w = Math.min(width - 8, 16 + measure(e.name, f));\n let row = rows[rows.length - 1];\n if (row.length && x + gap + w > width - 8) {\n rows.push((row = []));\n x = 0;\n }\n if (row.length) x += gap;\n row.push({ ...e, x, y: 0, width: w, height: LEGEND_ROW });\n x += w;\n }\n const height = rows.length * LEGEND_ROW + 8;\n const top = position === \"top\" ? 2 : chartHeight - height + 6;\n const boxes: ShapeLegendBox[] = [];\n rows.forEach((row, r) => {\n const last = row[row.length - 1];\n const used = last ? last.x + last.width : 0;\n const offset = (width - used) / 2;\n for (const box of row) {\n boxes.push({ ...box, x: box.x + offset, y: top + r * LEGEND_ROW });\n }\n });\n return { boxes, height };\n};\n\nexport interface ShapeTooltipBox {\n x: number;\n y: number;\n width: number;\n height: number;\n padding: number;\n lineHeight: number;\n /** Default content */\n content?: ShapeTooltipContent;\n /** Lines of the content's title (long titles wrap) */\n titleLines?: string[];\n /** Custom text (`tooltip.render` returning a string) */\n text?: string[];\n}\n\n/** Margin between a tooltip and the edges of the drawing */\nconst TIP_MARGIN = 6;\n/** Distance between a tooltip and its anchor */\nconst TIP_GAP = 14;\n/** Half size of the box around the pointer a tooltip keeps off */\nconst TIP_POINTER = 6;\n\nconst overlapArea = (a: ShapeRect, b: ShapeRect) =>\n Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x)) *\n Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));\n\n/** Box of a circle arc (stroke half width included) */\nconst arcBox = (\n cx: number,\n cy: number,\n r0: number,\n r1: number,\n a0: number,\n a1: number,\n): ShapeRect => {\n const xs: number[] = [];\n const ys: number[] = [];\n const add = (a: number) => {\n for (const r of [r0, r1]) {\n xs.push(cx + r * Math.cos(a));\n ys.push(cy + r * Math.sin(a));\n }\n };\n add(a0);\n add(a1);\n // the extreme points of the circle crossed by the arc\n const start = Math.ceil(a0 / (Math.PI / 2));\n for (let k = start; k * (Math.PI / 2) <= a1; k++) add(k * (Math.PI / 2));\n const x = Math.min(...xs);\n const y = Math.min(...ys);\n return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };\n};\n\n/** Box of the marks of an item (slice, tile, arc, polygon, flow, ...) */\nconst itemBox = (scene: ShapeScene, index: number): ShapeRect | null => {\n let box: ShapeRect | null = null;\n const add = (b: ShapeRect) => {\n box = unionRect(box, b);\n };\n for (const node of scene.nodes) {\n if (node.hit !== index) continue;\n switch (node.kind) {\n case \"rect\":\n add(node);\n break;\n case \"sector\":\n add(arcBox(node.cx, node.cy, node.r0, node.r1, node.a0, node.a1));\n break;\n case \"arc\":\n add(\n arcBox(\n node.cx,\n node.cy,\n node.r - node.width / 2,\n node.r + node.width / 2,\n node.a0,\n node.a1,\n ),\n );\n break;\n case \"polygon\": {\n const p = node.points;\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (let i = 0; i + 1 < p.length; i += 2) {\n x0 = Math.min(x0, p[i]);\n x1 = Math.max(x1, p[i]);\n y0 = Math.min(y0, p[i + 1]);\n y1 = Math.max(y1, p[i + 1]);\n }\n if (x1 >= x0) add({ x: x0, y: y0, width: x1 - x0, height: y1 - y0 });\n break;\n }\n case \"circle\":\n add({\n x: node.cx - node.r,\n y: node.cy - node.r,\n width: node.r * 2,\n height: node.r * 2,\n });\n break;\n case \"link\": {\n const half = node.width / 2;\n const y0 = Math.min(node.y0, node.y1) - half;\n add({\n x: Math.min(node.x0, node.x1),\n y: y0,\n width: Math.abs(node.x1 - node.x0),\n height: Math.abs(node.y1 - node.y0) + node.width,\n });\n break;\n }\n default:\n break;\n }\n }\n return box;\n};\n\n/** Approximate box of a text node (unrotated) */\nconst textBox = (node: {\n x: number;\n y: number;\n text: string;\n font: string;\n align: \"left\" | \"center\" | \"right\";\n baseline: \"top\" | \"middle\" | \"bottom\" | \"alphabetic\";\n}): ShapeRect => {\n const size = Number(/(\\d+(?:\\.\\d+)?)px/.exec(node.font)?.[1] ?? 12);\n const width = estimateText(node.text, node.font);\n const x =\n node.align === \"center\"\n ? node.x - width / 2\n : node.align === \"right\"\n ? node.x - width\n : node.x;\n const y =\n node.baseline === \"top\"\n ? node.y\n : node.baseline === \"middle\"\n ? node.y - size / 2\n : node.y - size;\n return { x, y, width, height: size };\n};\n\n/**\n * Top-left corner of a `w` x `h` tooltip anchored at `anchor`, inside a\n * `width` x `height` drawing (or overflowing it into `bounds`, see\n * `placeTooltip`, when the drawing has no room). Candidates around the\n * pointer and around the hovered item are scored: never over the pointer\n * (nor the hovered radar vertex), then covering as little as possible of the\n * hovered item and of the texts, close to the pointer; radar tooltips lean\n * outward.\n */\nexport const placeShapeTooltip = (\n scene: ShapeScene | null,\n hover: ShapeHover | null,\n anchor: { x: number; y: number },\n w: number,\n h: number,\n width: number,\n height: number,\n bounds: ShapeRect | null = null,\n): TooltipPlacement => {\n const m = TIP_MARGIN;\n const { x: ax, y: ay } = anchor;\n const t = TIP_POINTER;\n const fallback = () =>\n placeTooltip({\n anchor,\n size: { width: w, height: h },\n stage: { width, height },\n margin: m,\n avoid: { x: ax - t, y: ay - t, width: t * 2, height: t * 2 },\n bounds,\n gap: 16 - t,\n });\n // tooltips larger than the drawing (sparkline-sized charts) go out of it\n if (!scene || !hover || w + m * 2 > width || h + m * 2 > height)\n return fallback();\n\n const fit = (x: number, y: number) => ({\n x: Math.max(m, Math.min(x, width - w - m)),\n y: Math.max(m, Math.min(y, height - h - m)),\n });\n // points the tooltip must not cover: the pointer and the hovered vertex\n const keep: [number, number][] = [[ax, ay]];\n const item = scene.items.find((it) => it.index === hover.index);\n const vertex =\n item?.indicators && hover.indicator !== undefined\n ? item.indicators[hover.indicator]\n : undefined;\n if (vertex) keep.push([vertex.x, vertex.y]);\n const target = itemBox(scene, hover.index);\n const texts: ShapeRect[] = [...(scene.radar?.labels ?? [])];\n for (const node of scene.nodes)\n if (node.kind === \"text\" && !node.rotate && node.indicator === undefined)\n texts.push(textBox(node));\n\n const radar = scene.radar;\n let dx = 0;\n let dy = 0;\n if (radar) {\n dx = ax - radar.cx;\n dy = ay - radar.cy;\n const len = Math.hypot(dx, dy);\n if (len > 1) {\n dx /= len;\n dy /= len;\n } else {\n dx = 1;\n dy = 0;\n }\n }\n\n const g = TIP_GAP;\n const candidates: [number, number][] = [\n [ax + g, ay - h / 2],\n [ax - g - w, ay - h / 2],\n [ax - w / 2, ay - g - h],\n [ax - w / 2, ay + g],\n [ax + g, ay - g - h],\n [ax + g, ay + g],\n [ax - g - w, ay - g - h],\n [ax - g - w, ay + g],\n ];\n if (target) {\n const gap = 10;\n candidates.push(\n [target.x + target.width + gap, ay - h / 2],\n [target.x - gap - w, ay - h / 2],\n [ax - w / 2, target.y - gap - h],\n [ax - w / 2, target.y + target.height + gap],\n );\n }\n // the free edges of wide or tall drawings (beyond the labels)\n candidates.push(\n [m, ay - h / 2],\n [width - w - m, ay - h / 2],\n [ax - w / 2, m],\n [ax - w / 2, height - h - m],\n );\n const area = w * h;\n let best: { x: number; y: number } | null = null;\n let bestScore = Infinity;\n for (const [cx0, cy0] of candidates) {\n const p = fit(cx0, cy0);\n const box = { x: p.x, y: p.y, width: w, height: h };\n let score = 0;\n for (const [px, py] of keep) {\n if (\n px > box.x - 8 &&\n px < box.x + w + 8 &&\n py > box.y - 8 &&\n py < box.y + h + 8\n )\n score += 1e6;\n }\n // texts weigh most (a hidden label is lost), then the hovered item\n if (target) score += (overlapArea(box, target) / area) * 400;\n for (const text of texts) score += overlapArea(box, text) * 4;\n const ox = p.x + w / 2 - ax;\n const oy = p.y + h / 2 - ay;\n const dist = Math.hypot(ox, oy) || 1;\n score += dist * 0.35;\n if (radar) score -= ((ox * dx + oy * dy) / dist) * 40;\n // candidates that fit without being pushed in\n score += Math.abs(p.x - cx0) + Math.abs(p.y - cy0);\n if (score < bestScore) {\n bestScore = score;\n best = p;\n }\n }\n if (!best || bestScore >= 1e6) return fallback();\n return { ...best, fit: \"stage\" };\n};\n\n/** Box of a tooltip drawn on a canvas, next to the anchor and inside the drawing */\nexport const layoutShapeTooltip = (\n value: ShapeTooltipContent | string,\n anchorX: number,\n anchorY: number,\n width: number,\n height: number,\n theme: ChartTheme,\n measure: MeasureText,\n scene: ShapeScene | null = null,\n hover: ShapeHover | null = null,\n): ShapeTooltipBox => {\n const padding = 9;\n const lineHeight = 18;\n let w = 0;\n let lines: number;\n let content: ShapeTooltipContent | undefined;\n let text: string[] | undefined;\n let titleLines: string[] | undefined;\n if (typeof value === \"string\") {\n text = value.split(\"\\n\");\n const f = font(theme, 12);\n for (const line of text) w = Math.max(w, measure(line, f));\n lines = text.length;\n } else {\n content = value;\n // long titles (full names of truncated labels) wrap to 3 lines\n const titleFont = font(theme, 12, 600);\n const dot = value.color ? 14 : 0;\n const maxTitle = Math.max(\n 60,\n Math.min(260, width - 16 - padding * 2) - dot,\n );\n titleLines = wrapText(value.title, maxTitle, titleFont, measure, 3);\n if (!titleLines.length) titleLines = [value.title];\n for (const line of titleLines)\n w = Math.max(w, dot + measure(line, titleFont));\n for (const row of value.rows) {\n w = Math.max(\n w,\n (row.color ? 14 : 0) +\n measure(row.name, font(theme, 12)) +\n 16 +\n measure(row.value, font(theme, 12, 600)),\n );\n }\n lines = titleLines.length + value.rows.length;\n }\n const bw = Math.max(96, Math.ceil(w + padding * 2 + 4));\n const bh = lines * lineHeight + padding * 2;\n const { x, y } = placeShapeTooltip(\n scene,\n hover,\n { x: anchorX, y: anchorY },\n bw,\n bh,\n width,\n height,\n );\n return {\n x,\n y,\n width: bw,\n height: bh,\n padding,\n lineHeight,\n ...(content ? { content, titleLines } : {}),\n ...(text ? { text } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0EA,IAAMA,oBAAiC,IAAI,IAAI,GACzCC,IAA8B,CAAC,GAGxBC,KAAoB,MAAwC;CACvE,IAAM,EAAE,SAASC,GAAG,UAAO,UAAO,cAAWC,GACvCC,IAASD,EAAM,UAAU;EAAE,GAAG;EAAG,GAAG;EAAG;EAAO;CAAO,GACrDE,IAAOF,EAAM,QAAQ,MACrBG,IAAIC,EAAMJ,EAAM,KAAK,GAAG,GAAG,CAAC,GAC5BK,IAAUC,EAAM,QAAQ,SAASA,EAAM,UAAU,CAACA,EAAM,OAAO,GAC/DC,IAASC,EAAcT,EAAE,MAAM,GAC/BU,IAASC,EAAYX,CAAC,GACtBY,IAAmB;EACvB;EACA,SAASX,EAAM;EACf,QAAQA,EAAM,UAAUJ;EACxB,OAAOQ,EAAMJ,EAAM,SAAS,GAAG,GAAG,CAAC;EACnC,QAAQ,GAAK,MAAW;GACtB,IAAI,CAACE,KAAQC,KAAK,GAAG,OAAOS;GAC5B,IAAMC,IAAQX,EAAK,IAAIY,CAAG,KAAK;GAC/B,OAAOD,KAASD,IAASC,KAASV;EACpC;EACA,QAAQJ,EAAE,UAAUgB,EAAaR,CAAM;EACvC,SAAS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AAU;GAAE;GAAS;EAAW,IAAI,CAAC;EACzC,GAAIN,IAAO,EAAE,QAAK,IAAI,CAAC;CACzB;AACF"}
@@ -1,4 +1,4 @@
1
- import { ChartPadding } from '../types.cjs';
1
+ import { ChartPadding, ChartRendererKind, ChartRendererPreference } from '../types.cjs';
2
2
  /** Kind of shape chart */
3
3
  export type ShapeChartType = "pie" | "radar" | "gauge" | "funnel" | "treemap" | "sankey" | "sunburst" | "radialBar" | "calendarHeatmap" | "bullet" | "chord";
4
4
  /** A named value (pie slice, funnel stage) */
@@ -176,6 +176,13 @@ export interface ShapeChartCommonOptions {
176
176
  padding?: ChartPadding;
177
177
  /** Accessible name of the chart */
178
178
  ariaLabel?: string;
179
+ /**
180
+ * Backend of the shapes: `auto` tries WebGPU, then WebGL2, then WebGL (1),
181
+ * then Canvas2D, and skips GPU backends that run in software. Text is
182
+ * always drawn with Canvas2D, above the shapes.
183
+ * @default "auto" (the global default, see `setDefaultChartRenderer`)
184
+ */
185
+ renderer?: ChartRendererPreference;
179
186
  }
180
187
  /** Pie / donut chart */
181
188
  export interface PieChartOptions extends ShapeChartCommonOptions {
@@ -825,6 +832,11 @@ export interface ShapeChartInstance {
825
832
  drill(path: readonly string[]): void;
826
833
  /** Sunburst: names from the root to the focused node (`[]` = the root) */
827
834
  getDrillPath(): string[];
835
+ /**
836
+ * Backend drawing the shapes; `null` until it is chosen (the first frames
837
+ * are drawn with Canvas2D meanwhile)
838
+ */
839
+ getRenderer(): ChartRendererKind | null;
828
840
  /** Subscribes to an event; returns the unsubscribe function */
829
841
  on<K extends keyof ShapeChartEventMap>(type: K, listener: (event: ShapeChartEventMap[K]) => void): () => void;
830
842
  /** Removes the DOM */
@@ -1,4 +1,4 @@
1
- import { ChartPadding } from '../types.js';
1
+ import { ChartPadding, ChartRendererKind, ChartRendererPreference } from '../types.js';
2
2
  /** Kind of shape chart */
3
3
  export type ShapeChartType = "pie" | "radar" | "gauge" | "funnel" | "treemap" | "sankey" | "sunburst" | "radialBar" | "calendarHeatmap" | "bullet" | "chord";
4
4
  /** A named value (pie slice, funnel stage) */
@@ -176,6 +176,13 @@ export interface ShapeChartCommonOptions {
176
176
  padding?: ChartPadding;
177
177
  /** Accessible name of the chart */
178
178
  ariaLabel?: string;
179
+ /**
180
+ * Backend of the shapes: `auto` tries WebGPU, then WebGL2, then WebGL (1),
181
+ * then Canvas2D, and skips GPU backends that run in software. Text is
182
+ * always drawn with Canvas2D, above the shapes.
183
+ * @default "auto" (the global default, see `setDefaultChartRenderer`)
184
+ */
185
+ renderer?: ChartRendererPreference;
179
186
  }
180
187
  /** Pie / donut chart */
181
188
  export interface PieChartOptions extends ShapeChartCommonOptions {
@@ -825,6 +832,11 @@ export interface ShapeChartInstance {
825
832
  drill(path: readonly string[]): void;
826
833
  /** Sunburst: names from the root to the focused node (`[]` = the root) */
827
834
  getDrillPath(): string[];
835
+ /**
836
+ * Backend drawing the shapes; `null` until it is chosen (the first frames
837
+ * are drawn with Canvas2D meanwhile)
838
+ */
839
+ getRenderer(): ChartRendererKind | null;
828
840
  /** Subscribes to an event; returns the unsubscribe function */
829
841
  on<K extends keyof ShapeChartEventMap>(type: K, listener: (event: ShapeChartEventMap[K]) => void): () => void;
830
842
  /** Removes the DOM */
@@ -1,2 +1,2 @@
1
- const e=require("../color.cjs"),t=require("../locale.cjs"),n=require("../scale.cjs"),r=require("../renderers/follow.cjs"),i=require("../theme.cjs"),a=require("./colormap.cjs"),o=require("./detect.cjs"),s=require("./dom.cjs"),c=require("./labels.cjs"),l=require("./model.cjs"),u=require("./geometry.cjs"),d=require("./hover.cjs"),f=require("./math.cjs"),p=require("./overlay.cjs"),ee=require("./pick.cjs"),te=require("./sort.cjs");var ne=(e,t,n)=>{let r=t===1?e*16:t===2?e*400:e;return Math.exp(Math.max(-1,Math.min(1,r*(n?.01:.0025))))},re={ambient:.5,diffuse:.6,specular:.25,shininess:32},ie=12,ae=.45,oe=5,se=380,ce=e=>f.clampCamera({azimuth:e?.azimuth??f.DEFAULT_CAMERA.azimuth,elevation:e?.elevation??f.DEFAULT_CAMERA.elevation,zoom:e?.zoom??f.DEFAULT_CAMERA.zoom,pan:[0,0],projection:e?.projection??f.DEFAULT_CAMERA.projection}),m=e=>({...e,pan:[e.pan[0],e.pan[1]]}),le=(e,t)=>e.azimuth===t.azimuth&&e.elevation===t.elevation&&e.zoom===t.zoom&&e.pan[0]===t.pan[0]&&e.pan[1]===t.pan[1]&&e.projection===t.projection,ue=(e,t,n)=>{let r=(t.azimuth-e.azimuth)%360;return r>180&&(r-=360),r<-180&&(r+=360),f.clampCamera({azimuth:e.azimuth+r*n,elevation:e.elevation+(t.elevation-e.elevation)*n,zoom:e.zoom*(t.zoom/e.zoom)**+n,pan:[e.pan[0]+(t.pan[0]-e.pan[0])*n,e.pan[1]+(t.pan[1]-e.pan[1])*n],projection:n<.5?e.projection:t.projection})},de=(e,t,n)=>{let r=Math.max(30,Math.min(72,e*.08)),i=Math.max(14,Math.min(28,t*.05)),a=Math.max(30,Math.min(56,t*.1)),o=n?74:0,s={x:r,y:i,width:Math.max(10,e-r*2-o),height:Math.max(10,t-i-a)};if(!n)return{fit:s,bar:null};let c=Math.max(40,Math.min(260,t*.62));return{fit:s,bar:{x:e-66,y:(t-c)/2+8,w:12,h:c}}},fe=(fe,me)=>{let h=fe.ownerDocument,g=h.defaultView,_=s.createChart3DDom(fe),v=_.stage,y=me,b=i.readTheme(_.root,y.palette),he=0,x=!1,S=new Map,C=(e,t)=>{S.get(e)?.forEach(e=>e(t))},ge=new Set,w=l.buildModel(y),T,E,_e=``,ve=0,ye=u.createGeometryBuilder(),D={items:[],targets:[],counts:[]},O=!0,be=ee.createPicker(),xe=te.createDepthSorter(),k=null,Se=0,Ce=()=>{},we=new Promise(e=>{Ce=e}),A=ce(y.camera),Te=JSON.stringify(y.camera??{}),j=m(A),M=null,N=0,P=!0,F=null,I=null,L=p.overlayStyle(b,pe(b)),R=null,z=null,B=null,V=null,Ee=!1,H=!0,U=0,W=typeof g?.matchMedia==`function`?g.matchMedia(`(prefers-reduced-motion: reduce)`):null,G=()=>{let e=y.interaction;if(e===!1)return null;let t=typeof e==`object`?e:{};return{rotate:t.rotate??!0,zoom:t.zoom??!0,wheel:t.wheel??`modifier`,pan:t.pan??!0,keyboard:t.keyboard??!0}},De=()=>{let e=y.autoRotate;return e===!0?ie:typeof e==`number`&&Number.isFinite(e)?e:0},Oe=()=>y.colorBar!==!1&&!!w.colorDomain,ke=()=>({...y,series:y.series.map((e,t)=>{let n=e.id??String(t);return ge.has(n)?{...e,hidden:!e.hidden}:e})}),Ae=t=>b.resolve?b.resolve(t,[.5,.5,.5,1]):e.parseColor(t)??[.5,.5,.5,1],je=()=>{let t=`${JSON.stringify(y.colorScale??`viridis`)}|${he}`;(t!==_e||!E)&&(_e=t,E=a.colorLut(a.colorStops(y.colorScale,(t,n)=>b.resolve?b.resolve(t,n):e.parseColor(t)??n)),ve++);let n=b.palette.length?b.palette:[b.primary];T={series:w.series.map((e,t)=>e.color?Ae(e.color):n[t%n.length]??b.primary),resolve:Ae,lut:E,wire:[b.text[0],b.text[1],b.text[2],.38]}},K=()=>{w=l.buildModel(ke()),je(),O=!0,L=p.overlayStyle(b,pe(b)),Ne(),Pe(),q(!0),R&&V&&Ge(V.x,V.y)},Me=``,Ne=()=>{let t=y.legend,n=w.series.filter(e=>e.name).length,r=t===void 0?n>1:!!t,i=typeof t==`object`?t:{},a=i.toggle??!0,o=i.position===`bottom`,l=`${r}|${o}|${a}`;if(r&&w.series.forEach((t,n)=>{l+=`\n${t.id}\u0001${t.name}\u0001${e.toCss(T.series[n]??b.primary)}\u0001${t.hidden}`}),l===Me)return;Me=l;let u=[..._.legend.children].indexOf(h.activeElement);_.legend.replaceChildren(),_.legend.style.display=r?`flex`:`none`,r&&(_.legend.style.order=o?`1`:`0`,_.legend.style.padding=o?`8px 4px 0`:`0 4px 8px`,w.series.forEach((t,n)=>{if(!t.name)return;let r=h.createElement(a?`button`:`span`);r instanceof HTMLButtonElement&&(r.type=`button`,r.setAttribute(`aria-pressed`,String(!t.hidden)),r.addEventListener(`click`,()=>{ge.has(t.id)?ge.delete(t.id):ge.add(t.id);let{labels:e}=w.locale;_.live.textContent=c.fill(t.hidden?e.shown:e.hidden,{name:t.name}),K()})),s.style(r,{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`2px 4px`,margin:`0`,border:`0`,borderRadius:`4px`,background:`none`,font:`inherit`,color:`var(--text-secondary-color, #6b7280)`,cursor:a?`pointer`:`default`,opacity:t.hidden?`0.45`:`1`,textDecoration:t.hidden?`line-through`:`none`}),r.append(s.swatch(h,e.toCss(T.series[n]??b.primary),t.type!==`bar`&&t.type!==`surface`),h.createTextNode(t.name)),_.legend.appendChild(r)}),u>=0&&_.legend.children[u]?.focus())},Pe=()=>{let{labels:e,count:t}=w.locale,n=w.series.map(e=>e.name).filter(Boolean).join(e.listSeparator);v.setAttribute(`aria-roledescription`,e.chart),v.setAttribute(`aria-label`,y.ariaLabel??(n?c.fill(e.chartNamed,{names:n}):e.chart)),G()?.keyboard?v.tabIndex=0:v.removeAttribute(`tabindex`),v.style.cursor=G()?.rotate?`grab`:`default`;let r=[];r.push(c.fill(e.seriesCount,{count:t(w.series.length)}));for(let n of w.series){let i=n.name||c.fill(e.series,{n:n.index+1}),a=n.type===`surface`?c.fill(e.grid,{rows:t(n.grid.rows),cols:t(n.grid.cols)}):n.type===`bar`?c.fill(e.bars,{count:t(n.bars.count)}):c.fill(n.type===`line`?e.vertices:e.points,{count:t(n.cols.count)});r.push(c.fill(n.hidden?e.seriesSummaryHidden:e.seriesSummary,{name:i,type:e[n.type],size:a}))}for(let t of[`x`,`y`,`z`]){let n=w[t],i=n.categories?n.categories.join(e.listSeparator):c.fill(e.range,{min:n.format(n.domain[0]),max:n.format(n.domain[1])});r.push(c.fill(n.title?e.axisTitled:e.axis,{axis:t.toUpperCase(),title:n.title,range:i}))}_.summary.textContent=r.join(` `)};function q(e=!0){e&&(P=!0),!(x||N||!g)&&(N=g.requestAnimationFrame(Le))}let Fe=()=>De()!==0&&H&&!Ee&&!X&&!M&&!W?.matches&&h.visibilityState!==`hidden`,Ie=e=>{let t=[0,0,0];for(let n=0;n<3;n++)t[n]=-e.right[n]*.35+e.up[n]*.55-e.forward[n]*.7;return t[2]+=.35,f.normalize(t)};function Le(e){if(N=0,x)return;let t=v.clientWidth,n=v.clientHeight;if(t<=0||n<=0)return;let r=g?.devicePixelRatio||1;if(M){let t=Math.min(1,(e-M.start)/se),n=1-(1-t)**3;j=ue(M.from,M.to,n),t>=1&&(j=m(M.to),M=null,C(`camera`,m(j))),P=!0}else if(Fe()){let t=U?Math.min(.1,(e-U)/1e3):0;t>0&&(j=f.clampCamera({...j,azimuth:j.azimuth-De()*t}),P=!0),U=e}else U=0;s.sizeCanvas(_.background,t,n,r),s.sizeCanvas(_.foreground,t,n,r);let i=de(t,n,Oe()),a=y.camera?.fov??32,o=[w.x.half,w.y.half,w.z.half],c=f.cameraFrame(j,o,t,n,i.fit,a);if(F=c,I=i,P){P=!1;let e=_.background.getContext(`2d`);if(e&&(e.setTransform(r,0,0,r,0,0),e.clearRect(0,0,t,n),y.box!==!1&&p.drawWalls(e,c,w,L)),k){O&&(D=ye(w,T,k.kind===`canvas2d`?u.CPU_BUDGET:u.GPU_BUDGET,ve),O=!1,be.reset());let e=Math.max(1,Math.round(t*r)),i=Math.max(1,Math.round(n*r));(k.canvas.width!==e||k.canvas.height!==i)&&k.resize(e,i),k.canvas.style.width=`${t}px`,k.canvas.style.height=`${n}px`;let a=y.lighting??{},o={viewProj:c.viewProj,eye:c.eye,light:Ie(c),orthographic:c.orthographic,distance:c.distance,radius:c.radius,width:e,height:i,dpr:r,lighting:[a.ambient??re.ambient,a.diffuse??re.diffuse,a.specular??re.specular,a.shininess??re.shininess],fog:b.background,exposure:Math.max(0,y.exposure??1)};k.render(k.kind===`canvas2d`||k.orderIndependent?D.items:xe(D.items,o),o)}}Re(c,i,t,n,r),(M||Fe())&&q(!0)}let Re=(e,t,n,r,i)=>{let a=_.foreground.getContext(`2d`);if(a){if(a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r),y.box!==!1&&p.drawAxes(a,e,w,L,{left:4,top:4,right:t.bar?t.bar.x-10:n-4,bottom:r-4}),t.bar&&w.colorDomain){let e=typeof y.colorBar==`object`?y.colorBar:{};p.drawColorBar(a,t.bar,E,w.colorDomain,e.format??ze(),e.title??(w.colorFromZ?w.z.title:``),L,n)}if(R&&z){let t=d.highlightShape(D.targets,R,z.color);t&&p.drawHighlight(a,e,w,t,L)}}},ze=()=>{let e=w.colorDomain,{locale:t}=w;if(!e)return t.value;if(w.colorFromZ&&y.zAxis?.format)return y.zAxis.format;let r=n.tickStep(e[0],e[1],5);return r>0?t.ticks(r,Math.max(Math.abs(e[0]),Math.abs(e[1]))):t.value},Be=()=>y.tooltip!==!1,Ve=()=>({x:v.offsetLeft,y:v.offsetTop}),J=e=>{let t=e&&!O?d.hoverEvent(w,D.targets,e,T,Ve()):null,n=t===null!=(z===null)||!!t&&!!z&&(t.seriesIndex!==z.seriesIndex||t.index!==z.index||t.type!==z.type);if(R=t?e:null,z=t,He(),F&&I){let e=v.clientWidth,t=v.clientHeight;e>0&&t>0&&Re(F,I,e,t,g?.devicePixelRatio||1)}n&&C(`hover`,t)},He=()=>{let e=_.tooltip;if(!z||!R||!Be()){e.style.display=`none`;return}let t=typeof y.tooltip==`object`?y.tooltip.render:void 0,n=t?t(z):Ue(z);if(n===null){e.style.display=`none`;return}typeof n==`string`?e.textContent=n:e.replaceChildren(n),e.style.display=`block`;let r=v.clientWidth,i=v.clientHeight,a=e.offsetWidth,o=e.offsetHeight,s=R.x+16;s+a>r-4&&(s=R.x-16-a),s=Math.max(4,s);let c=Math.max(4,Math.min(i-o-4,R.y-o/2));e.style.transform=`translate(${Math.round(s)}px, ${Math.round(c)}px)`},Ue=e=>{let t=h.createDocumentFragment(),n=s.style(h.createElement(`div`),{display:`flex`,alignItems:`center`,gap:`6px`,fontWeight:`600`,marginBottom:`4px`,color:`var(--text-color, #1f2937)`});n.append(s.swatch(h,e.color,e.type!==`bar`),h.createTextNode(e.seriesName||c.fill(w.locale.labels.series,{n:e.seriesIndex+1}))),t.append(n);let r=typeof y.colorBar==`object`&&y.colorBar.title?y.colorBar.title:``;for(let n of d.tooltipRows(w,e,r)){let e=s.style(h.createElement(`div`),{display:`flex`,alignItems:`center`,gap:`8px`}),r=s.style(h.createElement(`span`),{flex:`1 1 auto`,color:`var(--text-secondary-color, #6b7280)`});r.textContent=n.name;let i=s.style(h.createElement(`span`),{fontWeight:n.name?`600`:`400`,fontVariantNumeric:`tabular-nums`,marginLeft:n.name?`12px`:`0`});i.textContent=n.value,n.name?e.append(r,i):e.append(i),t.append(e)}return t},We=(e,t)=>!F||O||!k?null:be.pick(D.targets,F,e,t),Y=0,Ge=(e,t)=>{B={x:e,y:t},!Y&&g&&(Y=g.requestAnimationFrame(()=>{Y=0;let e=B;B=null,!(!e||x||X)&&J(We(e.x,e.y))}))},X=null,Z=new Map,Q=e=>{let t=v.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},Ke=()=>I?.fit.height??Math.max(1,v.clientHeight),$=(e,t=!0)=>{let n=f.clampCamera(e);le(n,j)||(j=n,M=null,R&&J(null),q(!0),t&&C(`camera`,m(j)))},qe=e=>{if(W?.matches||!g){$(e);return}M={from:m(j),to:m(e),start:g.performance.now()},q(!0)},Je=()=>{let e=[...Z.values()],t=e[0]??{x:0,y:0},n=e[1]??t;return{distance:Math.hypot(t.x-n.x,t.y-n.y),center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}},Ye=(e,t)=>{X={mode:e,pointers:Z,start:m(j),origin:t,distance:e===`pinch`?Je().distance:0,moved:!1},M=null,R&&J(null),v.style.cursor=e===`rotate`?`grabbing`:`move`},Xe=e=>{let t=G();if(!t)return;let n=Q(e);if(Z.set(e.pointerId,n),v.setPointerCapture?.(e.pointerId),Z.size===2&&(t.zoom||t.pan)){Ye(`pinch`,Je().center);return}if(Z.size>1)return;let r=t.pan&&(e.button===2||e.shiftKey||e.button===1);r?Ye(`pan`,n):t.rotate&&e.button===0?Ye(`rotate`,n):X=null,(r||e.button===1)&&e.preventDefault()},Ze=e=>{let t=Q(e);if(V=t,Z.has(e.pointerId)&&Z.set(e.pointerId,t),!X){if(e.pointerType===`touch`&&Z.size)return;(Be()||S.get(`hover`)?.size||S.get(`click`)?.size)&&Ge(t.x,t.y);return}let n=G();if(!n)return;if(X.mode===`pinch`){let{distance:e,center:t}=Je(),r=X.distance>0?e/X.distance:1,i=Ke();$({...X.start,zoom:n.zoom?X.start.zoom*r:X.start.zoom,pan:n.pan?[X.start.pan[0]+(t.x-X.origin.x)/i,X.start.pan[1]+(t.y-X.origin.y)/i]:X.start.pan}),X.moved=!0;return}let r=t.x-X.origin.x,i=t.y-X.origin.y;if(!(!X.moved&&Math.hypot(r,i)<3)){if(X.moved=!0,X.mode===`pan`){let e=Ke();$({...X.start,pan:[X.start.pan[0]+r/e,X.start.pan[1]+i/e]})}else $({...X.start,azimuth:X.start.azimuth-r*ae,elevation:X.start.elevation+i*ae})}},Qe=e=>{let t=X;if(Z.delete(e.pointerId),v.hasPointerCapture?.(e.pointerId)&&v.releasePointerCapture(e.pointerId),Z.size===1&&t?.mode===`pinch`){let e=[...Z.values()][0];Ye(`rotate`,e);return}if(!Z.size){if(X=null,v.style.cursor=G()?.rotate?`grab`:`default`,t&&!t.moved&&e.button===0){let t=Q(e),n=We(t.x,t.y);J(n),z&&C(`click`,z)}Fe()&&q(!1)}},$e=e=>{Z.delete(e.pointerId),Z.size||(X=null,v.style.cursor=G()?.rotate?`grab`:`default`)},et=e=>{e.pointerType!==`touch`&&(Ee=!0)},tt=()=>{Ee=!1,B=null,V=null,!X&&R&&J(null),Fe()&&q(!1)},nt=e=>{let t=G();if(!t?.zoom)return;let n=e.ctrlKey&&!e.metaKey;if(t.wheel===`modifier`&&!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let r=ne(e.deltaY,e.deltaMode,n),i=j.zoom/r,a=I;if(!a){$({...j,zoom:i});return}let o=f.clampCamera({...j,zoom:i}),s=o.zoom/j.zoom,c=a.fit.height,l=a.fit.x+a.fit.width/2+j.pan[0]*c,u=a.fit.y+a.fit.height/2+j.pan[1]*c,d=Q(e),p=d.x-s*(d.x-l),ee=d.y-s*(d.y-u);$({...o,pan:[j.pan[0]+(p-l)/c,j.pan[1]+(ee-u)/c]}),R&&J(null)},rt=e=>{G()&&(e.preventDefault(),qe(A))},it=e=>{G()?.pan&&e.preventDefault()},at=()=>{let e;try{e=v.matches(`:focus-visible`)}catch{e=!0}e&&(v.style.boxShadow=`0 0 0 2px var(--primary-color, #4f46e5)`)},ot=()=>{v.style.boxShadow=``},st=e=>{let t=G();if(!t?.keyboard)return;let n=null,r=e.shiftKey?15:oe;switch(e.key){case`ArrowLeft`:t.rotate&&(n={...j,azimuth:j.azimuth+r});break;case`ArrowRight`:t.rotate&&(n={...j,azimuth:j.azimuth-r});break;case`ArrowUp`:t.rotate&&(n={...j,elevation:j.elevation+r});break;case`ArrowDown`:t.rotate&&(n={...j,elevation:j.elevation-r});break;case`+`:case`=`:t.zoom&&(n={...j,zoom:j.zoom*1.2});break;case`-`:case`_`:t.zoom&&(n={...j,zoom:j.zoom/1.2});break;case`0`:case`Home`:e.preventDefault(),qe(A);return;case`Escape`:V=null,R&&(e.preventDefault(),J(null));return;default:return}n&&(e.preventDefault(),$(n))};v.addEventListener(`pointerdown`,Xe),v.addEventListener(`pointermove`,Ze),v.addEventListener(`pointerup`,Qe),v.addEventListener(`pointercancel`,$e),v.addEventListener(`pointerenter`,et),v.addEventListener(`pointerleave`,tt),v.addEventListener(`wheel`,nt,{passive:!1}),v.addEventListener(`dblclick`,rt),v.addEventListener(`contextmenu`,it),v.addEventListener(`keydown`,st),v.addEventListener(`focus`,at),v.addEventListener(`blur`,ot);let ct=typeof ResizeObserver==`function`?new ResizeObserver(()=>{be.reset(),q(!0)}):null;ct?.observe(v);let lt=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{let t=e[e.length-1];if(!t)return;let n=H;H=t.isIntersecting,H&&!n&&q(!0)}):null;lt?.observe(v);let ut=()=>{h.visibilityState!==`hidden`&&q(!1)};h.addEventListener(`visibilitychange`,ut);let dt=null,ft=()=>{pt(),q(!0)},pt=()=>{dt?.removeEventListener?.(`change`,ft),dt=typeof g?.matchMedia==`function`?g.matchMedia(`(resolution: ${g.devicePixelRatio||1}dppx)`):null,dt?.addEventListener?.(`change`,ft)};pt();let mt=()=>q(!1);W?.addEventListener?.(`change`,mt);let ht=()=>{if(x)return;let e=i.readTheme(_.root,y.palette);i.themeColorsChanged(b,e)&&he++,b=e,K()},gt=i.watchTheme(ht),_t=typeof g?.MutationObserver==`function`?new g.MutationObserver(()=>{!x&&t.resolveLocale(y.locale)!==w.locale.locale&&K()}):null;_t?.observe(h.documentElement,{attributes:!0,attributeFilter:[`lang`]});let vt=async(e=new Set)=>{let t=++Se,n=await o.createRenderer3D(y.renderer??`auto`,()=>{let e=s.layerCanvas(h);return e.className=`minerva-chart-data`,e},t=>{x||k?.kind!==t||(k.destroy(),k.canvas.remove(),k=null,vt(new Set([...e,t])))},e);if(x||t!==Se){n?.destroy();return}k&&(k.destroy(),k.canvas.remove()),k=n,O=!0,n?(_.root.dataset.renderer=n.kind,v.insertBefore(n.canvas,_.foreground),C(`renderer`,n.kind)):delete _.root.dataset.renderer,Ce(n?.kind??null),q(!0)};je(),K(),vt();let yt=r.followDefaultRenderer(()=>y.renderer,()=>void vt());return{setOptions(e){if(x)return;let t=y;y=e,(e.palette??[]).join()!==(t.palette??[]).join()&&(b=i.readTheme(_.root,e.palette),he++);let n=JSON.stringify(e.camera??{});n!==Te&&(Te=n,A=ce(e.camera),$({...A})),(e.renderer??`auto`)!==(t.renderer??`auto`)&&vt(),K()},resize(){be.reset(),q(!0)},resetCamera(){$(m(A))},getCamera:()=>m(j),setCamera(e){x||$({azimuth:e.azimuth??j.azimuth,elevation:e.elevation??j.elevation,zoom:e.zoom??j.zoom,pan:e.pan?[e.pan[0],e.pan[1]]:j.pan,projection:e.projection??j.projection})},getRenderer:()=>k?.kind??null,ready:we,refreshTheme:ht,on(e,t){let n=S.get(e);return n||(n=new Set,S.set(e,n)),n.add(t),()=>{n.delete(t)}},destroy(){x||(x=!0,Se++,N&&g?.cancelAnimationFrame(N),Y&&g?.cancelAnimationFrame(Y),N=0,Y=0,ct?.disconnect(),lt?.disconnect(),h.removeEventListener(`visibilitychange`,ut),dt?.removeEventListener?.(`change`,ft),W?.removeEventListener?.(`change`,mt),yt(),gt(),_t?.disconnect(),v.removeEventListener(`pointerdown`,Xe),v.removeEventListener(`pointermove`,Ze),v.removeEventListener(`pointerup`,Qe),v.removeEventListener(`pointercancel`,$e),v.removeEventListener(`pointerenter`,et),v.removeEventListener(`pointerleave`,tt),v.removeEventListener(`wheel`,nt),v.removeEventListener(`dblclick`,rt),v.removeEventListener(`contextmenu`,it),v.removeEventListener(`keydown`,st),v.removeEventListener(`focus`,at),v.removeEventListener(`blur`,ot),k?.destroy(),k=null,S.clear(),Ce(null),_.root.remove())}}};function pe(t){return e.luminance(t.background)<.4||e.luminance(t.text)>.6}exports.createChart3D=fe,exports.initialCamera=ce,exports.stageLayout=de;
1
+ const e=require("../tooltip.cjs"),t=require("../locale.cjs"),n=require("../scale.cjs"),r=require("../color.cjs"),i=require("../renderers/follow.cjs"),a=require("../theme.cjs"),o=require("./colormap.cjs"),s=require("./detect.cjs"),c=require("./dom.cjs"),l=require("./labels.cjs"),u=require("./model.cjs"),d=require("./geometry.cjs"),ee=require("./hover.cjs"),f=require("./math.cjs"),p=require("./overlay.cjs"),te=require("./pick.cjs"),ne=require("./sort.cjs");var re=(e,t,n)=>{let r=t===1?e*16:t===2?e*400:e;return Math.exp(Math.max(-1,Math.min(1,r*(n?.01:.0025))))},m={ambient:.5,diffuse:.6,specular:.25,shininess:32},ie=12,ae=.45,oe=5,se=380,ce=e=>f.clampCamera({azimuth:e?.azimuth??f.DEFAULT_CAMERA.azimuth,elevation:e?.elevation??f.DEFAULT_CAMERA.elevation,zoom:e?.zoom??f.DEFAULT_CAMERA.zoom,pan:[0,0],projection:e?.projection??f.DEFAULT_CAMERA.projection}),h=e=>({...e,pan:[e.pan[0],e.pan[1]]}),le=(e,t)=>e.azimuth===t.azimuth&&e.elevation===t.elevation&&e.zoom===t.zoom&&e.pan[0]===t.pan[0]&&e.pan[1]===t.pan[1]&&e.projection===t.projection,ue=(e,t,n)=>{let r=(t.azimuth-e.azimuth)%360;return r>180&&(r-=360),r<-180&&(r+=360),f.clampCamera({azimuth:e.azimuth+r*n,elevation:e.elevation+(t.elevation-e.elevation)*n,zoom:e.zoom*(t.zoom/e.zoom)**+n,pan:[e.pan[0]+(t.pan[0]-e.pan[0])*n,e.pan[1]+(t.pan[1]-e.pan[1])*n],projection:n<.5?e.projection:t.projection})},de=(e,t,n)=>{let r=Math.max(30,Math.min(72,e*.08)),i=Math.max(14,Math.min(28,t*.05)),a=Math.max(30,Math.min(56,t*.1)),o=n?74:0,s={x:r,y:i,width:Math.max(10,e-r*2-o),height:Math.max(10,t-i-a)};if(!n)return{fit:s,bar:null};let c=Math.max(40,Math.min(260,t*.62));return{fit:s,bar:{x:e-66,y:(t-c)/2+8,w:12,h:c}}},fe=(fe,me)=>{let g=fe.ownerDocument,_=g.defaultView,v=c.createChart3DDom(fe),y=v.stage,b=me,x=a.readTheme(v.root,b.palette),he=0,S=!1,C=new Map,w=(e,t)=>{C.get(e)?.forEach(e=>e(t))},ge=new Set,T=u.buildModel(b),E,_e,ve=``,ye=0,be=d.createGeometryBuilder(),D={items:[],targets:[],counts:[]},O=!0,k=te.createPicker(),xe=ne.createDepthSorter(),A=null,Se=0,Ce=()=>{},we=new Promise(e=>{Ce=e}),j=ce(b.camera),Te=JSON.stringify(b.camera??{}),M=h(j),N=null,P=0,F=!0,I=null,L=null,R=p.overlayStyle(x,pe(x)),z=null,B=null,V=null,H=null,Ee=!1,U=!0,W=0,G=typeof _?.matchMedia==`function`?_.matchMedia(`(prefers-reduced-motion: reduce)`):null,K=()=>{let e=b.interaction;if(e===!1)return null;let t=typeof e==`object`?e:{};return{rotate:t.rotate??!0,zoom:t.zoom??!0,wheel:t.wheel??`modifier`,pan:t.pan??!0,keyboard:t.keyboard??!0}},De=()=>{let e=b.autoRotate;return e===!0?ie:typeof e==`number`&&Number.isFinite(e)?e:0},Oe=()=>b.colorBar!==!1&&!!T.colorDomain,ke=()=>({...b,series:b.series.map((e,t)=>{let n=e.id??String(t);return ge.has(n)?{...e,hidden:!e.hidden}:e})}),Ae=e=>x.resolve?x.resolve(e,[.5,.5,.5,1]):r.parseColor(e)??[.5,.5,.5,1],je=()=>{let e=`${JSON.stringify(b.colorScale??`viridis`)}|${he}`;(e!==ve||!_e)&&(ve=e,_e=o.colorLut(o.colorStops(b.colorScale,(e,t)=>x.resolve?x.resolve(e,t):r.parseColor(e)??t)),ye++);let t=x.palette.length?x.palette:[x.primary];E={series:T.series.map((e,n)=>e.color?Ae(e.color):t[n%t.length]??x.primary),resolve:Ae,lut:_e,wire:[x.text[0],x.text[1],x.text[2],.38]}},q=()=>{T=u.buildModel(ke()),je(),O=!0,R=p.overlayStyle(x,pe(x)),Ne(),Pe(),J(!0),z&&H&&Ge(H.x,H.y)},Me=``,Ne=()=>{let e=b.legend,t=T.series.filter(e=>e.name).length,n=e===void 0?t>1:!!e,i=typeof e==`object`?e:{},a=i.toggle??!0,o=i.position===`bottom`,s=`${n}|${o}|${a}`;if(n&&T.series.forEach((e,t)=>{s+=`\n${e.id}\u0001${e.name}\u0001${r.toCss(E.series[t]??x.primary)}\u0001${e.hidden}`}),s===Me)return;Me=s;let u=[...v.legend.children].indexOf(g.activeElement);v.legend.replaceChildren(),v.legend.style.display=n?`flex`:`none`,n&&(v.legend.style.order=o?`1`:`0`,v.legend.style.padding=o?`8px 4px 0`:`0 4px 8px`,T.series.forEach((e,t)=>{if(!e.name)return;let n=g.createElement(a?`button`:`span`);n instanceof HTMLButtonElement&&(n.type=`button`,n.setAttribute(`aria-pressed`,String(!e.hidden)),n.addEventListener(`click`,()=>{ge.has(e.id)?ge.delete(e.id):ge.add(e.id);let{labels:t}=T.locale;v.live.textContent=l.fill(e.hidden?t.shown:t.hidden,{name:e.name}),q()})),c.style(n,{display:`inline-flex`,alignItems:`center`,gap:`6px`,padding:`2px 4px`,margin:`0`,border:`0`,borderRadius:`4px`,background:`none`,font:`inherit`,color:`var(--text-secondary-color, #6b7280)`,cursor:a?`pointer`:`default`,opacity:e.hidden?`0.45`:`1`,textDecoration:e.hidden?`line-through`:`none`}),n.append(c.swatch(g,r.toCss(E.series[t]??x.primary),e.type!==`bar`&&e.type!==`surface`),g.createTextNode(e.name)),v.legend.appendChild(n)}),u>=0&&v.legend.children[u]?.focus())},Pe=()=>{let{labels:e,count:t}=T.locale,n=T.series.map(e=>e.name).filter(Boolean).join(e.listSeparator);y.setAttribute(`aria-roledescription`,e.chart),y.setAttribute(`aria-label`,b.ariaLabel??(n?l.fill(e.chartNamed,{names:n}):e.chart)),K()?.keyboard?y.tabIndex=0:y.removeAttribute(`tabindex`),y.style.cursor=K()?.rotate?`grab`:`default`;let r=[];r.push(l.fill(e.seriesCount,{count:t(T.series.length)}));for(let n of T.series){let i=n.name||l.fill(e.series,{n:n.index+1}),a=n.type===`surface`?l.fill(e.grid,{rows:t(n.grid.rows),cols:t(n.grid.cols)}):n.type===`bar`?l.fill(e.bars,{count:t(n.bars.count)}):l.fill(n.type===`line`?e.vertices:e.points,{count:t(n.cols.count)});r.push(l.fill(n.hidden?e.seriesSummaryHidden:e.seriesSummary,{name:i,type:e[n.type],size:a}))}for(let t of[`x`,`y`,`z`]){let n=T[t],i=n.categories?n.categories.join(e.listSeparator):l.fill(e.range,{min:n.format(n.domain[0]),max:n.format(n.domain[1])});r.push(l.fill(n.title?e.axisTitled:e.axis,{axis:t.toUpperCase(),title:n.title,range:i}))}v.summary.textContent=r.join(` `)};function J(e=!0){e&&(F=!0),!(S||P||!_)&&(P=_.requestAnimationFrame(Le))}let Fe=()=>De()!==0&&U&&!Ee&&!Z&&!N&&!G?.matches&&g.visibilityState!==`hidden`,Ie=e=>{let t=[0,0,0];for(let n=0;n<3;n++)t[n]=-e.right[n]*.35+e.up[n]*.55-e.forward[n]*.7;return t[2]+=.35,f.normalize(t)};function Le(e){if(P=0,S)return;let t=y.clientWidth,n=y.clientHeight;if(t<=0||n<=0)return;let r=_?.devicePixelRatio||1;if(N){let t=Math.min(1,(e-N.start)/se),n=1-(1-t)**3;M=ue(N.from,N.to,n),t>=1&&(M=h(N.to),N=null,w(`camera`,h(M))),F=!0}else if(Fe()){let t=W?Math.min(.1,(e-W)/1e3):0;t>0&&(M=f.clampCamera({...M,azimuth:M.azimuth-De()*t}),F=!0),W=e}else W=0;c.sizeCanvas(v.background,t,n,r),c.sizeCanvas(v.foreground,t,n,r);let i=de(t,n,Oe()),a=b.camera?.fov??32,o=[T.x.half,T.y.half,T.z.half],s=f.cameraFrame(M,o,t,n,i.fit,a);if(I=s,L=i,F){F=!1;let e=v.background.getContext(`2d`);if(e&&(e.setTransform(r,0,0,r,0,0),e.clearRect(0,0,t,n),b.box!==!1&&p.drawWalls(e,s,T,R)),A){O&&(D=be(T,E,A.kind===`canvas2d`?d.CPU_BUDGET:d.GPU_BUDGET,ye),O=!1,k.reset());let e=Math.max(1,Math.round(t*r)),i=Math.max(1,Math.round(n*r));(A.canvas.width!==e||A.canvas.height!==i)&&A.resize(e,i),A.canvas.style.width=`${t}px`,A.canvas.style.height=`${n}px`;let a=b.lighting??{},o={viewProj:s.viewProj,eye:s.eye,light:Ie(s),orthographic:s.orthographic,distance:s.distance,radius:s.radius,width:e,height:i,dpr:r,lighting:[a.ambient??m.ambient,a.diffuse??m.diffuse,a.specular??m.specular,a.shininess??m.shininess],fog:x.background,exposure:Math.max(0,b.exposure??1)};A.render(A.kind===`canvas2d`||A.orderIndependent?D.items:xe(D.items,o),o)}}Re(s,i,t,n,r),(N||Fe())&&J(!0)}let Re=(e,t,n,r,i)=>{let a=v.foreground.getContext(`2d`);if(a){if(a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r),b.box!==!1&&p.drawAxes(a,e,T,R,{left:4,top:4,right:t.bar?t.bar.x-10:n-4,bottom:r-4}),t.bar&&T.colorDomain){let e=typeof b.colorBar==`object`?b.colorBar:{};p.drawColorBar(a,t.bar,_e,T.colorDomain,e.format??ze(),e.title??(T.colorFromZ?T.z.title:``),R,n)}if(z&&B){let t=ee.highlightShape(D.targets,z,B.color);t&&p.drawHighlight(a,e,T,t,R)}}},ze=()=>{let e=T.colorDomain,{locale:t}=T;if(!e)return t.value;if(T.colorFromZ&&b.zAxis?.format)return b.zAxis.format;let r=n.tickStep(e[0],e[1],5);return r>0?t.ticks(r,Math.max(Math.abs(e[0]),Math.abs(e[1]))):t.value},Be=()=>b.tooltip!==!1,Ve=()=>({x:y.offsetLeft,y:y.offsetTop}),Y=e=>{let t=e&&!O?ee.hoverEvent(T,D.targets,e,E,Ve()):null,n=t===null!=(B===null)||!!t&&!!B&&(t.seriesIndex!==B.seriesIndex||t.index!==B.index||t.type!==B.type);if(z=t?e:null,B=t,He(),I&&L){let e=y.clientWidth,t=y.clientHeight;e>0&&t>0&&Re(I,L,e,t,_?.devicePixelRatio||1)}n&&w(`hover`,t)},He=()=>{let t=v.tooltip;if(!B||!z||!Be()){t.style.display=`none`;return}let n=typeof b.tooltip==`object`?b.tooltip.render:void 0,r=n?n(B):Ue(B);if(r===null){t.style.display=`none`;return}typeof r==`string`?t.textContent=r:t.replaceChildren(r),t.style.display=`block`,e.positionTooltip(t,y,{anchor:{x:z.x,y:z.y},avoid:{x:z.x-8,y:z.y-8,width:16,height:16},gap:10})},Ue=e=>{let t=g.createDocumentFragment(),n=c.style(g.createElement(`div`),{display:`flex`,alignItems:`center`,gap:`6px`,fontWeight:`600`,marginBottom:`4px`,color:`var(--text-color, #1f2937)`});n.append(c.swatch(g,e.color,e.type!==`bar`),g.createTextNode(e.seriesName||l.fill(T.locale.labels.series,{n:e.seriesIndex+1}))),t.append(n);let r=typeof b.colorBar==`object`&&b.colorBar.title?b.colorBar.title:``;for(let n of ee.tooltipRows(T,e,r)){let e=c.style(g.createElement(`div`),{display:`flex`,alignItems:`center`,gap:`8px`}),r=c.style(g.createElement(`span`),{flex:`1 1 auto`,color:`var(--text-secondary-color, #6b7280)`});r.textContent=n.name;let i=c.style(g.createElement(`span`),{fontWeight:n.name?`600`:`400`,fontVariantNumeric:`tabular-nums`,marginLeft:n.name?`12px`:`0`});i.textContent=n.value,n.name?e.append(r,i):e.append(i),t.append(e)}return t},We=(e,t)=>!I||O||!A?null:k.pick(D.targets,I,e,t),X=0,Ge=(e,t)=>{V={x:e,y:t},!X&&_&&(X=_.requestAnimationFrame(()=>{X=0;let e=V;V=null,!(!e||S||Z)&&Y(We(e.x,e.y))}))},Z=null,Q=new Map,Ke=e=>{let t=y.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},qe=()=>L?.fit.height??Math.max(1,y.clientHeight),$=(e,t=!0)=>{let n=f.clampCamera(e);le(n,M)||(M=n,N=null,z&&Y(null),J(!0),t&&w(`camera`,h(M)))},Je=e=>{if(G?.matches||!_){$(e);return}N={from:h(M),to:h(e),start:_.performance.now()},J(!0)},Ye=()=>{let e=[...Q.values()],t=e[0]??{x:0,y:0},n=e[1]??t;return{distance:Math.hypot(t.x-n.x,t.y-n.y),center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}},Xe=(e,t)=>{Z={mode:e,pointers:Q,start:h(M),origin:t,distance:e===`pinch`?Ye().distance:0,moved:!1},N=null,z&&Y(null),y.style.cursor=e===`rotate`?`grabbing`:`move`},Ze=e=>{let t=K();if(!t)return;let n=Ke(e);if(Q.set(e.pointerId,n),y.setPointerCapture?.(e.pointerId),Q.size===2&&(t.zoom||t.pan)){Xe(`pinch`,Ye().center);return}if(Q.size>1)return;let r=t.pan&&(e.button===2||e.shiftKey||e.button===1);r?Xe(`pan`,n):t.rotate&&e.button===0?Xe(`rotate`,n):Z=null,(r||e.button===1)&&e.preventDefault()},Qe=e=>{let t=Ke(e);if(H=t,Q.has(e.pointerId)&&Q.set(e.pointerId,t),!Z){if(e.pointerType===`touch`&&Q.size)return;(Be()||C.get(`hover`)?.size||C.get(`click`)?.size)&&Ge(t.x,t.y);return}let n=K();if(!n)return;if(Z.mode===`pinch`){let{distance:e,center:t}=Ye(),r=Z.distance>0?e/Z.distance:1,i=qe();$({...Z.start,zoom:n.zoom?Z.start.zoom*r:Z.start.zoom,pan:n.pan?[Z.start.pan[0]+(t.x-Z.origin.x)/i,Z.start.pan[1]+(t.y-Z.origin.y)/i]:Z.start.pan}),Z.moved=!0;return}let r=t.x-Z.origin.x,i=t.y-Z.origin.y;if(!(!Z.moved&&Math.hypot(r,i)<3)){if(Z.moved=!0,Z.mode===`pan`){let e=qe();$({...Z.start,pan:[Z.start.pan[0]+r/e,Z.start.pan[1]+i/e]})}else $({...Z.start,azimuth:Z.start.azimuth-r*ae,elevation:Z.start.elevation+i*ae})}},$e=e=>{let t=Z;if(Q.delete(e.pointerId),y.hasPointerCapture?.(e.pointerId)&&y.releasePointerCapture(e.pointerId),Q.size===1&&t?.mode===`pinch`){let e=[...Q.values()][0];Xe(`rotate`,e);return}if(!Q.size){if(Z=null,y.style.cursor=K()?.rotate?`grab`:`default`,t&&!t.moved&&e.button===0){let t=Ke(e),n=We(t.x,t.y);Y(n),B&&w(`click`,B)}Fe()&&J(!1)}},et=e=>{Q.delete(e.pointerId),Q.size||(Z=null,y.style.cursor=K()?.rotate?`grab`:`default`)},tt=e=>{e.pointerType!==`touch`&&(Ee=!0)},nt=()=>{Ee=!1,V=null,H=null,!Z&&z&&Y(null),Fe()&&J(!1)},rt=e=>{let t=K();if(!t?.zoom)return;let n=e.ctrlKey&&!e.metaKey;if(t.wheel===`modifier`&&!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let r=re(e.deltaY,e.deltaMode,n),i=M.zoom/r,a=L;if(!a){$({...M,zoom:i});return}let o=f.clampCamera({...M,zoom:i}),s=o.zoom/M.zoom,c=a.fit.height,l=a.fit.x+a.fit.width/2+M.pan[0]*c,u=a.fit.y+a.fit.height/2+M.pan[1]*c,d=Ke(e),ee=d.x-s*(d.x-l),p=d.y-s*(d.y-u);$({...o,pan:[M.pan[0]+(ee-l)/c,M.pan[1]+(p-u)/c]}),z&&Y(null)},it=e=>{K()&&(e.preventDefault(),Je(j))},at=e=>{K()?.pan&&e.preventDefault()},ot=()=>{let e;try{e=y.matches(`:focus-visible`)}catch{e=!0}e&&(y.style.boxShadow=`0 0 0 2px var(--primary-color, #4f46e5)`)},st=()=>{y.style.boxShadow=``},ct=e=>{let t=K();if(!t?.keyboard)return;let n=null,r=e.shiftKey?15:oe;switch(e.key){case`ArrowLeft`:t.rotate&&(n={...M,azimuth:M.azimuth+r});break;case`ArrowRight`:t.rotate&&(n={...M,azimuth:M.azimuth-r});break;case`ArrowUp`:t.rotate&&(n={...M,elevation:M.elevation+r});break;case`ArrowDown`:t.rotate&&(n={...M,elevation:M.elevation-r});break;case`+`:case`=`:t.zoom&&(n={...M,zoom:M.zoom*1.2});break;case`-`:case`_`:t.zoom&&(n={...M,zoom:M.zoom/1.2});break;case`0`:case`Home`:e.preventDefault(),Je(j);return;case`Escape`:H=null,z&&(e.preventDefault(),Y(null));return;default:return}n&&(e.preventDefault(),$(n))};y.addEventListener(`pointerdown`,Ze),y.addEventListener(`pointermove`,Qe),y.addEventListener(`pointerup`,$e),y.addEventListener(`pointercancel`,et),y.addEventListener(`pointerenter`,tt),y.addEventListener(`pointerleave`,nt),y.addEventListener(`wheel`,rt,{passive:!1}),y.addEventListener(`dblclick`,it),y.addEventListener(`contextmenu`,at),y.addEventListener(`keydown`,ct),y.addEventListener(`focus`,ot),y.addEventListener(`blur`,st);let lt=typeof ResizeObserver==`function`?new ResizeObserver(()=>{k.reset(),J(!0)}):null;lt?.observe(y);let ut=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{let t=e[e.length-1];if(!t)return;let n=U;U=t.isIntersecting,U&&!n&&J(!0)}):null;ut?.observe(y);let dt=()=>{g.visibilityState!==`hidden`&&J(!1)};g.addEventListener(`visibilitychange`,dt);let ft=null,pt=()=>{mt(),J(!0)},mt=()=>{ft?.removeEventListener?.(`change`,pt),ft=typeof _?.matchMedia==`function`?_.matchMedia(`(resolution: ${_.devicePixelRatio||1}dppx)`):null,ft?.addEventListener?.(`change`,pt)};mt();let ht=()=>J(!1);G?.addEventListener?.(`change`,ht);let gt=()=>{if(S)return;let e=a.readTheme(v.root,b.palette);a.themeColorsChanged(x,e)&&he++,x=e,q()},_t=a.watchTheme(gt),vt=typeof _?.MutationObserver==`function`?new _.MutationObserver(()=>{!S&&t.resolveLocale(b.locale)!==T.locale.locale&&q()}):null;vt?.observe(g.documentElement,{attributes:!0,attributeFilter:[`lang`]});let yt=async(e=new Set)=>{let t=++Se,n=await s.createRenderer3D(b.renderer??`auto`,()=>{let e=c.layerCanvas(g);return e.className=`minerva-chart-data`,e},t=>{S||A?.kind!==t||(A.destroy(),A.canvas.remove(),A=null,yt(new Set([...e,t])))},e);if(S||t!==Se){n?.destroy();return}A&&(A.destroy(),A.canvas.remove()),A=n,O=!0,n?(v.root.dataset.renderer=n.kind,y.insertBefore(n.canvas,v.foreground),w(`renderer`,n.kind)):delete v.root.dataset.renderer,Ce(n?.kind??null),J(!0)};je(),q(),yt();let bt=i.followDefaultRenderer(()=>b.renderer,()=>void yt());return{setOptions(e){if(S)return;let t=b;b=e,(e.palette??[]).join()!==(t.palette??[]).join()&&(x=a.readTheme(v.root,e.palette),he++);let n=JSON.stringify(e.camera??{});n!==Te&&(Te=n,j=ce(e.camera),$({...j})),(e.renderer??`auto`)!==(t.renderer??`auto`)&&yt(),q()},resize(){k.reset(),J(!0)},resetCamera(){$(h(j))},getCamera:()=>h(M),setCamera(e){S||$({azimuth:e.azimuth??M.azimuth,elevation:e.elevation??M.elevation,zoom:e.zoom??M.zoom,pan:e.pan?[e.pan[0],e.pan[1]]:M.pan,projection:e.projection??M.projection})},getRenderer:()=>A?.kind??null,ready:we,refreshTheme:gt,on(e,t){let n=C.get(e);return n||(n=new Set,C.set(e,n)),n.add(t),()=>{n.delete(t)}},destroy(){S||(S=!0,Se++,P&&_?.cancelAnimationFrame(P),X&&_?.cancelAnimationFrame(X),P=0,X=0,lt?.disconnect(),ut?.disconnect(),g.removeEventListener(`visibilitychange`,dt),ft?.removeEventListener?.(`change`,pt),G?.removeEventListener?.(`change`,ht),bt(),_t(),vt?.disconnect(),y.removeEventListener(`pointerdown`,Ze),y.removeEventListener(`pointermove`,Qe),y.removeEventListener(`pointerup`,$e),y.removeEventListener(`pointercancel`,et),y.removeEventListener(`pointerenter`,tt),y.removeEventListener(`pointerleave`,nt),y.removeEventListener(`wheel`,rt),y.removeEventListener(`dblclick`,it),y.removeEventListener(`contextmenu`,at),y.removeEventListener(`keydown`,ct),y.removeEventListener(`focus`,ot),y.removeEventListener(`blur`,st),A?.destroy(),A=null,C.clear(),Ce(null),v.root.remove())}}};function pe(e){return r.luminance(e.background)<.4||r.luminance(e.text)>.6}exports.createChart3D=fe,exports.initialCamera=ce,exports.stageLayout=de;
2
2
  //# sourceMappingURL=chart.cjs.map