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","describeChart","l","interpolate","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;CACxB,GACIwB;CACJ,QAA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AO;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","describeChart","l","interpolate","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,EAA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MnF,KAAOiF,EAAM,MACtB,IAAI,KAAK,IACP/G,IACC8B,EAAI,QAAQ,KAAK,KAChBW,EAAQX,EAAI,MAAMO,EAAK1E,GAAO,EAAE,CAAC,IACjC,KACA8E,EAAQX,EAAI,OAAOO,EAAK1E,GAAO,IAAI,GAAG,CAAC,CAC3C;EAEF,IAAQmJ,EAAW,SAASC,EAAM,KAAK;CACzC;CACA,IAAMM,IAAK,KAAK,IAAI,IAAI,KAAK,KAAKrH,IAAI,KAAc,CAAC,CAAC,GAChDsH,IAAKV,IAAQ,KAAa,IAC1B,EAAE,MAAG,MAAM7B,EACfxD,GACAF,GACA;EAAE,GAAGkG;EAAS,GAAGC;CAAQ,GACzBH,GACAC,GACA9E,GACAE,CACF;CACA,OAAO;EACL;EACA;EACA,OAAO2E;EACP,QAAQC;EACR;EACA;EACA,GAAIT,IAAU;GAAE;GAAS;EAAW,IAAI,CAAC;EACzC,GAAIN,IAAO,EAAE,QAAK,IAAI,CAAC;CACzB;AACF"}
@@ -0,0 +1,2 @@
1
+ var e={side:[`right`,`left`,`bottom`,`top`],vertical:[`top`,`bottom`,`right`,`left`],right:[`right`,`left`,`bottom`,`top`],left:[`left`,`right`,`bottom`,`top`],top:[`top`,`bottom`,`right`,`left`],bottom:[`bottom`,`top`,`right`,`left`]},t=(e,t)=>({x:e.x+t,y:e.y+t,width:Math.max(0,e.width-t*2),height:Math.max(0,e.height-t*2)}),n=(e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,width:Math.max(0,Math.min(e.x+e.width,t.x+t.width)-n),height:Math.max(0,Math.min(e.y+e.height,t.y+t.height)-r)}},r=(e,t)=>{if(!e)return{x:t.x,y:t.y,width:t.width,height:t.height};let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}},i=(e,t)=>{let r=n(e,t);return r.width*r.height},a=(e,t,n,r)=>Math.max(n,Math.min(e,r-t)),o=(e,t,n,r,i)=>t>=e.x-.5&&n>=e.y-.5&&t+r<=e.x+e.width+.5&&n+i<=e.y+e.height+.5,s=s=>{let{anchor:c,prefer:l=`side`,gap:u=12,margin:d=4}=s,{width:f,height:p}=s.size,m={x:c.x,y:c.y,width:0,height:0},h=r(s.avoid??null,m),g={x:0,y:0,width:s.stage.width,height:s.stage.height},_=s.bounds&&s.bounds.width>0&&s.bounds.height>0?t(s.bounds,d):null,v=t(g,d),y=_?n(v,_):v,b=y.width>0&&y.height>0?y:v,x=e[l],S=(e,t)=>{let n,r;if(e===`right`||e===`left`){n=e===`right`?h.x+h.width+u:h.x-u-f,r=c.y-p/2;for(let e of t)r=a(r,p,e.y,e.y+e.height)}else{r=e===`bottom`?h.y+h.height+u:h.y-u-p,n=c.x-f/2;for(let e of t)n=a(n,f,e.x,e.x+e.width)}return{x:n,y:r}};for(let e of x){let t=S(e,[b]);if(o(b,t.x,t.y,f,p))return{...t,fit:`stage`}}if(_){let e=null,t=1/0;for(let n of x){let r=S(n,[b,_]);if(!o(_,r.x,r.y,f,p))continue;let a=i({x:r.x,y:r.y,width:f,height:p},g);a<t-.5&&(e=r,t=a)}if(e)return{...e,fit:`bounds`}}let C={x:b.x,y:b.y},w=1/0;for(let e of _?[b,_]:[b]){let t=[...x.map(t=>S(t,[e])),{x:e.x,y:e.y},{x:e.x+e.width-f,y:e.y},{x:e.x,y:e.y+e.height-p},{x:e.x+e.width-f,y:e.y+e.height-p}];for(let n of t){let t=a(n.x,f,e.x,e.x+e.width),r=a(n.y,p,e.y,e.y+e.height),o=i({x:t,y:r,width:f,height:p},h);o<w-.5&&(C={x:t,y:r},w=o)}}return{...C,fit:`none`}},c=.86;exports.CANVAS_TOOLTIP_ALPHA=c,exports.overlapArea=i,exports.placeTooltip=s,exports.unionRect=r;
2
+ //# sourceMappingURL=tooltip.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.cjs","names":["ORDER","inset","r","m","intersection","x","a","b","y","unionRect","overlapArea","clampSpan","lo","v","hi","len","inside","area","w","h","placeTooltip","input","pointer","anchor","avoid","stageRect","bounds","margin","stageArea","visible","inner","order","prefer","beside","side","gap","areas","p","best","bestCover","cover","spots","s","CANVAS_TOOLTIP_ALPHA"],"sources":["../../../../../../charts/src/engine/tooltip.ts"],"sourcesContent":["// Tooltips of every chart family: the shared translucent look and a\n// placement that keeps the tooltip off what it describes (the hovered marks\n// and the pointer). `placeTooltip` is pure (canvas hosts use it too); the\n// DOM helpers measure the element and may let it overflow the stage.\n\nimport type { Rect } from \"./layout\";\n\nexport interface TooltipSize {\n width: number;\n height: number;\n}\n\n/**\n * Sides tried first: beside the marks (right, then left), above / below\n * them (above first), or one given side then its opposite\n */\nexport type TooltipPrefer =\n \"side\" | \"vertical\" | \"right\" | \"left\" | \"top\" | \"bottom\";\n\nexport interface TooltipPlacementInput {\n /** Pointer or focused point (stage pixels): the tooltip is aligned on it and never covers it */\n anchor: { x: number; y: number };\n /** Box of the hovered marks (stage pixels) the tooltip must not cover */\n avoid?: Rect | null;\n size: TooltipSize;\n stage: TooltipSize;\n /**\n * Area (stage pixels) the tooltip may overflow the stage into when it\n * fits nowhere inside, e.g. the visible part of the viewport\n */\n bounds?: Rect | null;\n prefer?: TooltipPrefer;\n /** Distance between the tooltip and the avoided box */\n gap?: number;\n /** Distance kept from the edges of the stage and of the bounds */\n margin?: number;\n}\n\nexport interface TooltipPlacement {\n /** Top-left corner, stage pixels */\n x: number;\n y: number;\n /**\n * `stage`: inside the stage, off the marks; `bounds`: off the marks,\n * overflowing the stage; `none`: no room off the marks, the spot\n * covering them the least\n */\n fit: \"stage\" | \"bounds\" | \"none\";\n}\n\ntype Side = \"right\" | \"left\" | \"bottom\" | \"top\";\n\nconst ORDER: Record<TooltipPrefer, readonly Side[]> = {\n side: [\"right\", \"left\", \"bottom\", \"top\"],\n vertical: [\"top\", \"bottom\", \"right\", \"left\"],\n right: [\"right\", \"left\", \"bottom\", \"top\"],\n left: [\"left\", \"right\", \"bottom\", \"top\"],\n top: [\"top\", \"bottom\", \"right\", \"left\"],\n bottom: [\"bottom\", \"top\", \"right\", \"left\"],\n};\n\nconst inset = (r: Rect, m: number): Rect => ({\n x: r.x + m,\n y: r.y + m,\n width: Math.max(0, r.width - m * 2),\n height: Math.max(0, r.height - m * 2),\n});\n\nconst intersection = (a: Rect, b: Rect): Rect => {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n return {\n x,\n y,\n width: Math.max(0, Math.min(a.x + a.width, b.x + b.width) - x),\n height: Math.max(0, Math.min(a.y + a.height, b.y + b.height) - y),\n };\n};\n\n/** Smallest rectangle holding both */\nexport const unionRect = (a: Rect | null, b: Rect): Rect => {\n if (!a) return { x: b.x, y: b.y, width: b.width, height: b.height };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return {\n x,\n y,\n width: Math.max(a.x + a.width, b.x + b.width) - x,\n height: Math.max(a.y + a.height, b.y + b.height) - y,\n };\n};\n\n/** Area covered by both rectangles */\nexport const overlapArea = (a: Rect, b: Rect): number => {\n const r = intersection(a, b);\n return r.width * r.height;\n};\n\n/** Start of a `len` long span at `v`, moved into [lo, hi] (at `lo` when longer) */\nconst clampSpan = (v: number, len: number, lo: number, hi: number) =>\n Math.max(lo, Math.min(v, hi - len));\n\n// half a pixel of slack: rounded sizes must not fail the fit\nconst inside = (area: Rect, x: number, y: number, w: number, h: number) =>\n x >= area.x - 0.5 &&\n y >= area.y - 0.5 &&\n x + w <= area.x + area.width + 0.5 &&\n y + h <= area.y + area.height + 0.5;\n\n/**\n * Top-left corner of a tooltip that covers neither the hovered marks\n * (`avoid`) nor the pointer. Candidates sit beside the avoided box, in the\n * order of `prefer`, centered on the pointer across that side and slid\n * into the area. The first one inside the stage wins; else, with `bounds`,\n * the candidate inside the bounds that covers the least of the stage (a\n * tooltip above a tiny sparkline rather than over it); else the clamped\n * spot covering the marks the least.\n */\nexport const placeTooltip = (\n input: TooltipPlacementInput,\n): TooltipPlacement => {\n const { anchor, prefer = \"side\", gap = 12, margin = 4 } = input;\n const { width: w, height: h } = input.size;\n const pointer: Rect = { x: anchor.x, y: anchor.y, width: 0, height: 0 };\n const avoid = unionRect(input.avoid ?? null, pointer);\n const stageRect: Rect = {\n x: 0,\n y: 0,\n width: input.stage.width,\n height: input.stage.height,\n };\n const bounds =\n input.bounds && input.bounds.width > 0 && input.bounds.height > 0\n ? inset(input.bounds, margin)\n : null;\n const stageArea = inset(stageRect, margin);\n const visible = bounds ? intersection(stageArea, bounds) : stageArea;\n // a stage scrolled out of sight keeps its own area\n const inner = visible.width > 0 && visible.height > 0 ? visible : stageArea;\n const order = ORDER[prefer];\n\n const beside = (side: Side, areas: readonly Rect[]) => {\n let x: number;\n let y: number;\n if (side === \"right\" || side === \"left\") {\n x = side === \"right\" ? avoid.x + avoid.width + gap : avoid.x - gap - w;\n y = anchor.y - h / 2;\n for (const r of areas) y = clampSpan(y, h, r.y, r.y + r.height);\n } else {\n y = side === \"bottom\" ? avoid.y + avoid.height + gap : avoid.y - gap - h;\n x = anchor.x - w / 2;\n for (const r of areas) x = clampSpan(x, w, r.x, r.x + r.width);\n }\n return { x, y };\n };\n\n for (const side of order) {\n const p = beside(side, [inner]);\n if (inside(inner, p.x, p.y, w, h)) return { ...p, fit: \"stage\" };\n }\n\n if (bounds) {\n let best: { x: number; y: number } | null = null;\n let bestCover = Infinity;\n for (const side of order) {\n // across the side: inside the stage when it is wide enough\n const p = beside(side, [inner, bounds]);\n if (!inside(bounds, p.x, p.y, w, h)) continue;\n const cover = overlapArea(\n { x: p.x, y: p.y, width: w, height: h },\n stageRect,\n );\n if (cover < bestCover - 0.5) {\n best = p;\n bestCover = cover;\n }\n }\n if (best) return { ...best, fit: \"bounds\" };\n }\n\n // no room off the marks: beside them or in a corner, whichever covers\n // them the least (inside the stage first)\n let best = { x: inner.x, y: inner.y };\n let bestCover = Infinity;\n for (const area of bounds ? [inner, bounds] : [inner]) {\n const spots = [\n ...order.map((side) => beside(side, [area])),\n { x: area.x, y: area.y },\n { x: area.x + area.width - w, y: area.y },\n { x: area.x, y: area.y + area.height - h },\n { x: area.x + area.width - w, y: area.y + area.height - h },\n ];\n for (const s of spots) {\n const x = clampSpan(s.x, w, area.x, area.x + area.width);\n const y = clampSpan(s.y, h, area.y, area.y + area.height);\n const cover = overlapArea({ x, y, width: w, height: h }, avoid);\n if (cover < bestCover - 0.5) {\n best = { x, y };\n bestCover = cover;\n }\n }\n }\n return { ...best, fit: \"none\" };\n};\n\n// ------------------------------------------------------------------- DOM\n\nconst SURFACE = \"var(--surface-elevated-color, var(--background-color, #fff))\";\nconst GLASS = `color-mix(in srgb, ${SURFACE} 80%, transparent)`;\nconst BLUR = \"blur(12px) saturate(160%)\";\n\n/** Transition of the tooltip moves (none when reduced motion is preferred) */\nexport const TOOLTIP_TRANSITION = \"transform 80ms ease-out\";\n\n/** Opacity of the fill of canvas-drawn tooltips (a canvas cannot blur what is below) */\nexport const CANVAS_TOOLTIP_ALPHA = 0.86;\n\n/** Look shared by the tooltips; sizes and type stay with each host */\nconst TOOLTIP_LOOK: Partial<CSSStyleDeclaration> = {\n position: \"absolute\",\n left: \"0\",\n top: \"0\",\n // also overrides the user agent style of a popover (top layer)\n right: \"auto\",\n bottom: \"auto\",\n margin: \"0\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n border:\n \"1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 70%, transparent)\",\n background: SURFACE,\n color: \"var(--text-color, #1f2937)\",\n // the light inner edge reads on dark themes, the shadow on light ones\n boxShadow:\n \"0 12px 32px -8px rgba(15, 23, 42, 0.2), 0 4px 10px -4px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06)\",\n};\n\n/**\n * Styles a tooltip element: translucent over a blurred backdrop where\n * supported. Unsupported inline values are ignored, so the opaque\n * background set first stays on older browsers.\n */\nexport const styleTooltip = <T extends HTMLElement>(\n el: T,\n style: Partial<CSSStyleDeclaration> = {},\n): T => {\n Object.assign(el.style, TOOLTIP_LOOK, style);\n el.style.background = GLASS;\n el.style.backdropFilter = BLUR;\n el.style.setProperty(\"-webkit-backdrop-filter\", BLUR);\n return el;\n};\n\n/** Whether the user prefers reduced motion (false without `matchMedia`) */\nexport const prefersReducedMotion = (\n win: Window | null | undefined,\n): boolean => {\n // typed loosely: the React Native build has no DOM `matchMedia` typings\n const media = (\n win as\n | { matchMedia?: (query: string) => { matches: boolean } | null }\n | null\n | undefined\n )?.matchMedia;\n try {\n return !!media?.call(win, \"(prefers-reduced-motion: reduce)\")?.matches;\n } catch {\n return false;\n }\n};\n\n/** Tooltips currently shown in the top layer (popover) */\nconst promoted = new WeakSet<HTMLElement>();\n\nconst canPromote = (el: HTMLElement) =>\n typeof el.showPopover === \"function\" && typeof el.hidePopover === \"function\";\n\n/**\n * Moves a tooltip into the top layer (out of any clipping ancestor and\n * above the page) or back into its stage; `true` when it moved\n */\nconst setTopLayer = (tip: HTMLElement, top: boolean): boolean => {\n if (top === promoted.has(tip)) return false;\n if (top) {\n if (!canPromote(tip) || !tip.isConnected) return false;\n try {\n tip.setAttribute(\"popover\", \"manual\");\n tip.showPopover();\n } catch {\n tip.removeAttribute(\"popover\");\n return false;\n }\n tip.style.position = \"fixed\";\n promoted.add(tip);\n return true;\n }\n try {\n tip.hidePopover();\n } catch {\n // already closed (e.g. removed from the document)\n }\n tip.removeAttribute(\"popover\");\n tip.style.position = \"absolute\";\n promoted.delete(tip);\n return true;\n};\n\n/** Overflow values clipping the descendants */\nconst CLIPS = /hidden|clip|auto|scroll/;\n\n/**\n * Area (stage pixels) a tooltip of `stage` can be seen in: the viewport,\n * narrowed to the ancestors clipping their overflow unless the tooltip\n * can go to the top layer (`topLayer`)\n */\nexport const tooltipBounds = (\n stage: HTMLElement,\n topLayer: boolean,\n): Rect | null => {\n const doc = stage.ownerDocument;\n const win = doc.defaultView;\n if (!win) return null;\n const origin = stage.getBoundingClientRect();\n const ox = origin.left + stage.clientLeft;\n const oy = origin.top + stage.clientTop;\n let left = 0;\n let top = 0;\n // without the scroll bars\n let right = doc.documentElement.clientWidth || win.innerWidth;\n let bottom = doc.documentElement.clientHeight || win.innerHeight;\n if (!topLayer) {\n // the overflow of <html> and <body> is the viewport's\n for (\n let el: HTMLElement | null = stage;\n el && el !== doc.body && el !== doc.documentElement;\n el = el.parentElement\n ) {\n const cs = win.getComputedStyle(el);\n if (!CLIPS.test(`${cs.overflowX} ${cs.overflowY}`)) continue;\n const r = el.getBoundingClientRect();\n const l = r.left + el.clientLeft;\n const t = r.top + el.clientTop;\n left = Math.max(left, l);\n top = Math.max(top, t);\n right = Math.min(right, l + el.clientWidth);\n bottom = Math.min(bottom, t + el.clientHeight);\n }\n }\n return {\n x: left - ox,\n y: top - oy,\n width: Math.max(0, right - left),\n height: Math.max(0, bottom - top),\n };\n};\n\nexport interface TooltipElementOptions {\n /** Size of the tooltip, measured on the element by default */\n size?: TooltipSize;\n /** Size of the stage, its client size by default */\n stage?: TooltipSize;\n /** Animates the moves, unless the user prefers reduced motion */\n animate?: boolean;\n}\n\n/**\n * Places a shown tooltip (a child of `stage`) with `place`, called with\n * the bounds it may overflow into only when it fits nowhere inside the\n * stage. A tooltip leaving the stage goes to the top layer where the\n * Popover API exists (its ancestors may clip it); elsewhere the bounds\n * stop at the clipping ancestors.\n */\nexport const placeTooltipElement = (\n tip: HTMLElement,\n stage: HTMLElement,\n place: (\n size: TooltipSize,\n stage: TooltipSize,\n bounds: Rect | null,\n ) => TooltipPlacement,\n options: TooltipElementOptions = {},\n): TooltipPlacement => {\n const size = options.size ?? {\n width: tip.offsetWidth,\n height: tip.offsetHeight,\n };\n const area = options.stage ?? {\n width: stage.clientWidth,\n height: stage.clientHeight,\n };\n const topLayer = canPromote(tip);\n let p = place(size, area, null);\n if (p.fit !== \"stage\") {\n const bounds = tooltipBounds(stage, topLayer);\n if (bounds) p = place(size, area, bounds);\n }\n const outside =\n p.x < 0 ||\n p.y < 0 ||\n p.x + size.width > area.width ||\n p.y + size.height > area.height;\n const moved = setTopLayer(tip, outside && topLayer);\n let { x, y } = p;\n if (promoted.has(tip)) {\n // fixed in the top layer: viewport pixels\n const r = stage.getBoundingClientRect();\n x += r.left + stage.clientLeft;\n y += r.top + stage.clientTop;\n }\n if (options.animate) {\n const win = stage.ownerDocument.defaultView;\n tip.style.transition =\n moved || prefersReducedMotion(win) ? \"none\" : TOOLTIP_TRANSITION;\n }\n tip.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;\n return p;\n};\n\nexport interface TooltipElementPlacement\n extends\n Omit<TooltipPlacementInput, \"size\" | \"stage\" | \"bounds\">,\n TooltipElementOptions {}\n\n/** Places a shown tooltip off the hovered marks (see `placeTooltip`) */\nexport const positionTooltip = (\n tip: HTMLElement,\n stage: HTMLElement,\n input: TooltipElementPlacement,\n): TooltipPlacement =>\n placeTooltipElement(\n tip,\n stage,\n (size, area, bounds) =>\n placeTooltip({ ...input, size, stage: area, bounds }),\n input,\n );\n"],"mappings":"AAoDA,IAAMA,EAAgD,CACpD,KAAM,CAAC,QAAS,OAAQ,SAAU,KAAK,EACvC,SAAU,CAAC,MAAO,SAAU,QAAS,MAAM,EAC3C,MAAO,CAAC,QAAS,OAAQ,SAAU,KAAK,EACxC,KAAM,CAAC,OAAQ,QAAS,SAAU,KAAK,EACvC,IAAK,CAAC,MAAO,SAAU,QAAS,MAAM,EACtC,OAAQ,CAAC,SAAU,MAAO,QAAS,MAAM,CAC3C,EAEMC,GAAS,EAAS,KAAqB,CAC3C,EAAGC,EAAE,EAAIC,EACT,EAAGD,EAAE,EAAIC,EACT,MAAO,KAAK,IAAI,EAAGD,EAAE,MAAQC,EAAI,CAAC,EAClC,OAAQ,KAAK,IAAI,EAAGD,EAAE,OAASC,EAAI,CAAC,CACtC,GAEMC,GAAgB,EAAS,IAAkB,CAC/C,IAAMC,EAAI,KAAK,IAAIC,EAAE,EAAGC,EAAE,CAAC,EACrBC,EAAI,KAAK,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,EAAGvB,EAAGF,EAAK,EAAGA,EAAK,EAAIA,EAAK,MAAM,EAClDuB,EAAQ9B,EAAY,CAAE,IAAG,IAAG,MAAOQ,EAAG,OAAQC,CAAE,EAAGK,CAAK,EAC1DgB,EAAQD,EAAY,KACtB,EAAO,CAAE,IAAG,GAAE,EACd,EAAYC,EAEhB,CACF,CACA,MAAO,CAAE,GAAGF,EAAM,IAAK,MAAO,CAChC,EAYaK,EAAuB"}
@@ -0,0 +1,164 @@
1
+ //#region ../charts/src/engine/tooltip.ts
2
+ var e = {
3
+ side: [
4
+ "right",
5
+ "left",
6
+ "bottom",
7
+ "top"
8
+ ],
9
+ vertical: [
10
+ "top",
11
+ "bottom",
12
+ "right",
13
+ "left"
14
+ ],
15
+ right: [
16
+ "right",
17
+ "left",
18
+ "bottom",
19
+ "top"
20
+ ],
21
+ left: [
22
+ "left",
23
+ "right",
24
+ "bottom",
25
+ "top"
26
+ ],
27
+ top: [
28
+ "top",
29
+ "bottom",
30
+ "right",
31
+ "left"
32
+ ],
33
+ bottom: [
34
+ "bottom",
35
+ "top",
36
+ "right",
37
+ "left"
38
+ ]
39
+ }, t = (e, t) => ({
40
+ x: e.x + t,
41
+ y: e.y + t,
42
+ width: Math.max(0, e.width - t * 2),
43
+ height: Math.max(0, e.height - t * 2)
44
+ }), n = (e, t) => {
45
+ let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y);
46
+ return {
47
+ x: n,
48
+ y: r,
49
+ width: Math.max(0, Math.min(e.x + e.width, t.x + t.width) - n),
50
+ height: Math.max(0, Math.min(e.y + e.height, t.y + t.height) - r)
51
+ };
52
+ }, r = (e, t) => {
53
+ if (!e) return {
54
+ x: t.x,
55
+ y: t.y,
56
+ width: t.width,
57
+ height: t.height
58
+ };
59
+ let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y);
60
+ return {
61
+ x: n,
62
+ y: r,
63
+ width: Math.max(e.x + e.width, t.x + t.width) - n,
64
+ height: Math.max(e.y + e.height, t.y + t.height) - r
65
+ };
66
+ }, i = (e, t) => {
67
+ let r = n(e, t);
68
+ return r.width * r.height;
69
+ }, a = (e, t, n, r) => Math.max(n, Math.min(e, r - t)), o = (e, t, n, r, i) => t >= e.x - .5 && n >= e.y - .5 && t + r <= e.x + e.width + .5 && n + i <= e.y + e.height + .5, s = (s) => {
70
+ let { anchor: c, prefer: l = "side", gap: u = 12, margin: d = 4 } = s, { width: f, height: p } = s.size, m = {
71
+ x: c.x,
72
+ y: c.y,
73
+ width: 0,
74
+ height: 0
75
+ }, h = r(s.avoid ?? null, m), g = {
76
+ x: 0,
77
+ y: 0,
78
+ width: s.stage.width,
79
+ height: s.stage.height
80
+ }, _ = s.bounds && s.bounds.width > 0 && s.bounds.height > 0 ? t(s.bounds, d) : null, v = t(g, d), y = _ ? n(v, _) : v, b = y.width > 0 && y.height > 0 ? y : v, x = e[l], S = (e, t) => {
81
+ let n, r;
82
+ if (e === "right" || e === "left") {
83
+ n = e === "right" ? h.x + h.width + u : h.x - u - f, r = c.y - p / 2;
84
+ for (let e of t) r = a(r, p, e.y, e.y + e.height);
85
+ } else {
86
+ r = e === "bottom" ? h.y + h.height + u : h.y - u - p, n = c.x - f / 2;
87
+ for (let e of t) n = a(n, f, e.x, e.x + e.width);
88
+ }
89
+ return {
90
+ x: n,
91
+ y: r
92
+ };
93
+ };
94
+ for (let e of x) {
95
+ let t = S(e, [b]);
96
+ if (o(b, t.x, t.y, f, p)) return {
97
+ ...t,
98
+ fit: "stage"
99
+ };
100
+ }
101
+ if (_) {
102
+ let e = null, t = Infinity;
103
+ for (let n of x) {
104
+ let r = S(n, [b, _]);
105
+ if (!o(_, r.x, r.y, f, p)) continue;
106
+ let a = i({
107
+ x: r.x,
108
+ y: r.y,
109
+ width: f,
110
+ height: p
111
+ }, g);
112
+ a < t - .5 && (e = r, t = a);
113
+ }
114
+ if (e) return {
115
+ ...e,
116
+ fit: "bounds"
117
+ };
118
+ }
119
+ let C = {
120
+ x: b.x,
121
+ y: b.y
122
+ }, w = Infinity;
123
+ for (let e of _ ? [b, _] : [b]) {
124
+ let t = [
125
+ ...x.map((t) => S(t, [e])),
126
+ {
127
+ x: e.x,
128
+ y: e.y
129
+ },
130
+ {
131
+ x: e.x + e.width - f,
132
+ y: e.y
133
+ },
134
+ {
135
+ x: e.x,
136
+ y: e.y + e.height - p
137
+ },
138
+ {
139
+ x: e.x + e.width - f,
140
+ y: e.y + e.height - p
141
+ }
142
+ ];
143
+ for (let n of t) {
144
+ let t = a(n.x, f, e.x, e.x + e.width), r = a(n.y, p, e.y, e.y + e.height), o = i({
145
+ x: t,
146
+ y: r,
147
+ width: f,
148
+ height: p
149
+ }, h);
150
+ o < w - .5 && (C = {
151
+ x: t,
152
+ y: r
153
+ }, w = o);
154
+ }
155
+ }
156
+ return {
157
+ ...C,
158
+ fit: "none"
159
+ };
160
+ }, c = .86;
161
+ //#endregion
162
+ export { c as CANVAS_TOOLTIP_ALPHA, i as overlapArea, s as placeTooltip, r as unionRect };
163
+
164
+ //# sourceMappingURL=tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.js","names":["ORDER","inset","r","m","intersection","x","a","b","y","unionRect","overlapArea","clampSpan","lo","v","hi","len","inside","area","w","h","placeTooltip","input","pointer","anchor","avoid","stageRect","bounds","margin","stageArea","visible","inner","order","prefer","beside","side","gap","areas","p","best","bestCover","cover","spots","s","CANVAS_TOOLTIP_ALPHA"],"sources":["../../../../../../charts/src/engine/tooltip.ts"],"sourcesContent":["// Tooltips of every chart family: the shared translucent look and a\n// placement that keeps the tooltip off what it describes (the hovered marks\n// and the pointer). `placeTooltip` is pure (canvas hosts use it too); the\n// DOM helpers measure the element and may let it overflow the stage.\n\nimport type { Rect } from \"./layout\";\n\nexport interface TooltipSize {\n width: number;\n height: number;\n}\n\n/**\n * Sides tried first: beside the marks (right, then left), above / below\n * them (above first), or one given side then its opposite\n */\nexport type TooltipPrefer =\n \"side\" | \"vertical\" | \"right\" | \"left\" | \"top\" | \"bottom\";\n\nexport interface TooltipPlacementInput {\n /** Pointer or focused point (stage pixels): the tooltip is aligned on it and never covers it */\n anchor: { x: number; y: number };\n /** Box of the hovered marks (stage pixels) the tooltip must not cover */\n avoid?: Rect | null;\n size: TooltipSize;\n stage: TooltipSize;\n /**\n * Area (stage pixels) the tooltip may overflow the stage into when it\n * fits nowhere inside, e.g. the visible part of the viewport\n */\n bounds?: Rect | null;\n prefer?: TooltipPrefer;\n /** Distance between the tooltip and the avoided box */\n gap?: number;\n /** Distance kept from the edges of the stage and of the bounds */\n margin?: number;\n}\n\nexport interface TooltipPlacement {\n /** Top-left corner, stage pixels */\n x: number;\n y: number;\n /**\n * `stage`: inside the stage, off the marks; `bounds`: off the marks,\n * overflowing the stage; `none`: no room off the marks, the spot\n * covering them the least\n */\n fit: \"stage\" | \"bounds\" | \"none\";\n}\n\ntype Side = \"right\" | \"left\" | \"bottom\" | \"top\";\n\nconst ORDER: Record<TooltipPrefer, readonly Side[]> = {\n side: [\"right\", \"left\", \"bottom\", \"top\"],\n vertical: [\"top\", \"bottom\", \"right\", \"left\"],\n right: [\"right\", \"left\", \"bottom\", \"top\"],\n left: [\"left\", \"right\", \"bottom\", \"top\"],\n top: [\"top\", \"bottom\", \"right\", \"left\"],\n bottom: [\"bottom\", \"top\", \"right\", \"left\"],\n};\n\nconst inset = (r: Rect, m: number): Rect => ({\n x: r.x + m,\n y: r.y + m,\n width: Math.max(0, r.width - m * 2),\n height: Math.max(0, r.height - m * 2),\n});\n\nconst intersection = (a: Rect, b: Rect): Rect => {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n return {\n x,\n y,\n width: Math.max(0, Math.min(a.x + a.width, b.x + b.width) - x),\n height: Math.max(0, Math.min(a.y + a.height, b.y + b.height) - y),\n };\n};\n\n/** Smallest rectangle holding both */\nexport const unionRect = (a: Rect | null, b: Rect): Rect => {\n if (!a) return { x: b.x, y: b.y, width: b.width, height: b.height };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return {\n x,\n y,\n width: Math.max(a.x + a.width, b.x + b.width) - x,\n height: Math.max(a.y + a.height, b.y + b.height) - y,\n };\n};\n\n/** Area covered by both rectangles */\nexport const overlapArea = (a: Rect, b: Rect): number => {\n const r = intersection(a, b);\n return r.width * r.height;\n};\n\n/** Start of a `len` long span at `v`, moved into [lo, hi] (at `lo` when longer) */\nconst clampSpan = (v: number, len: number, lo: number, hi: number) =>\n Math.max(lo, Math.min(v, hi - len));\n\n// half a pixel of slack: rounded sizes must not fail the fit\nconst inside = (area: Rect, x: number, y: number, w: number, h: number) =>\n x >= area.x - 0.5 &&\n y >= area.y - 0.5 &&\n x + w <= area.x + area.width + 0.5 &&\n y + h <= area.y + area.height + 0.5;\n\n/**\n * Top-left corner of a tooltip that covers neither the hovered marks\n * (`avoid`) nor the pointer. Candidates sit beside the avoided box, in the\n * order of `prefer`, centered on the pointer across that side and slid\n * into the area. The first one inside the stage wins; else, with `bounds`,\n * the candidate inside the bounds that covers the least of the stage (a\n * tooltip above a tiny sparkline rather than over it); else the clamped\n * spot covering the marks the least.\n */\nexport const placeTooltip = (\n input: TooltipPlacementInput,\n): TooltipPlacement => {\n const { anchor, prefer = \"side\", gap = 12, margin = 4 } = input;\n const { width: w, height: h } = input.size;\n const pointer: Rect = { x: anchor.x, y: anchor.y, width: 0, height: 0 };\n const avoid = unionRect(input.avoid ?? null, pointer);\n const stageRect: Rect = {\n x: 0,\n y: 0,\n width: input.stage.width,\n height: input.stage.height,\n };\n const bounds =\n input.bounds && input.bounds.width > 0 && input.bounds.height > 0\n ? inset(input.bounds, margin)\n : null;\n const stageArea = inset(stageRect, margin);\n const visible = bounds ? intersection(stageArea, bounds) : stageArea;\n // a stage scrolled out of sight keeps its own area\n const inner = visible.width > 0 && visible.height > 0 ? visible : stageArea;\n const order = ORDER[prefer];\n\n const beside = (side: Side, areas: readonly Rect[]) => {\n let x: number;\n let y: number;\n if (side === \"right\" || side === \"left\") {\n x = side === \"right\" ? avoid.x + avoid.width + gap : avoid.x - gap - w;\n y = anchor.y - h / 2;\n for (const r of areas) y = clampSpan(y, h, r.y, r.y + r.height);\n } else {\n y = side === \"bottom\" ? avoid.y + avoid.height + gap : avoid.y - gap - h;\n x = anchor.x - w / 2;\n for (const r of areas) x = clampSpan(x, w, r.x, r.x + r.width);\n }\n return { x, y };\n };\n\n for (const side of order) {\n const p = beside(side, [inner]);\n if (inside(inner, p.x, p.y, w, h)) return { ...p, fit: \"stage\" };\n }\n\n if (bounds) {\n let best: { x: number; y: number } | null = null;\n let bestCover = Infinity;\n for (const side of order) {\n // across the side: inside the stage when it is wide enough\n const p = beside(side, [inner, bounds]);\n if (!inside(bounds, p.x, p.y, w, h)) continue;\n const cover = overlapArea(\n { x: p.x, y: p.y, width: w, height: h },\n stageRect,\n );\n if (cover < bestCover - 0.5) {\n best = p;\n bestCover = cover;\n }\n }\n if (best) return { ...best, fit: \"bounds\" };\n }\n\n // no room off the marks: beside them or in a corner, whichever covers\n // them the least (inside the stage first)\n let best = { x: inner.x, y: inner.y };\n let bestCover = Infinity;\n for (const area of bounds ? [inner, bounds] : [inner]) {\n const spots = [\n ...order.map((side) => beside(side, [area])),\n { x: area.x, y: area.y },\n { x: area.x + area.width - w, y: area.y },\n { x: area.x, y: area.y + area.height - h },\n { x: area.x + area.width - w, y: area.y + area.height - h },\n ];\n for (const s of spots) {\n const x = clampSpan(s.x, w, area.x, area.x + area.width);\n const y = clampSpan(s.y, h, area.y, area.y + area.height);\n const cover = overlapArea({ x, y, width: w, height: h }, avoid);\n if (cover < bestCover - 0.5) {\n best = { x, y };\n bestCover = cover;\n }\n }\n }\n return { ...best, fit: \"none\" };\n};\n\n// ------------------------------------------------------------------- DOM\n\nconst SURFACE = \"var(--surface-elevated-color, var(--background-color, #fff))\";\nconst GLASS = `color-mix(in srgb, ${SURFACE} 80%, transparent)`;\nconst BLUR = \"blur(12px) saturate(160%)\";\n\n/** Transition of the tooltip moves (none when reduced motion is preferred) */\nexport const TOOLTIP_TRANSITION = \"transform 80ms ease-out\";\n\n/** Opacity of the fill of canvas-drawn tooltips (a canvas cannot blur what is below) */\nexport const CANVAS_TOOLTIP_ALPHA = 0.86;\n\n/** Look shared by the tooltips; sizes and type stay with each host */\nconst TOOLTIP_LOOK: Partial<CSSStyleDeclaration> = {\n position: \"absolute\",\n left: \"0\",\n top: \"0\",\n // also overrides the user agent style of a popover (top layer)\n right: \"auto\",\n bottom: \"auto\",\n margin: \"0\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n border:\n \"1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 70%, transparent)\",\n background: SURFACE,\n color: \"var(--text-color, #1f2937)\",\n // the light inner edge reads on dark themes, the shadow on light ones\n boxShadow:\n \"0 12px 32px -8px rgba(15, 23, 42, 0.2), 0 4px 10px -4px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06)\",\n};\n\n/**\n * Styles a tooltip element: translucent over a blurred backdrop where\n * supported. Unsupported inline values are ignored, so the opaque\n * background set first stays on older browsers.\n */\nexport const styleTooltip = <T extends HTMLElement>(\n el: T,\n style: Partial<CSSStyleDeclaration> = {},\n): T => {\n Object.assign(el.style, TOOLTIP_LOOK, style);\n el.style.background = GLASS;\n el.style.backdropFilter = BLUR;\n el.style.setProperty(\"-webkit-backdrop-filter\", BLUR);\n return el;\n};\n\n/** Whether the user prefers reduced motion (false without `matchMedia`) */\nexport const prefersReducedMotion = (\n win: Window | null | undefined,\n): boolean => {\n // typed loosely: the React Native build has no DOM `matchMedia` typings\n const media = (\n win as\n | { matchMedia?: (query: string) => { matches: boolean } | null }\n | null\n | undefined\n )?.matchMedia;\n try {\n return !!media?.call(win, \"(prefers-reduced-motion: reduce)\")?.matches;\n } catch {\n return false;\n }\n};\n\n/** Tooltips currently shown in the top layer (popover) */\nconst promoted = new WeakSet<HTMLElement>();\n\nconst canPromote = (el: HTMLElement) =>\n typeof el.showPopover === \"function\" && typeof el.hidePopover === \"function\";\n\n/**\n * Moves a tooltip into the top layer (out of any clipping ancestor and\n * above the page) or back into its stage; `true` when it moved\n */\nconst setTopLayer = (tip: HTMLElement, top: boolean): boolean => {\n if (top === promoted.has(tip)) return false;\n if (top) {\n if (!canPromote(tip) || !tip.isConnected) return false;\n try {\n tip.setAttribute(\"popover\", \"manual\");\n tip.showPopover();\n } catch {\n tip.removeAttribute(\"popover\");\n return false;\n }\n tip.style.position = \"fixed\";\n promoted.add(tip);\n return true;\n }\n try {\n tip.hidePopover();\n } catch {\n // already closed (e.g. removed from the document)\n }\n tip.removeAttribute(\"popover\");\n tip.style.position = \"absolute\";\n promoted.delete(tip);\n return true;\n};\n\n/** Overflow values clipping the descendants */\nconst CLIPS = /hidden|clip|auto|scroll/;\n\n/**\n * Area (stage pixels) a tooltip of `stage` can be seen in: the viewport,\n * narrowed to the ancestors clipping their overflow unless the tooltip\n * can go to the top layer (`topLayer`)\n */\nexport const tooltipBounds = (\n stage: HTMLElement,\n topLayer: boolean,\n): Rect | null => {\n const doc = stage.ownerDocument;\n const win = doc.defaultView;\n if (!win) return null;\n const origin = stage.getBoundingClientRect();\n const ox = origin.left + stage.clientLeft;\n const oy = origin.top + stage.clientTop;\n let left = 0;\n let top = 0;\n // without the scroll bars\n let right = doc.documentElement.clientWidth || win.innerWidth;\n let bottom = doc.documentElement.clientHeight || win.innerHeight;\n if (!topLayer) {\n // the overflow of <html> and <body> is the viewport's\n for (\n let el: HTMLElement | null = stage;\n el && el !== doc.body && el !== doc.documentElement;\n el = el.parentElement\n ) {\n const cs = win.getComputedStyle(el);\n if (!CLIPS.test(`${cs.overflowX} ${cs.overflowY}`)) continue;\n const r = el.getBoundingClientRect();\n const l = r.left + el.clientLeft;\n const t = r.top + el.clientTop;\n left = Math.max(left, l);\n top = Math.max(top, t);\n right = Math.min(right, l + el.clientWidth);\n bottom = Math.min(bottom, t + el.clientHeight);\n }\n }\n return {\n x: left - ox,\n y: top - oy,\n width: Math.max(0, right - left),\n height: Math.max(0, bottom - top),\n };\n};\n\nexport interface TooltipElementOptions {\n /** Size of the tooltip, measured on the element by default */\n size?: TooltipSize;\n /** Size of the stage, its client size by default */\n stage?: TooltipSize;\n /** Animates the moves, unless the user prefers reduced motion */\n animate?: boolean;\n}\n\n/**\n * Places a shown tooltip (a child of `stage`) with `place`, called with\n * the bounds it may overflow into only when it fits nowhere inside the\n * stage. A tooltip leaving the stage goes to the top layer where the\n * Popover API exists (its ancestors may clip it); elsewhere the bounds\n * stop at the clipping ancestors.\n */\nexport const placeTooltipElement = (\n tip: HTMLElement,\n stage: HTMLElement,\n place: (\n size: TooltipSize,\n stage: TooltipSize,\n bounds: Rect | null,\n ) => TooltipPlacement,\n options: TooltipElementOptions = {},\n): TooltipPlacement => {\n const size = options.size ?? {\n width: tip.offsetWidth,\n height: tip.offsetHeight,\n };\n const area = options.stage ?? {\n width: stage.clientWidth,\n height: stage.clientHeight,\n };\n const topLayer = canPromote(tip);\n let p = place(size, area, null);\n if (p.fit !== \"stage\") {\n const bounds = tooltipBounds(stage, topLayer);\n if (bounds) p = place(size, area, bounds);\n }\n const outside =\n p.x < 0 ||\n p.y < 0 ||\n p.x + size.width > area.width ||\n p.y + size.height > area.height;\n const moved = setTopLayer(tip, outside && topLayer);\n let { x, y } = p;\n if (promoted.has(tip)) {\n // fixed in the top layer: viewport pixels\n const r = stage.getBoundingClientRect();\n x += r.left + stage.clientLeft;\n y += r.top + stage.clientTop;\n }\n if (options.animate) {\n const win = stage.ownerDocument.defaultView;\n tip.style.transition =\n moved || prefersReducedMotion(win) ? \"none\" : TOOLTIP_TRANSITION;\n }\n tip.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;\n return p;\n};\n\nexport interface TooltipElementPlacement\n extends\n Omit<TooltipPlacementInput, \"size\" | \"stage\" | \"bounds\">,\n TooltipElementOptions {}\n\n/** Places a shown tooltip off the hovered marks (see `placeTooltip`) */\nexport const positionTooltip = (\n tip: HTMLElement,\n stage: HTMLElement,\n input: TooltipElementPlacement,\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AGA;GAAM,KAAK;EAAS;CAC5C;CAIA,IAAIA,IAAO;EAAE,GAAGR,EAAM;EAAG,GAAGA,EAAM;CAAE,GAChCS,IAAY;CAChB,KAAK,IAAMtB,KAAQS,IAAS,CAACI,GAAOJ,CAAM,IAAI,CAACI,CAAK,GAAG;EACrD,IAAMW,IAAQ;GACZ,GAAGV,EAAM,KAAK,MAASE,EAAOC,GAAM,CAACjB,CAAI,CAAC,CAAC;GAC3C;IAAE,GAAGA,EAAK;IAAG,GAAGA,EAAK;GAAE;GACvB;IAAE,GAAGA,EAAK,IAAIA,EAAK,QAAQC;IAAG,GAAGD,EAAK;GAAE;GACxC;IAAE,GAAGA,EAAK;IAAG,GAAGA,EAAK,IAAIA,EAAK,SAASE;GAAE;GACzC;IAAE,GAAGF,EAAK,IAAIA,EAAK,QAAQC;IAAG,GAAGD,EAAK,IAAIA,EAAK,SAASE;GAAE;EAC5D;EACA,KAAK,IAAMuB,KAAKD,GAAO;GACrB,IAAMpC,IAAIM,EAAU+B,EAAE,GAAGxB,GAAGD,EAAK,GAAGA,EAAK,IAAIA,EAAK,KAAK,GACjDT,IAAIG,EAAU+B,EAAE,GAAGvB,GAAGF,EAAK,GAAGA,EAAK,IAAIA,EAAK,MAAM,GAClDuB,IAAQ9B,EAAY;IAAE;IAAG;IAAG,OAAOQ;IAAG,QAAQC;GAAE,GAAGK,CAAK;GAC9D,AAAIgB,IAAQD,IAAY,OACtB,IAAO;IAAE;IAAG;GAAE,GACd,IAAYC;EAEhB;CACF;CACA,OAAO;EAAE,GAAGF;EAAM,KAAK;CAAO;AAChC,GAYaK,IAAuB"}
@@ -1,2 +1,2 @@
1
- const e=require("../../internal/parts.cjs"),t=require("../../charts/src/engine/color.cjs"),n=require("../../charts/src/engine/overlay.cjs"),r=require("../../charts/src/engine/controller.cjs");require("../../charts/src/canvas.cjs");const i=require("./measure.cjs");let a=require("react-native"),o=require("react/jsx-runtime");var s={linePoints:1200,dotsPerSeries:800,dots:2e3,barsPerSeries:600,bars:1500,areaColumns:200,dashes:200},c=`chart`,l=e=>Math.ceil(e*1.35),u=(e,t)=>Math.ceil(i.measureChartText(e,`${t.weight??400} ${t.size}px sans-serif`)*1.4+t.size*2);function d(e,t,n,r,i,s,c,d,f){let p=l(c.size),m=(p-c.size)/2,h=u(t,c),g=s===`top`?r-m:s===`bottom`?r-p+m:r-p/2,_=i===`left`?{left:n,width:h}:i===`right`?{right:d-n,width:h}:{left:n-h/2,width:h};return(0,o.jsx)(a.Text,{numberOfLines:1,style:[{position:`absolute`,top:g,..._,textAlign:i,fontSize:c.size,lineHeight:p,color:c.color,fontWeight:String(c.weight??400),includeFontPadding:!1,...c.family?{fontFamily:c.family}:null,...c.halo?{textShadowColor:c.halo,textShadowRadius:3,textShadowOffset:{width:0,height:0}}:null},f],children:t},e)}var f=(e,t,n,r,i,s,c)=>(0,o.jsx)(a.View,{style:[{position:`absolute`,left:t,top:n,width:r,height:i,backgroundColor:s},c]},e),p=(e,t,n,r,i,a)=>f(e,t-r/2,n-r/2,r,r,i,{borderRadius:r/2,...a}),m=(e,t,n,r,i,a,o)=>{let s=r-t,c=i-n,l=Math.hypot(s,c)+a;return f(e,(t+r)/2-l/2,(n+i)/2-a/2,l,a,o,{borderRadius:a/2,transform:[{rotate:`${Math.atan2(c,s)}rad`}]})};function h(e,t,n=s.dashes){let r=t.filter(e=>Number.isFinite(e)&&e>=0);r.length%2&&(r=[...r,...r]);let i=r.reduce((e,t)=>e+t,0);if(!r.length||i<=0)return[[0,e]];let a=e/i*(r.length/2),o=a>n?a/n:1,c=[],l=0;for(let t=0;l<e;t=(t+1)%r.length){let n=r[t]*o;t%2==0&&n>0&&c.push([l,Math.min(n,e-l)]),l+=Math.max(n,.5)}return c}var g=(e,t,n,r,i,a,o,s)=>h(i,s).map(([i,s],c)=>t===`y`?f(`${e}-${c}`,r+i,n,s,a,o):f(`${e}-${c}`,n,r+i,a,s,o)),_=(e,t=1)=>Math.round(e)+.5-t/2,v=(e,t,n,r)=>{let i=[],s=t.width,c=t.points;for(let a=1;a<c.length;a++){let o=c[a-1],l=c[a],u=Math.min(o.x,l.x)-n,d=Math.min(o.y,l.y)-r;i.push(o.y===l.y?f(`${e}-${a}`,u-s/2,d-s/2,Math.abs(l.x-o.x)+s,s,t.color):f(`${e}-${a}`,u-s/2,d-s/2,s,Math.abs(l.y-o.y)+s,t.color))}let[l,u,d]=t.head,p=Math.hypot(l.x-(u.x+d.x)/2,l.y-(u.y+d.y)/2),m=Math.hypot(d.x-u.x,d.y-u.y)/2,h=`transparent`,g={position:`absolute`,width:0,height:0},_=(u.x+d.x)/2,v=(u.y+d.y)/2;if(Math.abs(l.x-_)>=Math.abs(l.y-v)){let e=l.x>_;Object.assign(g,{left:(e?_:l.x)-n,top:l.y-m-r,borderTopWidth:m,borderBottomWidth:m,borderTopColor:h,borderBottomColor:h,...e?{borderLeftWidth:p,borderLeftColor:t.color}:{borderRightWidth:p,borderRightColor:t.color}})}else{let e=l.y>v;Object.assign(g,{left:l.x-m-n,top:(e?v:l.y)-r,borderLeftWidth:m,borderRightWidth:m,borderLeftColor:h,borderRightColor:h,...e?{borderTopWidth:p,borderTopColor:t.color}:{borderBottomWidth:p,borderBottomColor:t.color}})}return i.push((0,o.jsx)(a.View,{style:g},`${e}-head`)),i};function y(e,t){let n=e.length/2,r=n>t?Math.ceil(n/t):1,i=[];for(let t=0;t<n;t+=r){let n=e[t*2],r=e[t*2+1],a=i.length;a&&Math.hypot(n-i[a-2],r-i[a-1])<1.5||i.push(n,r)}let a=e[n*2-2],o=e[n*2-1],s=i.length;return n>1&&(i[s-2]!==a||i[s-1]!==o)&&i.push(a,o),i}function b(e,t,n,r,i,a,o,c=!1){let l=c?t.map((e,n)=>t[n%2?n-1:n+1]):t,u=c?{x:a.y,y:a.x,width:a.height,height:a.width}:a,d=l.length/2;if(d<2)return[];let p=l[0]<=l[d*2-2],m=e=>p?e:d-1-e,h=e=>l[m(e)*2],g=e=>l[m(e)*2+1],_=e=>o?o[m(e)]:n,v=Math.max(u.x,h(0)),y=Math.min(u.x+u.width,h(d-1));if(y<=v)return[];let b=Math.max(2,u.width/s.areaColumns),x=[],S=0;for(let t=Math.floor(v),n=0;t<y;n++){let a=Math.min(Math.ceil(y),Math.round(t+b)),o=(t+a)/2;for(;S<d-2&&h(S+1)<o;)S++;let s=h(S),l=h(S+1),p=l===s?0:Math.max(0,Math.min(1,(o-s)/(l-s))),m=g(S)+(g(S+1)-g(S))*p,v=_(S)+(_(S+1)-_(S))*p;if(Number.isFinite(m)&&Number.isFinite(v)){let o=Math.min(m,v),s=Math.abs(v-m);x.push(c?f(`${e}-${n}`,o-u.y,t-u.x,s,a-t,r,{opacity:i}):f(`${e}-${n}`,t-u.x,o-u.y,a-t,s,r,{opacity:i}))}t=a}return x}function x(e){let{plot:t}=e.layout,n=e.model.series.filter(e=>!e.hidden),r=n.filter(e=>e.type===`line`||e.type===`area`).length,i=n.filter(e=>e.type===`scatter`).length,a=Math.max(150,s.linePoints/Math.max(1,r)),o=Math.max(100,Math.min(s.dotsPerSeries,s.dots/Math.max(1,i)));return{perLine:a,options:{columnWidth:Math.max(3,t.width*4/a),maxDots:o,maxBars:s.barsPerSeries,dotCell:Math.max(4,Math.sqrt(t.width*t.height/o)*1.15+1)}}}function S(e){let{plot:t}=e.layout,{perLine:n,options:i}=x(e),a=r.scenePrimitives(e,i),o=t.x,c=t.y,l=[],u=s.dots,d=s.bars;return a.forEach((e,r)=>{let i=`${e.kind}${e.seriesIndex}-${r}`;if(e.kind===`area`){e.segments.forEach((n,r)=>l.push(...b(`${i}-${r}`,n,e.baseline,e.color,e.opacity,t,e.bottoms?.[r],e.horizontal)));return}if(e.kind===`line`){let t=0;for(let n of e.segments)t+=n.length/2;e.segments.forEach((r,a)=>{let s=y(r,Math.max(2,Math.round(n*r.length/2/Math.max(1,t))));if(s.length===2){l.push(p(`${i}-${a}`,s[0]-o,s[1]-c,e.width*1.5,e.color));return}for(let t=0;t+3<s.length;t+=2)l.push(m(`${i}-${a}-${t}`,s[t]-o,s[t+1]-c,s[t+2]-o,s[t+3]-c,e.width,e.color))});return}if(e.kind===`bars`){let t=e.rects.length/4,n=t>d?Math.ceil(t/Math.max(1,d)):1;for(let r=0;r<t;r+=n){let[t,n,a,s]=e.rects.slice(r*4,r*4+4),u=Math.min(e.radius??0,a/2,s/2);l.push(f(`${i}-${r}`,t-o,n-c,Math.max(a,.5),s,e.colors?.[r]??e.color,u>.5||e.opacity!==void 0?{...u>.5?{borderRadius:u}:null,...e.opacity===void 0?null:{opacity:e.opacity}}:void 0))}d=Math.max(0,d-Math.ceil(t/n));return}let a=e.dots.length/3,s=a>u?Math.ceil(a/Math.max(1,u)):1,h=e.stroke??0;for(let t=0;t<a;t+=s){let n=e.colors[t]??`#888`;l.push(p(`${i}-${t}`,e.dots[t*3]-o,e.dots[t*3+1]-c,e.dots[t*3+2],e.opacity>0?n:`transparent`,h>0&&e.opacity<1?{borderWidth:h,borderColor:n,opacity:1}:{opacity:e.opacity}))}u=Math.max(0,u-Math.ceil(a/s))}),l}var C=(e,n)=>t.toCss(e,n);function w(t,r){let{width:s,theme:l,model:u,layout:m,annotations:h}=t,{plot:g,scales:v,y2Ticks:y}=m,b=v.horizontal,x=b?u.y:u.x,S=b?u.x:u.y,w=b?m.yTicks:m.xTicks,T=b?m.xTicks:m.yTicks,E=b?v.yToPx:v.xToPx,D=b?v.xToPx:v.yToPx,O=l.fontSize,k=[];h.forEach((e,t)=>{if(e.type!==`rect`)return;let r=n.rectOf(e,v);r.width<=0||r.height<=0||k.push(f(`area-${t}`,r.x,r.y,r.width,r.height,C(e.color,e.opacity)))});let A=C(l.grid);S.grid&&T.values.forEach((e,t)=>{let n=D(e);n<g.y-1||n>g.y+g.height+1||k.push(f(`ygrid-${t}`,g.x,_(n),g.width,1,A))}),x.grid&&w.values.forEach((e,t)=>{let n=E(e);n<g.x-1||n>g.x+g.width+1||k.push(f(`xgrid-${t}`,_(n),g.y,1,g.height,A))});let j=Math.ceil(O*1.4),M={size:O,color:C(l.textMuted),family:r},N={size:O+1,weight:500,color:C(l.text,.8),family:r},P=g.y+g.height;if(x.visible){k.push(f(`xaxis`,g.x,_(P),g.width,1,C(l.axis)));let e=-1/0;w.values.map((e,t)=>({px:E(e),text:w.labels[t]??``})).sort((e,t)=>e.px-t.px).forEach(({px:t,text:n},r)=>{if(!n||t<g.x-.5||t>g.x+g.width+.5)return;let a=i.measureChartText(n,`400 ${O}px sans-serif`),o=Math.max(0,Math.min(s-a,t-a/2));o<e+6||(e=o+a,k.push(d(`xtick-${r}`,n,o+a/2,P+7,`center`,`top`,M,s)))}),x.title&&k.push(d(`xtitle`,x.title,g.x+g.width/2,P+j+10,`center`,`top`,N,s))}if(S.visible){let e=-1/0;T.values.map((e,t)=>({py:D(e),text:T.labels[t]??``})).sort((e,t)=>e.py-t.py).forEach(({py:t,text:n},r)=>{if(!(!n||t<g.y-.5||t>g.y+g.height+.5)){if(b){if(t-(O+2)/2<e)return;e=t+(O+2)/2}k.push(d(`ytick-${r}`,n,g.x-8,t,`right`,`middle`,M,s))}}),S.title&&k.push(d(`ytitle`,S.title,j/2+4,g.y+g.height/2,`center`,`middle`,N,s,{transform:[{rotate:`-90deg`}]}))}let F=b?null:u.y2;if(F&&y&&F.visible){let e=g.x+g.width;y.values.forEach((t,n)=>{let r=v.yToPx(t),i=y.labels[n];!i||r<g.y-.5||r>g.y+g.height+.5||k.push(d(`y2tick-${n}`,i,e+8,r,`left`,`middle`,M,s))}),F.title&&k.push(d(`y2title`,F.title,s-j/2-4,g.y+g.height/2,`center`,`middle`,N,s,{transform:[{rotate:`90deg`}]}))}let I=t.legend?.colors;if(I){let{bar:t,stops:n}=I,i=t.width/Math.max(1,n.length);k.push((0,o.jsx)(a.View,{...e.part(c,`color-legend`),style:{position:`absolute`,left:t.x,top:t.y,width:t.width,height:t.height,borderRadius:t.height/2,overflow:`hidden`,flexDirection:`row`},children:n.map((e,n)=>(0,o.jsx)(a.View,{style:{width:i,height:t.height,backgroundColor:e}},n))},`color-legend`)),I.ticks.forEach((e,n)=>k.push(f(`color-tick-${n}`,Math.round(e),t.y-2,1,t.height+4,C(l.text,.35)))),I.labels.forEach((e,t)=>k.push(d(`color-label-${t}`,e.text,e.x,e.y,e.align,`middle`,{size:11,color:C(l.textMuted),family:r},s)))}if(t.legend)for(let n of t.legend.entries){let t=n.box.height/2,i=n.shape===`dot`?p(`swatch`,5,t,8,n.color):n.shape===`line`?f(`swatch`,0,t-1,10,2,n.color):f(`swatch`,1,t-4,8,8,n.color);k.push((0,o.jsxs)(a.View,{style:{position:`absolute`,left:n.box.x,top:n.box.y,width:n.box.width,height:n.box.height,opacity:n.hidden?.45:1},...e.part(c,`legend-item`,{hidden:n.hidden}),children:[i,d(`name`,n.name,14,t,`left`,`middle`,{size:12,color:C(l.textMuted),family:r},n.box.width,n.hidden?{textDecorationLine:`line-through`}:void 0)]},`legend-${n.id}`))}return k}function T(e,t){let{theme:r,annotations:a,layout:o}=e,{plot:s,scales:c}=o,l=r.fontSize,u=s.x,p=s.y,m=s.width,h=C(r.background,.9),y=l+4,b=[];e.connectors.forEach((e,t)=>{let n=e.y0===e.y1;b.push(...n?g(`connector-${t}`,`y`,_(e.y0,e.width)-p,Math.min(e.x0,e.x1)-u,Math.abs(e.x1-e.x0),e.width,e.color,e.dash):g(`connector-${t}`,`x`,_(e.x0,e.width)-u,Math.min(e.y0,e.y1)-p,Math.abs(e.y1-e.y0),e.width,e.color,e.dash))}),e.arrows.forEach((e,t)=>{b.push(...v(`arrow-${t}`,e,u,p))}),a.forEach((e,r)=>{if(e.type!==`line`)return;let i=C(e.color),a=n.lineOf(e,c);if(a.vertical){let n=a.at;b.push(...g(`line-${r}`,`x`,_(n,e.width)-u,0,s.height,e.width,i,e.dash)),e.label&&b.push(d(`line-label-${r}`,e.label,n+5-u,5,`left`,`top`,{size:l,weight:500,color:i,halo:h,family:t},m))}else{let n=a.at;b.push(...g(`line-${r}`,`y`,_(n,e.width)-p,0,s.width,e.width,i,e.dash)),e.label&&b.push(d(`line-label-${r}`,e.label,s.width-6,n-3-p,`right`,`bottom`,{size:l,weight:500,color:i,halo:h,family:t},m))}}),a.forEach((e,a)=>{if(e.type!==`rect`)return;let o=n.areaTitleLayout(e,n.rectOf(e,c),l,(e,t,n)=>i.measureChartText(e,`${n} ${t}px sans-serif`));if(!o)return;let s=C(e.labelColor),h=C(r.textMuted);o.parts.forEach((n,r)=>{let i=`area-${n.kind}-${a}-${r}`,o=n.y+n.height/2-p;if(n.kind===`badge`){let r=n.height-2;b.push(f(`${i}-pill`,n.x-u,o-r/2,n.width,r,C(e.labelColor,.16),{borderRadius:r/2}),d(i,n.text,n.x-u+n.width/2,o,`center`,`middle`,{size:n.size,weight:n.weight,color:s,family:t},m));return}b.push(d(n.kind===`label`?`area-label-${a}`:i,n.text,n.x-u,o,`left`,`middle`,{size:n.size,weight:n.weight,color:n.kind===`label`?s:h,family:t},m))})}),a.forEach((e,r)=>{if(e.type!==`text`||!e.text)return;let a=i.measureChartText(e.text,`${e.weight} ${l}px sans-serif`),o=n.textBox(e,c,a,y);b.push(d(`text-${r}`,e.text,o.x-u,o.y+o.height/2-p,`left`,`middle`,{size:l,weight:e.weight,color:C(e.color),halo:h,family:t},m))});let x=C(r.text,.85);return e.pointLabels.forEach(({label:e,box:n},r)=>{let i=e.placement===`inside`?e.bar:void 0;b.push(d(`point-label-${r}`,e.text,n.x-u,n.y+n.height/2-p,`left`,`middle`,e.color?{size:l,color:e.color,family:t}:{size:l,color:x,halo:h,family:t},m,i?{width:Math.max(n.width,i.x+i.width-6-n.x)}:void 0))}),b}var E=e=>({position:`absolute`,left:e.x,top:e.y,width:e.width,height:e.height,overflow:`hidden`});function D(t,n){let{plot:r}=t.layout;return(0,o.jsxs)(o.Fragment,{children:[w(t,n),(0,o.jsx)(a.View,{style:E(r),...e.part(c,`data`),children:S(t)},`data`),(0,o.jsx)(a.View,{style:E(r),...e.part(c,`labels`),children:T(t,n)},`labels`)]})}function O(t,n,r){let{theme:i,layout:s,hover:l,dragging:u}=t,{plot:d}=s,m=C(i.background),h=[];l&&l.crosshairY!==null&&h.push((0,o.jsx)(a.View,{style:a.StyleSheet.absoluteFill,...e.part(c,`crosshair`),children:g(`dash`,`y`,Math.round(l.crosshairY),d.x,d.width,1,C(i.textMuted,.55),[3,3])},`crosshair-y`)),l&&l.crosshairX!==null&&h.push((0,o.jsx)(a.View,{style:a.StyleSheet.absoluteFill,...e.part(c,`crosshair`),children:g(`dash`,`x`,Math.round(l.crosshairX),d.y,d.height,1,C(i.textMuted,.55),[3,3])},`crosshair`)),l?.marks.forEach((e,t)=>{if(e.kind===`band`){h.push(f(`mark-${t}`,e.x,e.y,e.width,e.height,C(i.text,.05),{borderRadius:6}));return}if(e.kind===`guide`){h.push(f(`mark-${t}`,e.x,e.y,e.width,e.height,C(i.text,.06)));return}if(e.kind===`cell`){let n=Math.min(3,e.width*.06,e.height*.06),r=Math.min(2,e.width/5,e.height/5);h.push(f(`mark-${t}`,e.x-n,e.y-n,e.width+n*2,e.height+n*2,e.color,{borderRadius:Math.max(2,e.radius),shadowColor:`#0f172a`,shadowOpacity:.45,shadowRadius:6,shadowOffset:{width:0,height:3},elevation:4})),e.width>8&&e.height>8&&h.push(f(`ring-${t}`,e.x-n+r,e.y-n+r,e.width+(n-r)*2,e.height+(n-r)*2,`transparent`,{borderRadius:Math.max(1,e.radius-r/2),borderWidth:1.5,borderColor:e.ring}));return}h.push(p(`halo-${t}`,e.x,e.y,e.size+8,e.halo),p(`mark-${t}`,e.x,e.y,e.size,e.color,{borderWidth:2,borderColor:m}))}),u&&h.push((0,o.jsx)(a.View,{...e.part(c,`drag`),style:a.StyleSheet.absoluteFill,children:p(`ghost`,u.x,u.y,u.size+2,u.color,{opacity:.85,borderWidth:2,borderColor:m})},`drag`));let _=l?.tooltip;if(_&&!r){let{box:r,lineHeight:s,padding:l,content:u}=_,d=C(i.text),f=C(i.textMuted),p=(e,t)=>({fontSize:12,lineHeight:s,color:t,fontWeight:String(e),includeFontPadding:!1,...n?{fontFamily:n}:null}),m=e=>(0,o.jsx)(a.View,{style:{width:8,height:8,borderRadius:4,marginRight:6,backgroundColor:e}}),g={height:s,flexDirection:`row`,alignItems:`center`};h.push((0,o.jsx)(a.View,{...e.part(c,`tooltip`),style:[k(t),{left:r.x,top:r.y,width:r.width,height:r.height,paddingHorizontal:l+1,paddingVertical:l-1}],children:_.text?_.text.map((e,t)=>(0,o.jsx)(a.Text,{numberOfLines:1,style:p(400,d),children:e},t)):[(0,o.jsxs)(a.View,{style:g,children:[u.titleColor?m(u.titleColor):null,(0,o.jsx)(a.Text,{numberOfLines:1,style:[p(600,d),{flexShrink:1}],children:u.title})]},`title`),...u.subtitle?[(0,o.jsx)(a.View,{style:g,children:(0,o.jsx)(a.Text,{numberOfLines:1,style:[p(400,f),{fontSize:11,paddingLeft:u.titleColor?14:0}],children:u.subtitle})},`subtitle`)]:[],...u.rows.map((e,t)=>(0,o.jsxs)(a.View,{style:g,children:[_.swatchWidth>0?(0,o.jsx)(a.View,{style:{width:_.swatchWidth},children:e.color?m(e.color):null}):null,(0,o.jsx)(a.Text,{numberOfLines:1,style:[p(400,f),{flexShrink:1}],children:e.name}),(0,o.jsx)(a.Text,{numberOfLines:1,style:[p(600,d),{flexGrow:1,marginLeft:16,textAlign:`right`,fontVariant:[`tabular-nums`]}],children:e.value})]},t))]},`tooltip`))}return h}var k=e=>({position:`absolute`,backgroundColor:C(e.theme.background),borderColor:C(e.theme.axis),borderWidth:1,borderRadius:8,shadowColor:`#0f172a`,shadowOpacity:.18,shadowRadius:8,shadowOffset:{width:0,height:6},elevation:6});exports.SHAPE_BUDGET=s,exports.arrowViews=v,exports.dashRuns=h,exports.drawHover=O,exports.drawStatic=D,exports.primitiveLimits=x,exports.tooltipCard=k;
1
+ const e=require("../../internal/parts.cjs"),t=require("../../charts/src/engine/color.cjs"),n=require("../../charts/src/engine/overlay.cjs"),r=require("../../charts/src/engine/scene.cjs"),i=require("../../charts/src/engine/controller.cjs");require("../../charts/src/canvas.cjs");const a=require("./measure.cjs");let o=require("react-native"),s=require("react/jsx-runtime");var c={linePoints:1200,dotsPerSeries:800,dots:2e3,barsPerSeries:600,bars:1500,areaColumns:200,dashes:200},l=`chart`,u=e=>Math.ceil(e*1.35),d=(e,t)=>Math.ceil(a.measureChartText(e,`${t.weight??400} ${t.size}px sans-serif`)*1.4+t.size*2);function f(e,t,n,r,i,a,c,l,f){let p=u(c.size),m=(p-c.size)/2,h=d(t,c),g=a===`top`?r-m:a===`bottom`?r-p+m:r-p/2,_=i===`left`?{left:n,width:h}:i===`right`?{right:l-n,width:h}:{left:n-h/2,width:h};return(0,s.jsx)(o.Text,{numberOfLines:1,style:[{position:`absolute`,top:g,..._,textAlign:i,fontSize:c.size,lineHeight:p,color:c.color,fontWeight:String(c.weight??400),includeFontPadding:!1,...c.family?{fontFamily:c.family}:null,...c.halo?{textShadowColor:c.halo,textShadowRadius:3,textShadowOffset:{width:0,height:0}}:null},f],children:t},e)}var p=(e,t,n,r,i,a,c)=>(0,s.jsx)(o.View,{style:[{position:`absolute`,left:t,top:n,width:r,height:i,backgroundColor:a},c]},e),m=(e,t,n,r,i,a)=>p(e,t-r/2,n-r/2,r,r,i,{borderRadius:r/2,...a}),h=(e,t,n,r,i,a,o)=>{let s=r-t,c=i-n,l=Math.hypot(s,c)+a;return p(e,(t+r)/2-l/2,(n+i)/2-a/2,l,a,o,{borderRadius:a/2,transform:[{rotate:`${Math.atan2(c,s)}rad`}]})};function g(e,t,n=c.dashes){let r=t.filter(e=>Number.isFinite(e)&&e>=0);r.length%2&&(r=[...r,...r]);let i=r.reduce((e,t)=>e+t,0);if(!r.length||i<=0)return[[0,e]];let a=e/i*(r.length/2),o=a>n?a/n:1,s=[],l=0;for(let t=0;l<e;t=(t+1)%r.length){let n=r[t]*o;t%2==0&&n>0&&s.push([l,Math.min(n,e-l)]),l+=Math.max(n,.5)}return s}var _=(e,t,n,r,i,a,o,s)=>g(i,s).map(([i,s],c)=>t===`y`?p(`${e}-${c}`,r+i,n,s,a,o):p(`${e}-${c}`,n,r+i,a,s,o)),v=(e,t=1)=>Math.round(e)+.5-t/2,y=(e,t,n,r)=>{let i=[],a=t.width,c=t.points;for(let o=1;o<c.length;o++){let s=c[o-1],l=c[o],u=Math.min(s.x,l.x)-n,d=Math.min(s.y,l.y)-r;i.push(s.y===l.y?p(`${e}-${o}`,u-a/2,d-a/2,Math.abs(l.x-s.x)+a,a,t.color):p(`${e}-${o}`,u-a/2,d-a/2,a,Math.abs(l.y-s.y)+a,t.color))}let[l,u,d]=t.head,f=Math.hypot(l.x-(u.x+d.x)/2,l.y-(u.y+d.y)/2),m=Math.hypot(d.x-u.x,d.y-u.y)/2,h=`transparent`,g={position:`absolute`,width:0,height:0},_=(u.x+d.x)/2,v=(u.y+d.y)/2;if(Math.abs(l.x-_)>=Math.abs(l.y-v)){let e=l.x>_;Object.assign(g,{left:(e?_:l.x)-n,top:l.y-m-r,borderTopWidth:m,borderBottomWidth:m,borderTopColor:h,borderBottomColor:h,...e?{borderLeftWidth:f,borderLeftColor:t.color}:{borderRightWidth:f,borderRightColor:t.color}})}else{let e=l.y>v;Object.assign(g,{left:l.x-m-n,top:(e?v:l.y)-r,borderLeftWidth:m,borderRightWidth:m,borderLeftColor:h,borderRightColor:h,...e?{borderTopWidth:f,borderTopColor:t.color}:{borderBottomWidth:f,borderBottomColor:t.color}})}return i.push((0,s.jsx)(o.View,{style:g},`${e}-head`)),i};function b(e,t){let n=e.length/2,r=n>t?Math.ceil(n/t):1,i=[];for(let t=0;t<n;t+=r){let n=e[t*2],r=e[t*2+1],a=i.length;a&&Math.hypot(n-i[a-2],r-i[a-1])<1.5||i.push(n,r)}let a=e[n*2-2],o=e[n*2-1],s=i.length;return n>1&&(i[s-2]!==a||i[s-1]!==o)&&i.push(a,o),i}function x(e,t,n,r,i,a,o,s=!1){let l=s?t.map((e,n)=>t[n%2?n-1:n+1]):t,u=s?{x:a.y,y:a.x,width:a.height,height:a.width}:a,d=l.length/2;if(d<2)return[];let f=l[0]<=l[d*2-2],m=e=>f?e:d-1-e,h=e=>l[m(e)*2],g=e=>l[m(e)*2+1],_=e=>o?o[m(e)]:n,v=Math.max(u.x,h(0)),y=Math.min(u.x+u.width,h(d-1));if(y<=v)return[];let b=Math.max(2,u.width/c.areaColumns),x=[],S=0;for(let t=Math.floor(v),n=0;t<y;n++){let a=Math.min(Math.ceil(y),Math.round(t+b)),o=(t+a)/2;for(;S<d-2&&h(S+1)<o;)S++;let c=h(S),l=h(S+1),f=l===c?0:Math.max(0,Math.min(1,(o-c)/(l-c))),m=g(S)+(g(S+1)-g(S))*f,v=_(S)+(_(S+1)-_(S))*f;if(Number.isFinite(m)&&Number.isFinite(v)){let o=Math.min(m,v),c=Math.abs(v-m);x.push(s?p(`${e}-${n}`,o-u.y,t-u.x,c,a-t,r,{opacity:i}):p(`${e}-${n}`,t-u.x,o-u.y,a-t,c,r,{opacity:i}))}t=a}return x}function S(e){let{plot:t}=e.layout,n=e.model.series.filter(e=>!e.hidden),r=n.filter(e=>e.type===`line`||e.type===`area`).length,i=n.filter(e=>e.type===`scatter`).length,a=Math.max(150,c.linePoints/Math.max(1,r)),o=Math.max(100,Math.min(c.dotsPerSeries,c.dots/Math.max(1,i)));return{perLine:a,options:{columnWidth:Math.max(3,t.width*4/a),maxDots:o,maxBars:c.barsPerSeries,dotCell:Math.max(4,Math.sqrt(t.width*t.height/o)*1.15+1)}}}function C(e){let{plot:t}=e.layout,{perLine:n,options:r}=S(e),a=i.scenePrimitives(e,r),o=t.x,s=t.y,l=[],u=c.dots,d=c.bars;return a.forEach((e,r)=>{let i=`${e.kind}${e.seriesIndex}-${r}`;if(e.kind===`area`){e.segments.forEach((n,r)=>l.push(...x(`${i}-${r}`,n,e.baseline,e.color,e.opacity,t,e.bottoms?.[r],e.horizontal)));return}if(e.kind===`line`){let t=0;for(let n of e.segments)t+=n.length/2;e.segments.forEach((r,a)=>{let c=b(r,Math.max(2,Math.round(n*r.length/2/Math.max(1,t))));if(c.length===2){l.push(m(`${i}-${a}`,c[0]-o,c[1]-s,e.width*1.5,e.color));return}for(let t=0;t+3<c.length;t+=2)l.push(h(`${i}-${a}-${t}`,c[t]-o,c[t+1]-s,c[t+2]-o,c[t+3]-s,e.width,e.color))});return}if(e.kind===`bars`){let t=e.rects.length/4,n=t>d?Math.ceil(t/Math.max(1,d)):1;for(let r=0;r<t;r+=n){let[t,n,a,c]=e.rects.slice(r*4,r*4+4),u=Math.min(e.radius??0,a/2,c/2);l.push(p(`${i}-${r}`,t-o,n-s,Math.max(a,.5),c,e.colors?.[r]??e.color,u>.5||e.opacity!==void 0?{...u>.5?{borderRadius:u}:null,...e.opacity===void 0?null:{opacity:e.opacity}}:void 0))}d=Math.max(0,d-Math.ceil(t/n));return}let a=e.dots.length/3,c=a>u?Math.ceil(a/Math.max(1,u)):1,f=e.stroke??0;for(let t=0;t<a;t+=c){let n=e.colors[t]??`#888`;l.push(m(`${i}-${t}`,e.dots[t*3]-o,e.dots[t*3+1]-s,e.dots[t*3+2],e.opacity>0?n:`transparent`,f>0&&e.opacity<1?{borderWidth:f,borderColor:n,opacity:1}:{opacity:e.opacity}))}u=Math.max(0,u-Math.ceil(a/c))}),l}var w=(e,n)=>t.toCss(e,n);function T(t,r){let{width:i,theme:c,model:u,layout:d,annotations:h}=t,{plot:g,scales:_,y2Ticks:y}=d,b=_.horizontal,x=b?u.y:u.x,S=b?u.x:u.y,C=b?d.yTicks:d.xTicks,T=b?d.xTicks:d.yTicks,E=b?_.yToPx:_.xToPx,D=b?_.xToPx:_.yToPx,O=c.fontSize,k=[];h.forEach((e,t)=>{if(e.type!==`rect`)return;let r=n.rectOf(e,_);r.width<=0||r.height<=0||k.push(p(`area-${t}`,r.x,r.y,r.width,r.height,w(e.color,e.opacity)))});let A=w(c.grid);S.grid&&T.values.forEach((e,t)=>{let n=D(e);n<g.y-1||n>g.y+g.height+1||k.push(p(`ygrid-${t}`,g.x,v(n),g.width,1,A))}),x.grid&&C.values.forEach((e,t)=>{let n=E(e);n<g.x-1||n>g.x+g.width+1||k.push(p(`xgrid-${t}`,v(n),g.y,1,g.height,A))});let j=Math.ceil(O*1.4),M={size:O,color:w(c.textMuted),family:r},N={size:O+1,weight:500,color:w(c.text,.8),family:r},P=g.y+g.height;if(x.visible){k.push(p(`xaxis`,g.x,v(P),g.width,1,w(c.axis)));let e=-1/0;C.values.map((e,t)=>({px:E(e),text:C.labels[t]??``})).sort((e,t)=>e.px-t.px).forEach(({px:t,text:n},r)=>{if(!n||t<g.x-.5||t>g.x+g.width+.5)return;let o=a.measureChartText(n,`400 ${O}px sans-serif`),s=Math.max(0,Math.min(i-o,t-o/2));s<e+6||(e=s+o,k.push(f(`xtick-${r}`,n,s+o/2,P+7,`center`,`top`,M,i)))}),x.title&&k.push(f(`xtitle`,x.title,g.x+g.width/2,P+j+10,`center`,`top`,N,i))}if(S.visible){let e=-1/0;T.values.map((e,t)=>({py:D(e),text:T.labels[t]??``})).sort((e,t)=>e.py-t.py).forEach(({py:t,text:n},r)=>{if(!(!n||t<g.y-.5||t>g.y+g.height+.5)){if(b){if(t-(O+2)/2<e)return;e=t+(O+2)/2}k.push(f(`ytick-${r}`,n,g.x-8,t,`right`,`middle`,M,i))}}),S.title&&k.push(f(`ytitle`,S.title,j/2+4,g.y+g.height/2,`center`,`middle`,N,i,{transform:[{rotate:`-90deg`}]}))}let F=b?null:u.y2;if(F&&y&&F.visible){let e=g.x+g.width;y.values.forEach((t,n)=>{let r=_.yToPx(t),a=y.labels[n];!a||r<g.y-.5||r>g.y+g.height+.5||k.push(f(`y2tick-${n}`,a,e+8,r,`left`,`middle`,M,i))}),F.title&&k.push(f(`y2title`,F.title,i-j/2-4,g.y+g.height/2,`center`,`middle`,N,i,{transform:[{rotate:`90deg`}]}))}let I=t.legend?.colors;if(I){let{bar:t,stops:n}=I,a=t.width/Math.max(1,n.length);k.push((0,s.jsx)(o.View,{...e.part(l,`color-legend`),style:{position:`absolute`,left:t.x,top:t.y,width:t.width,height:t.height,borderRadius:t.height/2,overflow:`hidden`,flexDirection:`row`},children:n.map((e,n)=>(0,s.jsx)(o.View,{style:{width:a,height:t.height,backgroundColor:e}},n))},`color-legend`)),I.ticks.forEach((e,n)=>k.push(p(`color-tick-${n}`,Math.round(e),t.y-2,1,t.height+4,w(c.text,.35)))),I.labels.forEach((e,t)=>k.push(f(`color-label-${t}`,e.text,e.x,e.y,e.align,`middle`,{size:11,color:w(c.textMuted),family:r},i)))}if(t.legend)for(let n of t.legend.entries){let t=n.box.height/2,i=n.shape===`dot`?m(`swatch`,5,t,8,n.color):n.shape===`line`?p(`swatch`,0,t-1,10,2,n.color):p(`swatch`,1,t-4,8,8,n.color);k.push((0,s.jsxs)(o.View,{style:{position:`absolute`,left:n.box.x,top:n.box.y,width:n.box.width,height:n.box.height,opacity:n.hidden?.45:1},...e.part(l,`legend-item`,{hidden:n.hidden}),children:[i,f(`name`,n.name,14,t,`left`,`middle`,{size:12,color:w(c.textMuted),family:r},n.box.width,n.hidden?{textDecorationLine:`line-through`}:void 0)]},`legend-${n.id}`))}return k}function E(e,t){let{theme:r,annotations:i,layout:o}=e,{plot:s,scales:c}=o,l=r.fontSize,u=s.x,d=s.y,m=s.width,h=w(r.background,.9),g=l+4,b=[];e.connectors.forEach((e,t)=>{let n=e.y0===e.y1;b.push(...n?_(`connector-${t}`,`y`,v(e.y0,e.width)-d,Math.min(e.x0,e.x1)-u,Math.abs(e.x1-e.x0),e.width,e.color,e.dash):_(`connector-${t}`,`x`,v(e.x0,e.width)-u,Math.min(e.y0,e.y1)-d,Math.abs(e.y1-e.y0),e.width,e.color,e.dash))}),e.arrows.forEach((e,t)=>{b.push(...y(`arrow-${t}`,e,u,d))}),i.forEach((e,r)=>{if(e.type!==`line`)return;let i=w(e.color),a=n.lineOf(e,c);if(a.vertical){let n=a.at;b.push(..._(`line-${r}`,`x`,v(n,e.width)-u,0,s.height,e.width,i,e.dash)),e.label&&b.push(f(`line-label-${r}`,e.label,n+5-u,5,`left`,`top`,{size:l,weight:500,color:i,halo:h,family:t},m))}else{let n=a.at;b.push(..._(`line-${r}`,`y`,v(n,e.width)-d,0,s.width,e.width,i,e.dash)),e.label&&b.push(f(`line-label-${r}`,e.label,s.width-6,n-3-d,`right`,`bottom`,{size:l,weight:500,color:i,halo:h,family:t},m))}}),i.forEach((e,i)=>{if(e.type!==`rect`)return;let o=n.areaTitleLayout(e,n.rectOf(e,c),l,(e,t,n)=>a.measureChartText(e,`${n} ${t}px sans-serif`));if(!o)return;let s=w(e.labelColor),h=w(r.textMuted);o.parts.forEach((n,r)=>{let a=`area-${n.kind}-${i}-${r}`,o=n.y+n.height/2-d;if(n.kind===`badge`){let r=n.height-2;b.push(p(`${a}-pill`,n.x-u,o-r/2,n.width,r,w(e.labelColor,.16),{borderRadius:r/2}),f(a,n.text,n.x-u+n.width/2,o,`center`,`middle`,{size:n.size,weight:n.weight,color:s,family:t},m));return}b.push(f(n.kind===`label`?`area-label-${i}`:a,n.text,n.x-u,o,`left`,`middle`,{size:n.size,weight:n.weight,color:n.kind===`label`?s:h,family:t},m))})}),i.forEach((e,r)=>{if(e.type!==`text`||!e.text)return;let i=a.measureChartText(e.text,`${e.weight} ${l}px sans-serif`),o=n.textBox(e,c,i,g);b.push(f(`text-${r}`,e.text,o.x-u,o.y+o.height/2-d,`left`,`middle`,{size:l,weight:e.weight,color:w(e.color),halo:h,family:t},m))});let x=w(r.text,.85);return e.pointLabels.forEach(({label:e,box:n},r)=>{let i=e.placement===`inside`?e.bar:void 0;b.push(f(`point-label-${r}`,e.text,n.x-u,n.y+n.height/2-d,`left`,`middle`,e.color?{size:l,color:e.color,family:t}:{size:l,color:x,halo:h,family:t},m,i?{width:Math.max(n.width,i.x+i.width-6-n.x)}:void 0))}),b}var D=e=>({position:`absolute`,left:e.x,top:e.y,width:e.width,height:e.height,overflow:`hidden`});function O(t,n){let{plot:r}=t.layout;return(0,s.jsxs)(s.Fragment,{children:[T(t,n),(0,s.jsx)(o.View,{style:D(r),...e.part(l,`data`),children:C(t)},`data`),(0,s.jsx)(o.View,{style:D(r),...e.part(l,`labels`),children:E(t,n)},`labels`)]})}function k(t,n,i){let{theme:a,layout:c,hover:u,dragging:d}=t,{plot:f}=c,h=w(a.background),g=[];u&&u.crosshairY!==null&&g.push((0,s.jsx)(o.View,{style:o.StyleSheet.absoluteFill,...e.part(l,`crosshair`),children:_(`dash`,`y`,Math.round(u.crosshairY),f.x,f.width,1,w(a.textMuted,.55),[3,3])},`crosshair-y`)),u&&u.crosshairX!==null&&g.push((0,s.jsx)(o.View,{style:o.StyleSheet.absoluteFill,...e.part(l,`crosshair`),children:_(`dash`,`x`,Math.round(u.crosshairX),f.y,f.height,1,w(a.textMuted,.55),[3,3])},`crosshair`));let v=!1;u?.marks.forEach((e,t)=>{if(e.kind===`band`){g.push(p(`mark-${t}`,e.x,e.y,e.width,e.height,w(a.text,.05),{borderRadius:6}));return}if(e.kind===`guide`){g.push(p(`mark-${t}`,e.x,e.y,e.width,e.height,w(a.text,.06)));return}if(e.kind===`bar`){v||(v=!0,g.push(p(`veil`,f.x,f.y,f.width,f.height,w(a.background,.42))));let n=r.liftedBarRect(e);e.backdrop&&g.push(p(`under-${t}`,n.x,n.y,n.width,n.height,w(a.background),{borderRadius:e.radius})),g.push(p(`mark-${t}`,n.x,n.y,n.width,n.height,e.color,{borderRadius:e.radius,...e.ring?{borderWidth:e.backdrop?2:1.5,borderColor:e.ring,shadowColor:`#0f172a`,shadowOpacity:.4,shadowRadius:6,shadowOffset:{width:0,height:3},elevation:4}:null}));return}if(e.kind===`cell`){let n=Math.min(3,e.width*.06,e.height*.06),r=Math.min(2,e.width/5,e.height/5);g.push(p(`mark-${t}`,e.x-n,e.y-n,e.width+n*2,e.height+n*2,e.color,{borderRadius:Math.max(2,e.radius),shadowColor:`#0f172a`,shadowOpacity:.45,shadowRadius:6,shadowOffset:{width:0,height:3},elevation:4})),e.width>8&&e.height>8&&g.push(p(`ring-${t}`,e.x-n+r,e.y-n+r,e.width+(n-r)*2,e.height+(n-r)*2,`transparent`,{borderRadius:Math.max(1,e.radius-r/2),borderWidth:2,borderColor:e.ring}));return}g.push(m(`halo-${t}`,e.x,e.y,e.size+8,e.halo),m(`mark-${t}`,e.x,e.y,e.size,e.color,{borderWidth:2,borderColor:h}))}),d&&g.push((0,s.jsx)(o.View,{...e.part(l,`drag`),style:o.StyleSheet.absoluteFill,children:m(`ghost`,d.x,d.y,d.size+2,d.color,{opacity:.85,borderWidth:2,borderColor:h})},`drag`));let y=u?.tooltip;if(y&&!i){let{box:r,lineHeight:i,padding:c,content:u}=y,d=w(a.text),f=w(a.textMuted),p=(e,t)=>({fontSize:12,lineHeight:i,color:t,fontWeight:String(e),includeFontPadding:!1,...n?{fontFamily:n}:null}),m=e=>(0,s.jsx)(o.View,{style:{width:8,height:8,borderRadius:4,marginRight:6,backgroundColor:e}}),h={height:i,flexDirection:`row`,alignItems:`center`};g.push((0,s.jsx)(o.View,{...e.part(l,`tooltip`),style:[A(t),{left:r.x,top:r.y,width:r.width,height:r.height,paddingHorizontal:c+1,paddingVertical:c-1}],children:y.text?y.text.map((e,t)=>(0,s.jsx)(o.Text,{numberOfLines:1,style:p(400,d),children:e},t)):[(0,s.jsxs)(o.View,{style:h,children:[u.titleColor?m(u.titleColor):null,(0,s.jsx)(o.Text,{numberOfLines:1,style:[p(600,d),{flexShrink:1}],children:u.title})]},`title`),...u.subtitle?[(0,s.jsx)(o.View,{style:h,children:(0,s.jsx)(o.Text,{numberOfLines:1,style:[p(400,f),{fontSize:11,paddingLeft:u.titleColor?14:0}],children:u.subtitle})},`subtitle`)]:[],...u.rows.map((e,t)=>(0,s.jsxs)(o.View,{style:h,children:[y.swatchWidth>0?(0,s.jsx)(o.View,{style:{width:y.swatchWidth},children:e.color?m(e.color):null}):null,(0,s.jsx)(o.Text,{numberOfLines:1,style:[p(400,f),{flexShrink:1}],children:e.name}),(0,s.jsx)(o.Text,{numberOfLines:1,style:[p(600,d),{flexGrow:1,marginLeft:16,textAlign:`right`,fontVariant:[`tabular-nums`]}],children:e.value})]},t))]},`tooltip`))}return g}var A=e=>({position:`absolute`,backgroundColor:w(e.theme.background,.9),borderColor:w(e.theme.axis),borderWidth:1,borderRadius:8,shadowColor:`#0f172a`,shadowOpacity:.18,shadowRadius:8,shadowOffset:{width:0,height:6},elevation:6});exports.SHAPE_BUDGET=c,exports.arrowViews=y,exports.dashRuns=g,exports.drawHover=k,exports.drawStatic=O,exports.primitiveLimits=S,exports.tooltipCard=A;
2
2
  //# sourceMappingURL=scene.cjs.map