@voila.dev/chart 4.0.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 (377) hide show
  1. package/README.md +85 -0
  2. package/dist/brush/brush-layer.d.ts +16 -0
  3. package/dist/brush/brush-layer.d.ts.map +1 -0
  4. package/dist/brush/brush-layer.js +137 -0
  5. package/dist/brush/brush-layer.js.map +7 -0
  6. package/dist/brush/index.d.ts +10 -0
  7. package/dist/brush/index.d.ts.map +1 -0
  8. package/dist/brush/index.js +8 -0
  9. package/dist/brush/index.js.map +7 -0
  10. package/dist/canvas/canvas-renderer.d.ts +11 -0
  11. package/dist/canvas/canvas-renderer.d.ts.map +1 -0
  12. package/dist/canvas/canvas-renderer.js +49 -0
  13. package/dist/canvas/canvas-renderer.js.map +7 -0
  14. package/dist/canvas/index.d.ts +2 -0
  15. package/dist/canvas/index.d.ts.map +1 -0
  16. package/dist/canvas/index.js +5 -0
  17. package/dist/canvas/index.js.map +7 -0
  18. package/dist/canvas/paint-scene.d.ts +4 -0
  19. package/dist/canvas/paint-scene.d.ts.map +1 -0
  20. package/dist/canvas/paint-scene.js +130 -0
  21. package/dist/canvas/paint-scene.js.map +7 -0
  22. package/dist/canvas/resolve-color.d.ts +18 -0
  23. package/dist/canvas/resolve-color.d.ts.map +1 -0
  24. package/dist/canvas/resolve-color.js +52 -0
  25. package/dist/canvas/resolve-color.js.map +7 -0
  26. package/dist/contour/density.d.ts +20 -0
  27. package/dist/contour/density.d.ts.map +1 -0
  28. package/dist/contour/density.js +59 -0
  29. package/dist/contour/density.js.map +7 -0
  30. package/dist/contour/index.d.ts +2 -0
  31. package/dist/contour/index.d.ts.map +1 -0
  32. package/dist/contour/index.js +5 -0
  33. package/dist/contour/index.js.map +7 -0
  34. package/dist/core/channel.d.ts +11 -0
  35. package/dist/core/channel.d.ts.map +1 -0
  36. package/dist/core/channel.js +44 -0
  37. package/dist/core/channel.js.map +7 -0
  38. package/dist/core/compile.d.ts +22 -0
  39. package/dist/core/compile.d.ts.map +1 -0
  40. package/dist/core/compile.js +295 -0
  41. package/dist/core/compile.js.map +7 -0
  42. package/dist/core/define-chart.d.ts +96 -0
  43. package/dist/core/define-chart.d.ts.map +1 -0
  44. package/dist/core/define-chart.js +7 -0
  45. package/dist/core/define-chart.js.map +7 -0
  46. package/dist/core/facet.d.ts +7 -0
  47. package/dist/core/facet.d.ts.map +1 -0
  48. package/dist/core/facet.js +134 -0
  49. package/dist/core/facet.js.map +7 -0
  50. package/dist/core/format.d.ts +37 -0
  51. package/dist/core/format.d.ts.map +1 -0
  52. package/dist/core/format.js +108 -0
  53. package/dist/core/format.js.map +7 -0
  54. package/dist/core/guides/axes.d.ts +25 -0
  55. package/dist/core/guides/axes.d.ts.map +1 -0
  56. package/dist/core/guides/axes.js +204 -0
  57. package/dist/core/guides/axes.js.map +7 -0
  58. package/dist/core/marks/area.d.ts +23 -0
  59. package/dist/core/marks/area.d.ts.map +1 -0
  60. package/dist/core/marks/area.js +187 -0
  61. package/dist/core/marks/area.js.map +7 -0
  62. package/dist/core/marks/bar.d.ts +26 -0
  63. package/dist/core/marks/bar.d.ts.map +1 -0
  64. package/dist/core/marks/bar.js +200 -0
  65. package/dist/core/marks/bar.js.map +7 -0
  66. package/dist/core/marks/cell.d.ts +16 -0
  67. package/dist/core/marks/cell.d.ts.map +1 -0
  68. package/dist/core/marks/cell.js +98 -0
  69. package/dist/core/marks/cell.js.map +7 -0
  70. package/dist/core/marks/dot.d.ts +17 -0
  71. package/dist/core/marks/dot.d.ts.map +1 -0
  72. package/dist/core/marks/dot.js +125 -0
  73. package/dist/core/marks/dot.js.map +7 -0
  74. package/dist/core/marks/funnel-layout.d.ts +37 -0
  75. package/dist/core/marks/funnel-layout.d.ts.map +1 -0
  76. package/dist/core/marks/funnel-layout.js +61 -0
  77. package/dist/core/marks/funnel-layout.js.map +7 -0
  78. package/dist/core/marks/funnel.d.ts +19 -0
  79. package/dist/core/marks/funnel.d.ts.map +1 -0
  80. package/dist/core/marks/funnel.js +143 -0
  81. package/dist/core/marks/funnel.js.map +7 -0
  82. package/dist/core/marks/line.d.ts +17 -0
  83. package/dist/core/marks/line.d.ts.map +1 -0
  84. package/dist/core/marks/line.js +150 -0
  85. package/dist/core/marks/line.js.map +7 -0
  86. package/dist/core/marks/polar.d.ts +61 -0
  87. package/dist/core/marks/polar.d.ts.map +1 -0
  88. package/dist/core/marks/polar.js +436 -0
  89. package/dist/core/marks/polar.js.map +7 -0
  90. package/dist/core/marks/rect.d.ts +22 -0
  91. package/dist/core/marks/rect.d.ts.map +1 -0
  92. package/dist/core/marks/rect.js +119 -0
  93. package/dist/core/marks/rect.js.map +7 -0
  94. package/dist/core/marks/rule.d.ts +17 -0
  95. package/dist/core/marks/rule.d.ts.map +1 -0
  96. package/dist/core/marks/rule.js +73 -0
  97. package/dist/core/marks/rule.js.map +7 -0
  98. package/dist/core/marks/shared.d.ts +41 -0
  99. package/dist/core/marks/shared.d.ts.map +1 -0
  100. package/dist/core/marks/shared.js +74 -0
  101. package/dist/core/marks/shared.js.map +7 -0
  102. package/dist/core/marks/stack.d.ts +13 -0
  103. package/dist/core/marks/stack.d.ts.map +1 -0
  104. package/dist/core/marks/stack.js +28 -0
  105. package/dist/core/marks/stack.js.map +7 -0
  106. package/dist/core/marks/stats/difference.d.ts +20 -0
  107. package/dist/core/marks/stats/difference.d.ts.map +1 -0
  108. package/dist/core/marks/stats/difference.js +168 -0
  109. package/dist/core/marks/stats/difference.js.map +7 -0
  110. package/dist/core/marks/stats/distribution.d.ts +41 -0
  111. package/dist/core/marks/stats/distribution.d.ts.map +1 -0
  112. package/dist/core/marks/stats/distribution.js +354 -0
  113. package/dist/core/marks/stats/distribution.js.map +7 -0
  114. package/dist/core/marks/stats/dodge.d.ts +16 -0
  115. package/dist/core/marks/stats/dodge.d.ts.map +1 -0
  116. package/dist/core/marks/stats/dodge.js +104 -0
  117. package/dist/core/marks/stats/dodge.js.map +7 -0
  118. package/dist/core/marks/stats/hexbin.d.ts +26 -0
  119. package/dist/core/marks/stats/hexbin.d.ts.map +1 -0
  120. package/dist/core/marks/stats/hexbin.js +113 -0
  121. package/dist/core/marks/stats/hexbin.js.map +7 -0
  122. package/dist/core/marks/stats/histogram.d.ts +27 -0
  123. package/dist/core/marks/stats/histogram.d.ts.map +1 -0
  124. package/dist/core/marks/stats/histogram.js +70 -0
  125. package/dist/core/marks/stats/histogram.js.map +7 -0
  126. package/dist/core/marks/stats/regression.d.ts +13 -0
  127. package/dist/core/marks/stats/regression.d.ts.map +1 -0
  128. package/dist/core/marks/stats/regression.js +80 -0
  129. package/dist/core/marks/stats/regression.js.map +7 -0
  130. package/dist/core/marks/stats/statistics.d.ts +34 -0
  131. package/dist/core/marks/stats/statistics.d.ts.map +1 -0
  132. package/dist/core/marks/stats/statistics.js +111 -0
  133. package/dist/core/marks/stats/statistics.js.map +7 -0
  134. package/dist/core/marks/stats/waffle.d.ts +18 -0
  135. package/dist/core/marks/stats/waffle.d.ts.map +1 -0
  136. package/dist/core/marks/stats/waffle.js +117 -0
  137. package/dist/core/marks/stats/waffle.js.map +7 -0
  138. package/dist/core/marks/text.d.ts +19 -0
  139. package/dist/core/marks/text.d.ts.map +1 -0
  140. package/dist/core/marks/text.js +60 -0
  141. package/dist/core/marks/text.js.map +7 -0
  142. package/dist/core/motion/tween.d.ts +6 -0
  143. package/dist/core/motion/tween.d.ts.map +1 -0
  144. package/dist/core/motion/tween.js +98 -0
  145. package/dist/core/motion/tween.js.map +7 -0
  146. package/dist/core/nearest.d.ts +25 -0
  147. package/dist/core/nearest.d.ts.map +1 -0
  148. package/dist/core/nearest.js +151 -0
  149. package/dist/core/nearest.js.map +7 -0
  150. package/dist/core/paths.d.ts +65 -0
  151. package/dist/core/paths.d.ts.map +1 -0
  152. package/dist/core/paths.js +192 -0
  153. package/dist/core/paths.js.map +7 -0
  154. package/dist/core/scales/color.d.ts +11 -0
  155. package/dist/core/scales/color.d.ts.map +1 -0
  156. package/dist/core/scales/color.js +35 -0
  157. package/dist/core/scales/color.js.map +7 -0
  158. package/dist/core/scales/continuous.d.ts +18 -0
  159. package/dist/core/scales/continuous.d.ts.map +1 -0
  160. package/dist/core/scales/continuous.js +82 -0
  161. package/dist/core/scales/continuous.js.map +7 -0
  162. package/dist/core/scales/discrete.d.ts +22 -0
  163. package/dist/core/scales/discrete.d.ts.map +1 -0
  164. package/dist/core/scales/discrete.js +103 -0
  165. package/dist/core/scales/discrete.js.map +7 -0
  166. package/dist/core/scales/resolve.d.ts +18 -0
  167. package/dist/core/scales/resolve.d.ts.map +1 -0
  168. package/dist/core/scales/resolve.js +112 -0
  169. package/dist/core/scales/resolve.js.map +7 -0
  170. package/dist/core/scales/time.d.ts +4 -0
  171. package/dist/core/scales/time.d.ts.map +1 -0
  172. package/dist/core/scales/time.js +140 -0
  173. package/dist/core/scales/time.js.map +7 -0
  174. package/dist/core/text.d.ts +3 -0
  175. package/dist/core/text.d.ts.map +1 -0
  176. package/dist/core/text.js +29 -0
  177. package/dist/core/text.js.map +7 -0
  178. package/dist/core/theme.d.ts +8 -0
  179. package/dist/core/theme.d.ts.map +1 -0
  180. package/dist/core/theme.js +21 -0
  181. package/dist/core/theme.js.map +7 -0
  182. package/dist/core/ticks.d.ts +27 -0
  183. package/dist/core/ticks.d.ts.map +1 -0
  184. package/dist/core/ticks.js +76 -0
  185. package/dist/core/ticks.js.map +7 -0
  186. package/dist/core/types.d.ts +305 -0
  187. package/dist/core/types.d.ts.map +1 -0
  188. package/dist/core/types.js +1 -0
  189. package/dist/core/types.js.map +7 -0
  190. package/dist/force/force.d.ts +30 -0
  191. package/dist/force/force.d.ts.map +1 -0
  192. package/dist/force/force.js +143 -0
  193. package/dist/force/force.js.map +7 -0
  194. package/dist/force/index.d.ts +2 -0
  195. package/dist/force/index.d.ts.map +1 -0
  196. package/dist/force/index.js +7 -0
  197. package/dist/force/index.js.map +7 -0
  198. package/dist/geo/geo.d.ts +59 -0
  199. package/dist/geo/geo.d.ts.map +1 -0
  200. package/dist/geo/geo.js +231 -0
  201. package/dist/geo/geo.js.map +7 -0
  202. package/dist/geo/index.d.ts +2 -0
  203. package/dist/geo/index.d.ts.map +1 -0
  204. package/dist/geo/index.js +13 -0
  205. package/dist/geo/index.js.map +7 -0
  206. package/dist/hierarchy/hierarchy.d.ts +24 -0
  207. package/dist/hierarchy/hierarchy.d.ts.map +1 -0
  208. package/dist/hierarchy/hierarchy.js +279 -0
  209. package/dist/hierarchy/hierarchy.js.map +7 -0
  210. package/dist/hierarchy/index.d.ts +2 -0
  211. package/dist/hierarchy/index.d.ts.map +1 -0
  212. package/dist/hierarchy/index.js +11 -0
  213. package/dist/hierarchy/index.js.map +7 -0
  214. package/dist/index.d.ts +29 -0
  215. package/dist/index.d.ts.map +1 -0
  216. package/dist/index.js +96 -0
  217. package/dist/index.js.map +7 -0
  218. package/dist/react/brush-contract.d.ts +23 -0
  219. package/dist/react/brush-contract.d.ts.map +1 -0
  220. package/dist/react/brush-contract.js +7 -0
  221. package/dist/react/brush-contract.js.map +7 -0
  222. package/dist/react/chart-data-table.d.ts +18 -0
  223. package/dist/react/chart-data-table.d.ts.map +1 -0
  224. package/dist/react/chart-data-table.js +55 -0
  225. package/dist/react/chart-data-table.js.map +7 -0
  226. package/dist/react/chart-legend.d.ts +17 -0
  227. package/dist/react/chart-legend.d.ts.map +1 -0
  228. package/dist/react/chart-legend.js +126 -0
  229. package/dist/react/chart-legend.js.map +7 -0
  230. package/dist/react/chart-tooltip.d.ts +18 -0
  231. package/dist/react/chart-tooltip.d.ts.map +1 -0
  232. package/dist/react/chart-tooltip.js +95 -0
  233. package/dist/react/chart-tooltip.js.map +7 -0
  234. package/dist/react/chart.d.ts +45 -0
  235. package/dist/react/chart.d.ts.map +1 -0
  236. package/dist/react/chart.js +383 -0
  237. package/dist/react/chart.js.map +7 -0
  238. package/dist/react/focus-overlay.d.ts +14 -0
  239. package/dist/react/focus-overlay.d.ts.map +1 -0
  240. package/dist/react/focus-overlay.js +147 -0
  241. package/dist/react/focus-overlay.js.map +7 -0
  242. package/dist/react/index.d.ts +7 -0
  243. package/dist/react/index.d.ts.map +1 -0
  244. package/dist/react/index.js +11 -0
  245. package/dist/react/index.js.map +7 -0
  246. package/dist/react/messages.d.ts +16 -0
  247. package/dist/react/messages.d.ts.map +1 -0
  248. package/dist/react/messages.js +33 -0
  249. package/dist/react/messages.js.map +7 -0
  250. package/dist/react/renderer.d.ts +14 -0
  251. package/dist/react/renderer.d.ts.map +1 -0
  252. package/dist/react/renderer.js +1 -0
  253. package/dist/react/renderer.js.map +7 -0
  254. package/dist/react/sr-only.d.ts +4 -0
  255. package/dist/react/sr-only.d.ts.map +1 -0
  256. package/dist/react/sr-only.js +15 -0
  257. package/dist/react/sr-only.js.map +7 -0
  258. package/dist/react/svg-renderer.d.ts +4 -0
  259. package/dist/react/svg-renderer.d.ts.map +1 -0
  260. package/dist/react/svg-renderer.js +20 -0
  261. package/dist/react/svg-renderer.js.map +7 -0
  262. package/dist/react/svg-scene.d.ts +8 -0
  263. package/dist/react/svg-scene.d.ts.map +1 -0
  264. package/dist/react/svg-scene.js +121 -0
  265. package/dist/react/svg-scene.js.map +7 -0
  266. package/dist/react/use-animated-scene.d.ts +10 -0
  267. package/dist/react/use-animated-scene.d.ts.map +1 -0
  268. package/dist/react/use-animated-scene.js +41 -0
  269. package/dist/react/use-animated-scene.js.map +7 -0
  270. package/dist/react/use-chart-focus.d.ts +29 -0
  271. package/dist/react/use-chart-focus.d.ts.map +1 -0
  272. package/dist/react/use-chart-focus.js +180 -0
  273. package/dist/react/use-chart-focus.js.map +7 -0
  274. package/dist/react/use-chart-width.d.ts +12 -0
  275. package/dist/react/use-chart-width.d.ts.map +1 -0
  276. package/dist/react/use-chart-width.js +23 -0
  277. package/dist/react/use-chart-width.js.map +7 -0
  278. package/dist/react/use-chart-zoom.d.ts +13 -0
  279. package/dist/react/use-chart-zoom.d.ts.map +1 -0
  280. package/dist/react/use-chart-zoom.js +52 -0
  281. package/dist/react/use-chart-zoom.js.map +7 -0
  282. package/dist/react/use-text-measurer.d.ts +8 -0
  283. package/dist/react/use-text-measurer.d.ts.map +1 -0
  284. package/dist/react/use-text-measurer.js +44 -0
  285. package/dist/react/use-text-measurer.js.map +7 -0
  286. package/dist/sankey/index.d.ts +2 -0
  287. package/dist/sankey/index.d.ts.map +1 -0
  288. package/dist/sankey/index.js +7 -0
  289. package/dist/sankey/index.js.map +7 -0
  290. package/dist/sankey/sankey.d.ts +29 -0
  291. package/dist/sankey/sankey.d.ts.map +1 -0
  292. package/dist/sankey/sankey.js +127 -0
  293. package/dist/sankey/sankey.js.map +7 -0
  294. package/dist/voronoi/index.d.ts +2 -0
  295. package/dist/voronoi/index.d.ts.map +1 -0
  296. package/dist/voronoi/index.js +5 -0
  297. package/dist/voronoi/index.js.map +7 -0
  298. package/dist/voronoi/voronoi.d.ts +16 -0
  299. package/dist/voronoi/voronoi.d.ts.map +1 -0
  300. package/dist/voronoi/voronoi.js +62 -0
  301. package/dist/voronoi/voronoi.js.map +7 -0
  302. package/package.json +74 -0
  303. package/src/brush/brush-layer.tsx +174 -0
  304. package/src/brush/index.ts +14 -0
  305. package/src/canvas/canvas-renderer.tsx +56 -0
  306. package/src/canvas/index.ts +1 -0
  307. package/src/canvas/paint-scene.ts +152 -0
  308. package/src/canvas/resolve-color.ts +65 -0
  309. package/src/contour/density.ts +90 -0
  310. package/src/contour/index.ts +1 -0
  311. package/src/core/channel.ts +53 -0
  312. package/src/core/compile.ts +436 -0
  313. package/src/core/define-chart.ts +128 -0
  314. package/src/core/facet.ts +189 -0
  315. package/src/core/format.ts +163 -0
  316. package/src/core/guides/axes.ts +283 -0
  317. package/src/core/marks/area.ts +238 -0
  318. package/src/core/marks/bar.ts +278 -0
  319. package/src/core/marks/cell.ts +123 -0
  320. package/src/core/marks/dot.ts +157 -0
  321. package/src/core/marks/funnel-layout.ts +113 -0
  322. package/src/core/marks/funnel.ts +172 -0
  323. package/src/core/marks/line.ts +206 -0
  324. package/src/core/marks/polar.ts +568 -0
  325. package/src/core/marks/rect.ts +156 -0
  326. package/src/core/marks/rule.ts +104 -0
  327. package/src/core/marks/shared.ts +134 -0
  328. package/src/core/marks/stack.ts +42 -0
  329. package/src/core/marks/stats/difference.ts +205 -0
  330. package/src/core/marks/stats/distribution.ts +425 -0
  331. package/src/core/marks/stats/dodge.ts +136 -0
  332. package/src/core/marks/stats/hexbin.ts +152 -0
  333. package/src/core/marks/stats/histogram.ts +108 -0
  334. package/src/core/marks/stats/regression.ts +108 -0
  335. package/src/core/marks/stats/statistics.ts +153 -0
  336. package/src/core/marks/stats/waffle.ts +141 -0
  337. package/src/core/marks/text.ts +97 -0
  338. package/src/core/motion/tween.ts +131 -0
  339. package/src/core/nearest.ts +223 -0
  340. package/src/core/paths.ts +323 -0
  341. package/src/core/scales/color.ts +51 -0
  342. package/src/core/scales/continuous.ts +111 -0
  343. package/src/core/scales/discrete.ts +156 -0
  344. package/src/core/scales/resolve.ts +158 -0
  345. package/src/core/scales/time.ts +180 -0
  346. package/src/core/text.ts +42 -0
  347. package/src/core/theme.ts +26 -0
  348. package/src/core/ticks.ts +118 -0
  349. package/src/core/types.ts +358 -0
  350. package/src/force/force.ts +200 -0
  351. package/src/force/index.ts +6 -0
  352. package/src/geo/geo.ts +346 -0
  353. package/src/geo/index.ts +10 -0
  354. package/src/hierarchy/hierarchy.ts +377 -0
  355. package/src/hierarchy/index.ts +6 -0
  356. package/src/index.ts +70 -0
  357. package/src/react/brush-contract.ts +35 -0
  358. package/src/react/chart-data-table.tsx +98 -0
  359. package/src/react/chart-legend.tsx +130 -0
  360. package/src/react/chart-tooltip.tsx +111 -0
  361. package/src/react/chart.tsx +489 -0
  362. package/src/react/focus-overlay.tsx +164 -0
  363. package/src/react/index.ts +9 -0
  364. package/src/react/messages.ts +49 -0
  365. package/src/react/renderer.ts +15 -0
  366. package/src/react/sr-only.ts +14 -0
  367. package/src/react/svg-renderer.tsx +18 -0
  368. package/src/react/svg-scene.tsx +146 -0
  369. package/src/react/use-animated-scene.ts +57 -0
  370. package/src/react/use-chart-focus.ts +245 -0
  371. package/src/react/use-chart-width.ts +27 -0
  372. package/src/react/use-chart-zoom.ts +67 -0
  373. package/src/react/use-text-measurer.ts +49 -0
  374. package/src/sankey/index.ts +6 -0
  375. package/src/sankey/sankey.ts +179 -0
  376. package/src/voronoi/index.ts +1 -0
  377. package/src/voronoi/voronoi.ts +84 -0
@@ -0,0 +1,231 @@
1
+ import {
2
+ geoAlbersUsa,
3
+ geoArea,
4
+ geoConicConformal,
5
+ geoEqualEarth,
6
+ geoEquirectangular,
7
+ geoMercator,
8
+ geoNaturalEarth1,
9
+ geoOrthographic,
10
+ geoPath
11
+ } from "d3-geo";
12
+ import { isPlaceable, numericValue, readChannel } from "../core/channel.js";
13
+ import { markId, paint } from "../core/marks/shared.js";
14
+ const PROJECTIONS = {
15
+ "equal-earth": geoEqualEarth,
16
+ "natural-earth": geoNaturalEarth1,
17
+ mercator: geoMercator,
18
+ equirectangular: geoEquirectangular,
19
+ orthographic: geoOrthographic,
20
+ "albers-usa": geoAlbersUsa,
21
+ france: () => geoConicConformal().parallels([44, 49]).rotate([-3, 0])
22
+ };
23
+ function reverseRings(geometry) {
24
+ if (geometry.type === "Polygon") {
25
+ return {
26
+ ...geometry,
27
+ coordinates: geometry.coordinates.map(
28
+ (ring) => [...ring].reverse()
29
+ )
30
+ };
31
+ }
32
+ if (geometry.type === "MultiPolygon") {
33
+ return {
34
+ ...geometry,
35
+ coordinates: geometry.coordinates.map(
36
+ (polygon) => polygon.map((ring) => [...ring].reverse())
37
+ )
38
+ };
39
+ }
40
+ return geometry;
41
+ }
42
+ function rewind(object) {
43
+ const value = object;
44
+ if (value.type === "FeatureCollection" && Array.isArray(value.features)) {
45
+ return {
46
+ ...value,
47
+ features: value.features.map((feature) => rewind(feature))
48
+ };
49
+ }
50
+ if (value.type === "Feature" && value.geometry) {
51
+ return geoArea(value) > 2 * Math.PI ? { ...value, geometry: reverseRings(value.geometry) } : object;
52
+ }
53
+ return object;
54
+ }
55
+ function projection(kind, options) {
56
+ return {
57
+ fit(plot) {
58
+ const inset = options.inset ?? 4;
59
+ const projected = (typeof kind === "function" ? kind : PROJECTIONS[kind])().fitExtent(
60
+ [
61
+ [plot.x + inset, plot.y + inset],
62
+ [plot.x + plot.width - inset, plot.y + plot.height - inset]
63
+ ],
64
+ rewind(options.domain)
65
+ );
66
+ const path = geoPath(projected);
67
+ return {
68
+ project(longitude, latitude) {
69
+ const point = projected([longitude, latitude]);
70
+ return point ? { x: point[0], y: point[1] } : void 0;
71
+ },
72
+ path: (geometry) => path(geometry) ?? "",
73
+ centroid(geometry) {
74
+ const [x, y] = path.centroid(geometry);
75
+ return { x, y };
76
+ },
77
+ bounds(geometry) {
78
+ const [[x0, y0], [x1, y1]] = path.bounds(
79
+ geometry
80
+ );
81
+ return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
82
+ }
83
+ };
84
+ }
85
+ };
86
+ }
87
+ function geoShape(features, options) {
88
+ const names = readChannel(features, options.name);
89
+ const colors = readChannel(features, options.color);
90
+ return {
91
+ id: options.id,
92
+ coordinate: "frame",
93
+ focusOrder: "point",
94
+ titles: { value: options.label },
95
+ channels: options.color === void 0 ? {} : { color: { values: colors.filter(isPlaceable) } },
96
+ render(context) {
97
+ const id = markId(options.id, "geo", context);
98
+ const fitted = context.projection;
99
+ if (fitted === void 0) {
100
+ return { nodes: [] };
101
+ }
102
+ const nodes = [];
103
+ const points = [];
104
+ for (const [index, feature] of features.entries()) {
105
+ const name = String(names[index] ?? index);
106
+ const value = colors[index];
107
+ const fill = options.fill ?? (value === void 0 || options.color === void 0 ? context.theme.grid : context.colorOf(value));
108
+ const shape = rewind(feature);
109
+ const d = fitted.path(shape);
110
+ if (d === "") continue;
111
+ nodes.push({
112
+ kind: "path",
113
+ key: `${id}:${name}`,
114
+ role: "mark",
115
+ d,
116
+ paint: paint({
117
+ fill,
118
+ stroke: options.stroke ?? context.theme.background,
119
+ strokeWidth: 0.75
120
+ })
121
+ });
122
+ if (options.tip !== false) {
123
+ const center = fitted.centroid(shape);
124
+ const number = numericValue(value);
125
+ points.push({
126
+ key: `${id}:${name}`,
127
+ markId: id,
128
+ index,
129
+ datum: feature,
130
+ x: center.x,
131
+ y: center.y,
132
+ xValue: name,
133
+ yValue: value,
134
+ seriesLabel: options.label,
135
+ color: fill,
136
+ title: name,
137
+ value: value === void 0 ? "" : number === void 0 ? String(value) : context.formatY(number),
138
+ hit: { kind: "rect", rect: fitted.bounds(shape) }
139
+ });
140
+ }
141
+ }
142
+ return { nodes, points };
143
+ }
144
+ };
145
+ }
146
+ function geoDot(data, options) {
147
+ const longitudes = readChannel(data, options.longitude).map(numericValue);
148
+ const latitudes = readChannel(data, options.latitude).map(numericValue);
149
+ const names = readChannel(data, options.name);
150
+ const values = readChannel(data, options.value).map(numericValue);
151
+ const sized = options.r !== void 0 && typeof options.r !== "number";
152
+ const sizes = sized ? readChannel(data, options.r).map(
153
+ numericValue
154
+ ) : [];
155
+ const largest = Math.max(0, ...sizes.map((size) => Math.abs(size ?? 0)));
156
+ return {
157
+ id: options.id,
158
+ coordinate: "frame",
159
+ focusOrder: "point",
160
+ titles: { value: options.label },
161
+ channels: {},
162
+ render(context) {
163
+ const id = markId(options.id, "geoDot", context);
164
+ const fitted = context.projection;
165
+ if (fitted === void 0) {
166
+ return { nodes: [] };
167
+ }
168
+ const color = options.fill ?? context.paletteColor(context.markIndex);
169
+ const maxRadius = options.maxRadius ?? 16;
170
+ const nodes = [];
171
+ const points = [];
172
+ for (const [index, datum] of data.entries()) {
173
+ const longitude = longitudes[index];
174
+ const latitude = latitudes[index];
175
+ if (longitude === void 0 || latitude === void 0) continue;
176
+ const at = fitted.project(longitude, latitude);
177
+ if (at === void 0) continue;
178
+ const r = typeof options.r === "number" ? options.r : sized ? largest === 0 ? 0 : Math.sqrt(Math.abs(sizes[index] ?? 0) / largest) * maxRadius : 4;
179
+ const name = String(names[index] ?? index);
180
+ nodes.push({
181
+ kind: "circle",
182
+ key: `${id}:${index}`,
183
+ role: "mark",
184
+ cx: at.x,
185
+ cy: at.y,
186
+ r,
187
+ paint: {
188
+ fill: color,
189
+ fillOpacity: 0.75,
190
+ stroke: context.theme.background,
191
+ strokeWidth: 1
192
+ }
193
+ });
194
+ if (options.tip !== false) {
195
+ const value = values[index] ?? sizes[index];
196
+ points.push({
197
+ key: `${id}:${index}`,
198
+ markId: id,
199
+ index,
200
+ datum,
201
+ x: at.x,
202
+ y: at.y,
203
+ xValue: name,
204
+ yValue: value,
205
+ seriesLabel: options.label,
206
+ color,
207
+ title: name,
208
+ value: value === void 0 ? "" : context.formatY(value),
209
+ hit: {
210
+ kind: "rect",
211
+ rect: {
212
+ x: at.x - r - 2,
213
+ y: at.y - r - 2,
214
+ width: r * 2 + 4,
215
+ height: r * 2 + 4
216
+ }
217
+ }
218
+ });
219
+ }
220
+ }
221
+ return { nodes, points };
222
+ }
223
+ };
224
+ }
225
+ export {
226
+ geoDot,
227
+ geoShape,
228
+ projection,
229
+ rewind
230
+ };
231
+ //# sourceMappingURL=geo.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/geo/geo.ts"],
4
+ "sourcesContent": ["import {\n\ttype GeoPermissibleObjects,\n\ttype GeoProjection,\n\tgeoAlbersUsa,\n\tgeoArea,\n\tgeoConicConformal,\n\tgeoEqualEarth,\n\tgeoEquirectangular,\n\tgeoMercator,\n\tgeoNaturalEarth1,\n\tgeoOrthographic,\n\tgeoPath,\n} from \"d3-geo\";\nimport { isPlaceable, numericValue, readChannel } from \"#/core/channel.ts\";\nimport { markId, paint } from \"#/core/marks/shared.ts\";\nimport type {\n\tChartAccessor,\n\tChartFittedProjection,\n\tChartMark,\n\tChartPoint,\n\tChartProjection,\n\tChartValue,\n\tSceneNode,\n} from \"#/core/types.ts\";\n\nexport type ProjectionName =\n\t| \"equal-earth\"\n\t| \"natural-earth\"\n\t| \"mercator\"\n\t| \"equirectangular\"\n\t| \"orthographic\"\n\t| \"albers-usa\"\n\t/** Conformal conic on France's own standard parallels (Lambert 93's). */\n\t| \"france\";\n\nconst PROJECTIONS: Record<ProjectionName, () => GeoProjection> = {\n\t\"equal-earth\": geoEqualEarth,\n\t\"natural-earth\": geoNaturalEarth1,\n\tmercator: geoMercator,\n\tequirectangular: geoEquirectangular,\n\torthographic: geoOrthographic,\n\t\"albers-usa\": geoAlbersUsa as unknown as () => GeoProjection,\n\tfrance: () => geoConicConformal().parallels([44, 49]).rotate([-3, 0]),\n};\n\ntype Ring = ReadonlyArray<ReadonlyArray<number>>;\n\nfunction reverseRings(geometry: {\n\ttype: string;\n\tcoordinates?: unknown;\n}): unknown {\n\tif (geometry.type === \"Polygon\") {\n\t\treturn {\n\t\t\t...geometry,\n\t\t\tcoordinates: (geometry.coordinates as Ring[]).map((ring) =>\n\t\t\t\t[...ring].reverse(),\n\t\t\t),\n\t\t};\n\t}\n\tif (geometry.type === \"MultiPolygon\") {\n\t\treturn {\n\t\t\t...geometry,\n\t\t\tcoordinates: (geometry.coordinates as Ring[][]).map((polygon) =>\n\t\t\t\tpolygon.map((ring) => [...ring].reverse()),\n\t\t\t),\n\t\t};\n\t}\n\treturn geometry;\n}\n\n/**\n * GeoJSON as RFC 7946 writes it winds rings counter-clockwise; d3-geo reads\n * that as \"the whole sphere except this region\". A shape covering more than\n * half the globe is that mistake, so its rings are turned round.\n */\nexport function rewind<T>(object: T): T {\n\tconst value = object as {\n\t\ttype?: string;\n\t\tfeatures?: unknown[];\n\t\tgeometry?: { type: string };\n\t};\n\tif (value.type === \"FeatureCollection\" && Array.isArray(value.features)) {\n\t\treturn {\n\t\t\t...value,\n\t\t\tfeatures: value.features.map((feature) => rewind(feature)),\n\t\t} as T;\n\t}\n\tif (value.type === \"Feature\" && value.geometry) {\n\t\treturn geoArea(value as GeoPermissibleObjects) > 2 * Math.PI\n\t\t\t? ({ ...value, geometry: reverseRings(value.geometry) } as T)\n\t\t\t: object;\n\t}\n\treturn object;\n}\n\nexport interface ProjectionOptions {\n\t/** The GeoJSON the map should frame: usually the shapes it draws. */\n\treadonly domain: GeoPermissibleObjects;\n\t/** Pixels kept clear around the framed shape. */\n\treadonly inset?: number;\n}\n\n/**\n * How longitude and latitude become pixels, fitted so `domain` fills the\n * plot. A name picks one of the usual projections; any d3-geo projection\n * factory works too.\n */\nexport function projection(\n\tkind: ProjectionName | (() => GeoProjection),\n\toptions: ProjectionOptions,\n): ChartProjection {\n\treturn {\n\t\tfit(plot): ChartFittedProjection {\n\t\t\tconst inset = options.inset ?? 4;\n\t\t\tconst projected = (\n\t\t\t\ttypeof kind === \"function\" ? kind : PROJECTIONS[kind]\n\t\t\t)().fitExtent(\n\t\t\t\t[\n\t\t\t\t\t[plot.x + inset, plot.y + inset],\n\t\t\t\t\t[plot.x + plot.width - inset, plot.y + plot.height - inset],\n\t\t\t\t],\n\t\t\t\trewind(options.domain),\n\t\t\t);\n\t\t\tconst path = geoPath(projected);\n\t\t\treturn {\n\t\t\t\tproject(longitude, latitude) {\n\t\t\t\t\tconst point = projected([longitude, latitude]);\n\t\t\t\t\treturn point ? { x: point[0], y: point[1] } : undefined;\n\t\t\t\t},\n\t\t\t\tpath: (geometry) => path(geometry as GeoPermissibleObjects) ?? \"\",\n\t\t\t\tcentroid(geometry) {\n\t\t\t\t\tconst [x, y] = path.centroid(geometry as GeoPermissibleObjects);\n\t\t\t\t\treturn { x, y };\n\t\t\t\t},\n\t\t\t\tbounds(geometry) {\n\t\t\t\t\tconst [[x0, y0], [x1, y1]] = path.bounds(\n\t\t\t\t\t\tgeometry as GeoPermissibleObjects,\n\t\t\t\t\t);\n\t\t\t\t\treturn { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\ninterface Feature {\n\treadonly type: \"Feature\";\n\treadonly properties?: Record<string, unknown> | null;\n\treadonly geometry: unknown;\n}\n\nexport interface GeoShapeOptions<TFeature> {\n\treadonly id?: string;\n\t/** A region's name: tooltip, table, live region. */\n\treadonly name: ChartAccessor<TFeature, unknown>;\n\t/** A value per region: a choropleth on a sequential (numbers) or ordinal (categories) color scale. */\n\treadonly color?: ChartAccessor<TFeature, ChartValue>;\n\treadonly fill?: string;\n\treadonly stroke?: string;\n\t/** What the colour values are, for the table heading. */\n\treadonly label?: string;\n\treadonly tip?: boolean;\n}\n\n/** Regions, countries, d\u00E9partements: one shape per GeoJSON feature. */\nexport function geoShape<TFeature extends Feature>(\n\tfeatures: ReadonlyArray<TFeature>,\n\toptions: GeoShapeOptions<TFeature>,\n): ChartMark {\n\tconst names = readChannel(features, options.name);\n\tconst colors = readChannel(features, options.color);\n\treturn {\n\t\tid: options.id,\n\t\tcoordinate: \"frame\",\n\t\tfocusOrder: \"point\",\n\t\ttitles: { value: options.label },\n\t\tchannels:\n\t\t\toptions.color === undefined\n\t\t\t\t? {}\n\t\t\t\t: { color: { values: colors.filter(isPlaceable) } },\n\t\trender(context) {\n\t\t\tconst id = markId(options.id, \"geo\", context);\n\t\t\tconst fitted = context.projection;\n\t\t\tif (fitted === undefined) {\n\t\t\t\treturn { nodes: [] };\n\t\t\t}\n\t\t\tconst nodes: SceneNode[] = [];\n\t\t\tconst points: ChartPoint[] = [];\n\t\t\tfor (const [index, feature] of features.entries()) {\n\t\t\t\tconst name = String(names[index] ?? index);\n\t\t\t\tconst value = colors[index];\n\t\t\t\tconst fill =\n\t\t\t\t\toptions.fill ??\n\t\t\t\t\t(value === undefined || options.color === undefined\n\t\t\t\t\t\t? context.theme.grid\n\t\t\t\t\t\t: context.colorOf(value));\n\t\t\t\tconst shape = rewind(feature);\n\t\t\t\tconst d = fitted.path(shape);\n\t\t\t\tif (d === \"\") continue;\n\t\t\t\tnodes.push({\n\t\t\t\t\tkind: \"path\",\n\t\t\t\t\tkey: `${id}:${name}`,\n\t\t\t\t\trole: \"mark\",\n\t\t\t\t\td,\n\t\t\t\t\tpaint: paint({\n\t\t\t\t\t\tfill,\n\t\t\t\t\t\tstroke: options.stroke ?? context.theme.background,\n\t\t\t\t\t\tstrokeWidth: 0.75,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t\tif (options.tip !== false) {\n\t\t\t\t\tconst center = fitted.centroid(shape);\n\t\t\t\t\tconst number = numericValue(value);\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tkey: `${id}:${name}`,\n\t\t\t\t\t\tmarkId: id,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tdatum: feature,\n\t\t\t\t\t\tx: center.x,\n\t\t\t\t\t\ty: center.y,\n\t\t\t\t\t\txValue: name,\n\t\t\t\t\t\tyValue: value,\n\t\t\t\t\t\tseriesLabel: options.label,\n\t\t\t\t\t\tcolor: fill,\n\t\t\t\t\t\ttitle: name,\n\t\t\t\t\t\tvalue:\n\t\t\t\t\t\t\tvalue === undefined\n\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t: number === undefined\n\t\t\t\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t\t\t\t: context.formatY(number),\n\t\t\t\t\t\thit: { kind: \"rect\", rect: fitted.bounds(shape) },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { nodes, points };\n\t\t},\n\t};\n}\n\nexport interface GeoDotOptions<TDatum> {\n\treadonly id?: string;\n\treadonly longitude: ChartAccessor<TDatum, ChartValue>;\n\treadonly latitude: ChartAccessor<TDatum, ChartValue>;\n\treadonly name: ChartAccessor<TDatum, unknown>;\n\t/** A radius in pixels, or a field whose values set each dot's area. */\n\treadonly r?: number | ChartAccessor<TDatum, ChartValue>;\n\treadonly maxRadius?: number;\n\treadonly fill?: string;\n\treadonly label?: string;\n\treadonly value?: ChartAccessor<TDatum, ChartValue>;\n\treadonly tip?: boolean;\n}\n\n/** Places on the map: a dot at each longitude and latitude, sized by a value if asked. */\nexport function geoDot<TDatum>(\n\tdata: ReadonlyArray<TDatum>,\n\toptions: GeoDotOptions<TDatum>,\n): ChartMark {\n\tconst longitudes = readChannel(data, options.longitude).map(numericValue);\n\tconst latitudes = readChannel(data, options.latitude).map(numericValue);\n\tconst names = readChannel(data, options.name);\n\tconst values = readChannel(data, options.value).map(numericValue);\n\tconst sized = options.r !== undefined && typeof options.r !== \"number\";\n\tconst sizes = sized\n\t\t? readChannel(data, options.r as ChartAccessor<TDatum, ChartValue>).map(\n\t\t\t\tnumericValue,\n\t\t\t)\n\t\t: [];\n\tconst largest = Math.max(0, ...sizes.map((size) => Math.abs(size ?? 0)));\n\treturn {\n\t\tid: options.id,\n\t\tcoordinate: \"frame\",\n\t\tfocusOrder: \"point\",\n\t\ttitles: { value: options.label },\n\t\tchannels: {},\n\t\trender(context) {\n\t\t\tconst id = markId(options.id, \"geoDot\", context);\n\t\t\tconst fitted = context.projection;\n\t\t\tif (fitted === undefined) {\n\t\t\t\treturn { nodes: [] };\n\t\t\t}\n\t\t\tconst color = options.fill ?? context.paletteColor(context.markIndex);\n\t\t\tconst maxRadius = options.maxRadius ?? 16;\n\t\t\tconst nodes: SceneNode[] = [];\n\t\t\tconst points: ChartPoint[] = [];\n\t\t\tfor (const [index, datum] of data.entries()) {\n\t\t\t\tconst longitude = longitudes[index];\n\t\t\t\tconst latitude = latitudes[index];\n\t\t\t\tif (longitude === undefined || latitude === undefined) continue;\n\t\t\t\tconst at = fitted.project(longitude, latitude);\n\t\t\t\tif (at === undefined) continue;\n\t\t\t\tconst r =\n\t\t\t\t\ttypeof options.r === \"number\"\n\t\t\t\t\t\t? options.r\n\t\t\t\t\t\t: sized\n\t\t\t\t\t\t\t? largest === 0\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: Math.sqrt(Math.abs(sizes[index] ?? 0) / largest) * maxRadius\n\t\t\t\t\t\t\t: 4;\n\t\t\t\tconst name = String(names[index] ?? index);\n\t\t\t\tnodes.push({\n\t\t\t\t\tkind: \"circle\",\n\t\t\t\t\tkey: `${id}:${index}`,\n\t\t\t\t\trole: \"mark\",\n\t\t\t\t\tcx: at.x,\n\t\t\t\t\tcy: at.y,\n\t\t\t\t\tr,\n\t\t\t\t\tpaint: {\n\t\t\t\t\t\tfill: color,\n\t\t\t\t\t\tfillOpacity: 0.75,\n\t\t\t\t\t\tstroke: context.theme.background,\n\t\t\t\t\t\tstrokeWidth: 1,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (options.tip !== false) {\n\t\t\t\t\tconst value = values[index] ?? sizes[index];\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tkey: `${id}:${index}`,\n\t\t\t\t\t\tmarkId: id,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tdatum,\n\t\t\t\t\t\tx: at.x,\n\t\t\t\t\t\ty: at.y,\n\t\t\t\t\t\txValue: name,\n\t\t\t\t\t\tyValue: value,\n\t\t\t\t\t\tseriesLabel: options.label,\n\t\t\t\t\t\tcolor,\n\t\t\t\t\t\ttitle: name,\n\t\t\t\t\t\tvalue: value === undefined ? \"\" : context.formatY(value),\n\t\t\t\t\t\thit: {\n\t\t\t\t\t\t\tkind: \"rect\",\n\t\t\t\t\t\t\trect: {\n\t\t\t\t\t\t\t\tx: at.x - r - 2,\n\t\t\t\t\t\t\t\ty: at.y - r - 2,\n\t\t\t\t\t\t\t\twidth: r * 2 + 4,\n\t\t\t\t\t\t\t\theight: r * 2 + 4,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { nodes, points };\n\t\t},\n\t};\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAGC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,cAAc,mBAAmB;AACvD,SAAS,QAAQ,aAAa;AAqB9B,MAAM,cAA2D;AAAA,EAChE,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,i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,MAAM,WAClB,QAAQ,IACR,QACC,YAAY,IACX,IACA,KAAK,KAAK,KAAK,IAAI,MAAM,KAAK,KAAK,CAAC,IAAI,OAAO,IAAI,YACpD;AACL,cAAM,OAAO,OAAO,MAAM,KAAK,KAAK,KAAK;AACzC,cAAM,KAAK;AAAA,UACV,MAAM;AAAA,UACN,KAAK,GAAG,EAAE,IAAI,KAAK;AAAA,UACnB,MAAM;AAAA,UACN,IAAI,GAAG;AAAA,UACP,IAAI,GAAG;AAAA,UACP;AAAA,UACA,OAAO;AAAA,YACN,MAAM;AAAA,YACN,aAAa;AAAA,YACb,QAAQ,QAAQ,MAAM;AAAA,YACtB,aAAa;AAAA,UACd;AAAA,QACD,CAAC;AACD,YAAI,QAAQ,QAAQ,OAAO;AAC1B,gBAAM,QAAQ,OAAO,KAAK,KAAK,MAAM,KAAK;AAC1C,iBAAO,KAAK;AAAA,YACX,KAAK,GAAG,EAAE,IAAI,KAAK;AAAA,YACnB,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA,GAAG,GAAG;AAAA,YACN,GAAG,GAAG;AAAA,YACN,QAAQ;AAAA,YACR,QAAQ;AAAA,YACR,aAAa,QAAQ;AAAA,YACrB;AAAA,YACA,OAAO;AAAA,YACP,OAAO,UAAU,SAAY,KAAK,QAAQ,QAAQ,KAAK;AAAA,YACvD,KAAK;AAAA,cACJ,MAAM;AAAA,cACN,MAAM;AAAA,gBACL,GAAG,GAAG,IAAI,IAAI;AAAA,gBACd,GAAG,GAAG,IAAI,IAAI;AAAA,gBACd,OAAO,IAAI,IAAI;AAAA,gBACf,QAAQ,IAAI,IAAI;AAAA,cACjB;AAAA,YACD;AAAA,UACD,CAAC;AAAA,QACF;AAAA,MACD;AACA,aAAO,EAAE,OAAO,OAAO;AAAA,IACxB;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export { type GeoDotOptions, type GeoShapeOptions, geoDot, geoShape, type ProjectionName, type ProjectionOptions, projection, rewind, } from "./geo.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,MAAM,EACN,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,UAAU,EACV,MAAM,GACN,MAAM,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ import {
2
+ geoDot,
3
+ geoShape,
4
+ projection,
5
+ rewind
6
+ } from "./geo.js";
7
+ export {
8
+ geoDot,
9
+ geoShape,
10
+ projection,
11
+ rewind
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/geo/index.ts"],
4
+ "sourcesContent": ["export {\n\ttype GeoDotOptions,\n\ttype GeoShapeOptions,\n\tgeoDot,\n\tgeoShape,\n\ttype ProjectionName,\n\ttype ProjectionOptions,\n\tprojection,\n\trewind,\n} from \"#/geo/geo.ts\";\n"],
5
+ "mappings": "AAAA;AAAA,EAGC;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,OACM;",
6
+ "names": []
7
+ }
@@ -0,0 +1,24 @@
1
+ import type { ChartMark } from "../core/types.js";
2
+ /**
3
+ * Nested data: a treemap, a sunburst, a tree. Each takes one root and reads
4
+ * its children, value and name through accessors, so any nested shape works.
5
+ * Colours follow the root's direct children (the branches the legend lists);
6
+ * deeper levels keep their branch's colour.
7
+ */
8
+ export interface HierarchyOptions<TNode> {
9
+ readonly id?: string;
10
+ readonly children?: (node: TNode) => ReadonlyArray<TNode> | undefined;
11
+ /** A leaf's size. Branches sum their leaves. */
12
+ readonly value?: (node: TNode) => number;
13
+ readonly name: (node: TNode) => string;
14
+ /** What the values are, for the table heading. */
15
+ readonly label?: string;
16
+ readonly tip?: boolean;
17
+ }
18
+ /** Rectangles nested inside rectangles, each leaf as large as its value. */
19
+ export declare function treemapMark<TNode>(root: TNode, options: HierarchyOptions<TNode>): ChartMark;
20
+ /** Rings of arcs: the root's children on the first ring, theirs on the next. */
21
+ export declare function sunburstMark<TNode>(root: TNode, options: HierarchyOptions<TNode>): ChartMark;
22
+ /** A node-link tree, root on the left, leaves on the right, every node named. */
23
+ export declare function treeMark<TNode>(root: TNode, options: HierarchyOptions<TNode>): ChartMark;
24
+ //# sourceMappingURL=hierarchy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hierarchy.d.ts","sourceRoot":"","sources":["../../src/hierarchy/hierarchy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACX,SAAS,EAIT,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB,CAAC,KAAK;IACtC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IACtE,gDAAgD;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACvC,kDAAkD;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACvB;AAiGD,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,KAAK,EAChC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC9B,SAAS,CA+EX;AAED,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,KAAK,EACjC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC9B,SAAS,CA8DX;AAKD,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,KAAK,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC9B,SAAS,CAqFX"}
@@ -0,0 +1,279 @@
1
+ import {
2
+ hierarchy,
3
+ partition,
4
+ tree,
5
+ treemap
6
+ } from "d3-hierarchy";
7
+ import { truncate } from "../core/guides/axes.js";
8
+ import { markId } from "../core/marks/shared.js";
9
+ import { arcPath, polarToCartesian } from "../core/paths.js";
10
+ function rooted(root, options) {
11
+ const node = hierarchy(
12
+ root,
13
+ (datum) => options.children?.(datum) ?? datum.children
14
+ );
15
+ return node.sum((datum) => options.value ? Math.max(0, options.value(datum)) : 0).sort((left, right) => (right.value ?? 0) - (left.value ?? 0));
16
+ }
17
+ function branchOf(node) {
18
+ let current = node;
19
+ while (current.parent?.parent) {
20
+ current = current.parent;
21
+ }
22
+ return current;
23
+ }
24
+ function pathName(node, options) {
25
+ return node.ancestors().reverse().slice(1).map((ancestor) => options.name(ancestor.data)).join(" \u203A ");
26
+ }
27
+ function branchNames(root, options) {
28
+ return (rooted(root, options).children ?? []).map(
29
+ (child) => options.name(child.data)
30
+ );
31
+ }
32
+ function nodeKey(node, options) {
33
+ return node.ancestors().map((ancestor) => options.name(ancestor.data)).reverse().join("/");
34
+ }
35
+ function colorFor(node, options, context) {
36
+ return node.depth === 0 ? context.theme.muted : context.colorOf(options.name(branchOf(node).data));
37
+ }
38
+ function pointFor(id, node, options, context, index, at, hit) {
39
+ return {
40
+ key: `${id}:${nodeKey(node, options)}`,
41
+ markId: id,
42
+ index,
43
+ datum: node.data,
44
+ x: at.x,
45
+ y: at.y,
46
+ xValue: options.name(node.data),
47
+ yValue: node.value ?? 0,
48
+ series: options.name(branchOf(node).data),
49
+ seriesLabel: options.label,
50
+ color: colorFor(node, options, context),
51
+ title: pathName(node, options) || options.name(node.data),
52
+ value: context.formatY(node.value ?? 0),
53
+ hit
54
+ };
55
+ }
56
+ const LABEL_PADDING = 4;
57
+ const MIN_LABEL_HEIGHT = 16;
58
+ function treemapMark(root, options) {
59
+ return {
60
+ id: options.id,
61
+ coordinate: "frame",
62
+ focusOrder: "point",
63
+ titles: { value: options.label },
64
+ channels: { color: { values: branchNames(root, options) } },
65
+ render(context) {
66
+ const id = markId(options.id, "treemap", context);
67
+ const { plot, theme } = context;
68
+ const laid = treemap().size([plot.width, plot.height]).paddingInner(2).round(true)(rooted(root, options));
69
+ const nodes = [];
70
+ const points = [];
71
+ for (const [index, leaf] of laid.leaves().entries()) {
72
+ const rect = {
73
+ x: plot.x + leaf.x0,
74
+ y: plot.y + leaf.y0,
75
+ width: Math.max(0, leaf.x1 - leaf.x0),
76
+ height: Math.max(0, leaf.y1 - leaf.y0)
77
+ };
78
+ const key = nodeKey(leaf, options);
79
+ const series = options.name(branchOf(leaf).data);
80
+ nodes.push({
81
+ kind: "rect",
82
+ key: `${id}:${key}`,
83
+ series,
84
+ role: "mark",
85
+ ...rect,
86
+ corners: [3, 3, 3, 3],
87
+ paint: {
88
+ fill: colorFor(leaf, options, context),
89
+ fillOpacity: 0.55 + 0.45 / leaf.depth
90
+ }
91
+ });
92
+ if (rect.height >= MIN_LABEL_HEIGHT && rect.width > theme.fontSize * 2) {
93
+ nodes.push({
94
+ kind: "text",
95
+ key: `${id}:label:${key}`,
96
+ series,
97
+ role: "label",
98
+ x: rect.x + LABEL_PADDING,
99
+ y: rect.y + LABEL_PADDING,
100
+ text: truncate(
101
+ options.name(leaf.data),
102
+ rect.width - LABEL_PADDING * 2,
103
+ theme.fontSize,
104
+ context.measureText
105
+ ),
106
+ paint: {
107
+ fill: theme.background,
108
+ fontSize: theme.fontSize,
109
+ fontWeight: 600,
110
+ baseline: "top"
111
+ }
112
+ });
113
+ }
114
+ if (options.tip !== false) {
115
+ points.push(
116
+ pointFor(
117
+ id,
118
+ leaf,
119
+ options,
120
+ context,
121
+ index,
122
+ { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
123
+ { kind: "rect", rect }
124
+ )
125
+ );
126
+ }
127
+ }
128
+ return { nodes, points };
129
+ }
130
+ };
131
+ }
132
+ function sunburstMark(root, options) {
133
+ return {
134
+ id: options.id,
135
+ coordinate: "frame",
136
+ focusOrder: "point",
137
+ titles: { value: options.label },
138
+ channels: { color: { values: branchNames(root, options) } },
139
+ render(context) {
140
+ const id = markId(options.id, "sunburst", context);
141
+ const { plot } = context;
142
+ const radius = Math.max(0, Math.min(plot.width, plot.height) / 2 - 4);
143
+ const cx = plot.x + plot.width / 2;
144
+ const cy = plot.y + plot.height / 2;
145
+ const laid = partition().size([360, radius])(
146
+ rooted(root, options)
147
+ );
148
+ const ringWidth = radius / (laid.height + 1);
149
+ const nodes = [];
150
+ const points = [];
151
+ const descendants = laid.descendants().filter((node) => node.depth > 0 && node.x1 - node.x0 > 0.2);
152
+ for (const [index, node] of descendants.entries()) {
153
+ const shape = {
154
+ cx,
155
+ cy,
156
+ innerRadius: node.depth * ringWidth,
157
+ outerRadius: (node.depth + 1) * ringWidth - 1,
158
+ startAngle: node.x0 + 0.25,
159
+ endAngle: node.x1 - 0.25
160
+ };
161
+ const series = options.name(branchOf(node).data);
162
+ nodes.push({
163
+ kind: "path",
164
+ key: `${id}:${nodeKey(node, options)}`,
165
+ series,
166
+ role: "mark",
167
+ d: arcPath(shape),
168
+ paint: {
169
+ fill: colorFor(node, options, context),
170
+ fillOpacity: 1 - (node.depth - 1) * 0.18
171
+ }
172
+ });
173
+ if (options.tip !== false) {
174
+ const anchor = polarToCartesian(
175
+ cx,
176
+ cy,
177
+ (shape.innerRadius + shape.outerRadius) / 2,
178
+ (shape.startAngle + shape.endAngle) / 2
179
+ );
180
+ points.push(
181
+ pointFor(id, node, options, context, index, anchor, {
182
+ kind: "arc",
183
+ ...shape
184
+ })
185
+ );
186
+ }
187
+ }
188
+ return { nodes, points };
189
+ }
190
+ };
191
+ }
192
+ const NODE_RADIUS = 4;
193
+ const LABEL_GAP = 6;
194
+ function treeMark(root, options) {
195
+ return {
196
+ id: options.id,
197
+ coordinate: "frame",
198
+ focusOrder: "point",
199
+ titles: { value: options.label },
200
+ channels: {},
201
+ render(context) {
202
+ const id = markId(options.id, "tree", context);
203
+ const { plot, theme, measureText } = context;
204
+ const rootNode = rooted(root, options);
205
+ const leafLabel = Math.max(
206
+ 0,
207
+ ...rootNode.leaves().map((leaf) => measureText(options.name(leaf.data), theme.fontSize))
208
+ );
209
+ const width = Math.max(
210
+ 0,
211
+ plot.width - leafLabel - LABEL_GAP - NODE_RADIUS * 2
212
+ );
213
+ const laid = tree().size([plot.height, width])(
214
+ rootNode
215
+ );
216
+ const position = (node) => ({
217
+ x: plot.x + NODE_RADIUS + (node.y ?? 0),
218
+ y: plot.y + (node.x ?? 0)
219
+ });
220
+ const nodes = [];
221
+ const points = [];
222
+ for (const link of laid.links()) {
223
+ const from = position(link.source);
224
+ const to = position(link.target);
225
+ const middle = (from.x + to.x) / 2;
226
+ nodes.push({
227
+ kind: "path",
228
+ key: `${id}:link:${nodeKey(link.target, options)}`,
229
+ role: "grid",
230
+ d: `M${from.x},${from.y}C${middle},${from.y} ${middle},${to.y} ${to.x},${to.y}`,
231
+ paint: { fill: "none", stroke: theme.grid, strokeWidth: 1.5 }
232
+ });
233
+ }
234
+ for (const [index, node] of laid.descendants().entries()) {
235
+ const at = position(node);
236
+ const leaf = node.children === void 0;
237
+ nodes.push(
238
+ {
239
+ kind: "circle",
240
+ key: `${id}:${nodeKey(node, options)}`,
241
+ role: "mark",
242
+ cx: at.x,
243
+ cy: at.y,
244
+ r: NODE_RADIUS,
245
+ paint: {
246
+ fill: leaf ? theme.background : colorFor(node, options, context),
247
+ stroke: colorFor(node, options, context),
248
+ strokeWidth: 1.5
249
+ }
250
+ },
251
+ {
252
+ kind: "text",
253
+ key: `${id}:label:${nodeKey(node, options)}`,
254
+ role: "label",
255
+ x: at.x + (leaf ? LABEL_GAP + NODE_RADIUS : -(LABEL_GAP + NODE_RADIUS)),
256
+ y: at.y,
257
+ text: options.name(node.data),
258
+ paint: {
259
+ fill: theme.foreground,
260
+ fontSize: theme.fontSize,
261
+ textAnchor: leaf ? "start" : "end",
262
+ baseline: "middle"
263
+ }
264
+ }
265
+ );
266
+ if (options.tip !== false) {
267
+ points.push(pointFor(id, node, options, context, index, at));
268
+ }
269
+ }
270
+ return { nodes, points };
271
+ }
272
+ };
273
+ }
274
+ export {
275
+ sunburstMark,
276
+ treeMark,
277
+ treemapMark
278
+ };
279
+ //# sourceMappingURL=hierarchy.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hierarchy/hierarchy.ts"],
4
+ "sourcesContent": ["import {\n\ttype HierarchyNode,\n\ttype HierarchyRectangularNode,\n\thierarchy,\n\tpartition,\n\ttree,\n\ttreemap,\n} from \"d3-hierarchy\";\nimport { truncate } from \"#/core/guides/axes.ts\";\nimport { markId } from \"#/core/marks/shared.ts\";\nimport { arcPath, polarToCartesian } from \"#/core/paths.ts\";\nimport type {\n\tChartMark,\n\tChartMarkContext,\n\tChartPoint,\n\tSceneNode,\n} from \"#/core/types.ts\";\n\n/**\n * Nested data: a treemap, a sunburst, a tree. Each takes one root and reads\n * its children, value and name through accessors, so any nested shape works.\n * Colours follow the root's direct children (the branches the legend lists);\n * deeper levels keep their branch's colour.\n */\n\nexport interface HierarchyOptions<TNode> {\n\treadonly id?: string;\n\treadonly children?: (node: TNode) => ReadonlyArray<TNode> | undefined;\n\t/** A leaf's size. Branches sum their leaves. */\n\treadonly value?: (node: TNode) => number;\n\treadonly name: (node: TNode) => string;\n\t/** What the values are, for the table heading. */\n\treadonly label?: string;\n\treadonly tip?: boolean;\n}\n\nfunction rooted<TNode>(\n\troot: TNode,\n\toptions: HierarchyOptions<TNode>,\n): HierarchyNode<TNode> {\n\tconst node = hierarchy(\n\t\troot,\n\t\t(datum) =>\n\t\t\t(options.children?.(datum) as TNode[] | undefined) ??\n\t\t\t(datum as { children?: TNode[] }).children,\n\t);\n\treturn node\n\t\t.sum((datum) => (options.value ? Math.max(0, options.value(datum)) : 0))\n\t\t.sort((left, right) => (right.value ?? 0) - (left.value ?? 0));\n}\n\nfunction branchOf<TNode>(node: HierarchyNode<TNode>): HierarchyNode<TNode> {\n\tlet current = node;\n\twhile (current.parent?.parent) {\n\t\tcurrent = current.parent;\n\t}\n\treturn current;\n}\n\nfunction pathName<TNode>(\n\tnode: HierarchyNode<TNode>,\n\toptions: HierarchyOptions<TNode>,\n): string {\n\treturn node\n\t\t.ancestors()\n\t\t.reverse()\n\t\t.slice(1)\n\t\t.map((ancestor) => options.name(ancestor.data))\n\t\t.join(\" \u203A \");\n}\n\nfunction branchNames<TNode>(\n\troot: TNode,\n\toptions: HierarchyOptions<TNode>,\n): string[] {\n\treturn (rooted(root, options).children ?? []).map((child) =>\n\t\toptions.name(child.data),\n\t);\n}\n\nfunction nodeKey<TNode>(\n\tnode: HierarchyNode<TNode>,\n\toptions: HierarchyOptions<TNode>,\n): string {\n\treturn node\n\t\t.ancestors()\n\t\t.map((ancestor) => options.name(ancestor.data))\n\t\t.reverse()\n\t\t.join(\"/\");\n}\n\nfunction colorFor<TNode>(\n\tnode: HierarchyNode<TNode>,\n\toptions: HierarchyOptions<TNode>,\n\tcontext: ChartMarkContext,\n): string {\n\treturn node.depth === 0\n\t\t? context.theme.muted\n\t\t: context.colorOf(options.name(branchOf(node).data));\n}\n\nfunction pointFor<TNode>(\n\tid: string,\n\tnode: HierarchyNode<TNode>,\n\toptions: HierarchyOptions<TNode>,\n\tcontext: ChartMarkContext,\n\tindex: number,\n\tat: { x: number; y: number },\n\thit?: ChartPoint[\"hit\"],\n): ChartPoint {\n\treturn {\n\t\tkey: `${id}:${nodeKey(node, options)}`,\n\t\tmarkId: id,\n\t\tindex,\n\t\tdatum: node.data,\n\t\tx: at.x,\n\t\ty: at.y,\n\t\txValue: options.name(node.data),\n\t\tyValue: node.value ?? 0,\n\t\tseries: options.name(branchOf(node).data),\n\t\tseriesLabel: options.label,\n\t\tcolor: colorFor(node, options, context),\n\t\ttitle: pathName(node, options) || options.name(node.data),\n\t\tvalue: context.formatY(node.value ?? 0),\n\t\thit,\n\t};\n}\n\nconst LABEL_PADDING = 4;\nconst MIN_LABEL_HEIGHT = 16;\n\n/** Rectangles nested inside rectangles, each leaf as large as its value. */\nexport function treemapMark<TNode>(\n\troot: TNode,\n\toptions: HierarchyOptions<TNode>,\n): ChartMark {\n\treturn {\n\t\tid: options.id,\n\t\tcoordinate: \"frame\",\n\t\tfocusOrder: \"point\",\n\t\ttitles: { value: options.label },\n\t\tchannels: { color: { values: branchNames(root, options) } },\n\t\trender(context) {\n\t\t\tconst id = markId(options.id, \"treemap\", context);\n\t\t\tconst { plot, theme } = context;\n\t\t\tconst laid = treemap<TNode>()\n\t\t\t\t.size([plot.width, plot.height])\n\t\t\t\t.paddingInner(2)\n\t\t\t\t.round(true)(rooted(root, options));\n\t\t\tconst nodes: SceneNode[] = [];\n\t\t\tconst points: ChartPoint[] = [];\n\t\t\tfor (const [index, leaf] of laid.leaves().entries()) {\n\t\t\t\tconst rect = {\n\t\t\t\t\tx: plot.x + leaf.x0,\n\t\t\t\t\ty: plot.y + leaf.y0,\n\t\t\t\t\twidth: Math.max(0, leaf.x1 - leaf.x0),\n\t\t\t\t\theight: Math.max(0, leaf.y1 - leaf.y0),\n\t\t\t\t};\n\t\t\t\tconst key = nodeKey(leaf, options);\n\t\t\t\tconst series = options.name(branchOf(leaf).data);\n\t\t\t\tnodes.push({\n\t\t\t\t\tkind: \"rect\",\n\t\t\t\t\tkey: `${id}:${key}`,\n\t\t\t\t\tseries,\n\t\t\t\t\trole: \"mark\",\n\t\t\t\t\t...rect,\n\t\t\t\t\tcorners: [3, 3, 3, 3],\n\t\t\t\t\tpaint: {\n\t\t\t\t\t\tfill: colorFor(leaf, options, context),\n\t\t\t\t\t\tfillOpacity: 0.55 + 0.45 / leaf.depth,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\trect.height >= MIN_LABEL_HEIGHT &&\n\t\t\t\t\trect.width > theme.fontSize * 2\n\t\t\t\t) {\n\t\t\t\t\tnodes.push({\n\t\t\t\t\t\tkind: \"text\",\n\t\t\t\t\t\tkey: `${id}:label:${key}`,\n\t\t\t\t\t\tseries,\n\t\t\t\t\t\trole: \"label\",\n\t\t\t\t\t\tx: rect.x + LABEL_PADDING,\n\t\t\t\t\t\ty: rect.y + LABEL_PADDING,\n\t\t\t\t\t\ttext: truncate(\n\t\t\t\t\t\t\toptions.name(leaf.data),\n\t\t\t\t\t\t\trect.width - LABEL_PADDING * 2,\n\t\t\t\t\t\t\ttheme.fontSize,\n\t\t\t\t\t\t\tcontext.measureText,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tpaint: {\n\t\t\t\t\t\t\tfill: theme.background,\n\t\t\t\t\t\t\tfontSize: theme.fontSize,\n\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\tbaseline: \"top\",\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (options.tip !== false) {\n\t\t\t\t\tpoints.push(\n\t\t\t\t\t\tpointFor(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tleaf,\n\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t{ x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },\n\t\t\t\t\t\t\t{ kind: \"rect\", rect },\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { nodes, points };\n\t\t},\n\t};\n}\n\n/** Rings of arcs: the root's children on the first ring, theirs on the next. */\nexport function sunburstMark<TNode>(\n\troot: TNode,\n\toptions: HierarchyOptions<TNode>,\n): ChartMark {\n\treturn {\n\t\tid: options.id,\n\t\tcoordinate: \"frame\",\n\t\tfocusOrder: \"point\",\n\t\ttitles: { value: options.label },\n\t\tchannels: { color: { values: branchNames(root, options) } },\n\t\trender(context) {\n\t\t\tconst id = markId(options.id, \"sunburst\", context);\n\t\t\tconst { plot } = context;\n\t\t\tconst radius = Math.max(0, Math.min(plot.width, plot.height) / 2 - 4);\n\t\t\tconst cx = plot.x + plot.width / 2;\n\t\t\tconst cy = plot.y + plot.height / 2;\n\t\t\tconst laid = partition<TNode>().size([360, radius])(\n\t\t\t\trooted(root, options),\n\t\t\t);\n\t\t\t// The root's ring would be a disc in the middle: leave it empty.\n\t\t\tconst ringWidth = radius / (laid.height + 1);\n\t\t\tconst nodes: SceneNode[] = [];\n\t\t\tconst points: ChartPoint[] = [];\n\t\t\tconst descendants = laid\n\t\t\t\t.descendants()\n\t\t\t\t.filter((node) => node.depth > 0 && node.x1 - node.x0 > 0.2);\n\t\t\tfor (const [index, node] of descendants.entries()) {\n\t\t\t\tconst shape = {\n\t\t\t\t\tcx,\n\t\t\t\t\tcy,\n\t\t\t\t\tinnerRadius: node.depth * ringWidth,\n\t\t\t\t\touterRadius: (node.depth + 1) * ringWidth - 1,\n\t\t\t\t\tstartAngle: node.x0 + 0.25,\n\t\t\t\t\tendAngle: node.x1 - 0.25,\n\t\t\t\t};\n\t\t\t\tconst series = options.name(branchOf(node).data);\n\t\t\t\tnodes.push({\n\t\t\t\t\tkind: \"path\",\n\t\t\t\t\tkey: `${id}:${nodeKey(node, options)}`,\n\t\t\t\t\tseries,\n\t\t\t\t\trole: \"mark\",\n\t\t\t\t\td: arcPath(shape),\n\t\t\t\t\tpaint: {\n\t\t\t\t\t\tfill: colorFor(node, options, context),\n\t\t\t\t\t\tfillOpacity: 1 - (node.depth - 1) * 0.18,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (options.tip !== false) {\n\t\t\t\t\tconst anchor = polarToCartesian(\n\t\t\t\t\t\tcx,\n\t\t\t\t\t\tcy,\n\t\t\t\t\t\t(shape.innerRadius + shape.outerRadius) / 2,\n\t\t\t\t\t\t(shape.startAngle + shape.endAngle) / 2,\n\t\t\t\t\t);\n\t\t\t\t\tpoints.push(\n\t\t\t\t\t\tpointFor(id, node, options, context, index, anchor, {\n\t\t\t\t\t\t\tkind: \"arc\",\n\t\t\t\t\t\t\t...shape,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { nodes, points };\n\t\t},\n\t};\n}\n\nconst NODE_RADIUS = 4;\nconst LABEL_GAP = 6;\n\n/** A node-link tree, root on the left, leaves on the right, every node named. */\nexport function treeMark<TNode>(\n\troot: TNode,\n\toptions: HierarchyOptions<TNode>,\n): ChartMark {\n\treturn {\n\t\tid: options.id,\n\t\tcoordinate: \"frame\",\n\t\tfocusOrder: \"point\",\n\t\ttitles: { value: options.label },\n\t\tchannels: {},\n\t\trender(context) {\n\t\t\tconst id = markId(options.id, \"tree\", context);\n\t\t\tconst { plot, theme, measureText } = context;\n\t\t\tconst rootNode = rooted(root, options);\n\t\t\tconst leafLabel = Math.max(\n\t\t\t\t0,\n\t\t\t\t...rootNode\n\t\t\t\t\t.leaves()\n\t\t\t\t\t.map((leaf) => measureText(options.name(leaf.data), theme.fontSize)),\n\t\t\t);\n\t\t\tconst width = Math.max(\n\t\t\t\t0,\n\t\t\t\tplot.width - leafLabel - LABEL_GAP - NODE_RADIUS * 2,\n\t\t\t);\n\t\t\tconst laid = tree<TNode>().size([plot.height, width])(\n\t\t\t\trootNode,\n\t\t\t) as HierarchyRectangularNode<TNode> & HierarchyNode<TNode>;\n\t\t\tconst position = (\n\t\t\t\tnode: HierarchyNode<TNode> & { x?: number; y?: number },\n\t\t\t) => ({\n\t\t\t\tx: plot.x + NODE_RADIUS + (node.y ?? 0),\n\t\t\t\ty: plot.y + (node.x ?? 0),\n\t\t\t});\n\t\t\tconst nodes: SceneNode[] = [];\n\t\t\tconst points: ChartPoint[] = [];\n\t\t\tfor (const link of laid.links()) {\n\t\t\t\tconst from = position(link.source);\n\t\t\t\tconst to = position(link.target);\n\t\t\t\tconst middle = (from.x + to.x) / 2;\n\t\t\t\tnodes.push({\n\t\t\t\t\tkind: \"path\",\n\t\t\t\t\tkey: `${id}:link:${nodeKey(link.target, options)}`,\n\t\t\t\t\trole: \"grid\",\n\t\t\t\t\td: `M${from.x},${from.y}C${middle},${from.y} ${middle},${to.y} ${to.x},${to.y}`,\n\t\t\t\t\tpaint: { fill: \"none\", stroke: theme.grid, strokeWidth: 1.5 },\n\t\t\t\t});\n\t\t\t}\n\t\t\tfor (const [index, node] of laid.descendants().entries()) {\n\t\t\t\tconst at = position(node);\n\t\t\t\tconst leaf = node.children === undefined;\n\t\t\t\tnodes.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"circle\",\n\t\t\t\t\t\tkey: `${id}:${nodeKey(node, options)}`,\n\t\t\t\t\t\trole: \"mark\",\n\t\t\t\t\t\tcx: at.x,\n\t\t\t\t\t\tcy: at.y,\n\t\t\t\t\t\tr: NODE_RADIUS,\n\t\t\t\t\t\tpaint: {\n\t\t\t\t\t\t\tfill: leaf ? theme.background : colorFor(node, options, context),\n\t\t\t\t\t\t\tstroke: colorFor(node, options, context),\n\t\t\t\t\t\t\tstrokeWidth: 1.5,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"text\",\n\t\t\t\t\t\tkey: `${id}:label:${nodeKey(node, options)}`,\n\t\t\t\t\t\trole: \"label\",\n\t\t\t\t\t\tx:\n\t\t\t\t\t\t\tat.x +\n\t\t\t\t\t\t\t(leaf ? LABEL_GAP + NODE_RADIUS : -(LABEL_GAP + NODE_RADIUS)),\n\t\t\t\t\t\ty: at.y,\n\t\t\t\t\t\ttext: options.name(node.data),\n\t\t\t\t\t\tpaint: {\n\t\t\t\t\t\t\tfill: theme.foreground,\n\t\t\t\t\t\t\tfontSize: theme.fontSize,\n\t\t\t\t\t\t\ttextAnchor: leaf ? \"start\" : \"end\",\n\t\t\t\t\t\t\tbaseline: \"middle\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (options.tip !== false) {\n\t\t\t\t\tpoints.push(pointFor(id, node, options, context, index, at));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { nodes, points };\n\t\t},\n\t};\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAGC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,SAAS,wBAAwB;AA0B1C,SAAS,OACR,MACA,SACuB;AACvB,QAAM,OAAO;AAAA,IACZ;AAAA,IACA,CAAC,UACC,QAAQ,WAAW,KAAK,KACxB,MAAiC;AAAA,EACpC;AACA,SAAO,KACL,IAAI,CAAC,UAAW,QAAQ,QAAQ,KAAK,IAAI,GAAG,QAAQ,MAAM,KAAK,CAAC,IAAI,CAAE,EACtE,KAAK,CAAC,MAAM,WAAW,MAAM,SAAS,MAAM,KAAK,SAAS,EAAE;AAC/D;AAEA,SAAS,SAAgB,MAAkD;AAC1E,MAAI,UAAU;AACd,SAAO,QAAQ,QAAQ,QAAQ;AAC9B,cAAU,QAAQ;AAAA,EACnB;AACA,SAAO;AACR;AAEA,SAAS,SACR,MACA,SACS;AACT,SAAO,KACL,UAAU,EACV,QAAQ,EACR,MAAM,CAAC,EACP,IAAI,CAAC,aAAa,QAAQ,KAAK,SAAS,IAAI,CAAC,EAC7C,KAAK,UAAK;AACb;AAEA,SAAS,YACR,MACA,SACW;AACX,UAAQ,OAAO,MAAM,OAAO,EAAE,YAAY,CAAC,GAAG;AAAA,IAAI,CAAC,UAClD,QAAQ,KAAK,MAAM,IAAI;AAAA,EACxB;AACD;AAEA,SAAS,QACR,MACA,SACS;AACT,SAAO,KACL,UAAU,EACV,IAAI,CAAC,aAAa,QAAQ,KAAK,SAAS,IAAI,CAAC,EAC7C,QAAQ,EACR,KAAK,GAAG;AACX;AAEA,SAAS,SACR,MACA,SACA,SACS;AACT,SAAO,KAAK,UAAU,IACnB,QAAQ,MAAM,QACd,Q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A,YACH,OAAO;AAAA,cACN,MAAM,OAAO,MAAM,aAAa,SAAS,MAAM,SAAS,OAAO;AAAA,cAC/D,QAAQ,SAAS,MAAM,SAAS,OAAO;AAAA,cACvC,aAAa;AAAA,YACd;AAAA,UACD;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,KAAK,GAAG,EAAE,UAAU,QAAQ,MAAM,OAAO,CAAC;AAAA,YAC1C,MAAM;AAAA,YACN,GACC,GAAG,KACF,OAAO,YAAY,cAAc,EAAE,YAAY;AAAA,YACjD,GAAG,GAAG;AAAA,YACN,MAAM,QAAQ,KAAK,KAAK,IAAI;AAAA,YAC5B,OAAO;AAAA,cACN,MAAM,MAAM;AAAA,cACZ,UAAU,MAAM;AAAA,cAChB,YAAY,OAAO,UAAU;AAAA,cAC7B,UAAU;AAAA,YACX;AAAA,UACD;AAAA,QACD;AACA,YAAI,QAAQ,QAAQ,OAAO;AAC1B,iBAAO,KAAK,SAAS,IAAI,MAAM,SAAS,SAAS,OAAO,EAAE,CAAC;AAAA,QAC5D;AAAA,MACD;AACA,aAAO,EAAE,OAAO,OAAO;AAAA,IACxB;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export { type HierarchyOptions, sunburstMark as sunburst, treeMark as tree, treemapMark as treemap, } from "./hierarchy.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hierarchy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,IAAI,QAAQ,EACxB,QAAQ,IAAI,IAAI,EAChB,WAAW,IAAI,OAAO,GACtB,MAAM,0BAA0B,CAAC"}