@antv/gpt-vis 1.3.2 → 1.4.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 (284) hide show
  1. package/README.md +261 -137
  2. package/README.zh-CN.md +263 -116
  3. package/dist/cjs/annotation/components/bottom-n.d.ts +2 -0
  4. package/dist/cjs/annotation/components/bottom-n.js +57 -0
  5. package/dist/cjs/annotation/components/centroid.d.ts +2 -0
  6. package/dist/cjs/annotation/components/centroid.js +75 -0
  7. package/dist/cjs/annotation/components/connector.d.ts +25 -0
  8. package/dist/cjs/annotation/components/connector.js +298 -0
  9. package/dist/cjs/annotation/components/contribution.d.ts +3 -0
  10. package/dist/cjs/annotation/components/contribution.js +136 -0
  11. package/dist/cjs/annotation/components/crossing.d.ts +3 -0
  12. package/dist/cjs/annotation/components/crossing.js +504 -0
  13. package/dist/cjs/annotation/components/event.d.ts +2 -0
  14. package/dist/cjs/annotation/components/event.js +62 -0
  15. package/dist/cjs/annotation/components/first.d.ts +2 -0
  16. package/dist/cjs/annotation/components/first.js +42 -0
  17. package/dist/cjs/annotation/components/group.d.ts +3 -0
  18. package/dist/cjs/annotation/components/group.js +73 -0
  19. package/dist/cjs/annotation/components/highlight.d.ts +14 -0
  20. package/dist/cjs/annotation/components/highlight.js +552 -0
  21. package/dist/cjs/annotation/components/index.d.ts +34 -0
  22. package/dist/cjs/annotation/components/index.js +128 -0
  23. package/dist/cjs/annotation/components/last.d.ts +2 -0
  24. package/dist/cjs/annotation/components/last.js +42 -0
  25. package/dist/cjs/annotation/components/max-x.d.ts +2 -0
  26. package/dist/cjs/annotation/components/max-x.js +41 -0
  27. package/dist/cjs/annotation/components/max-y.d.ts +2 -0
  28. package/dist/cjs/annotation/components/max-y.js +41 -0
  29. package/dist/cjs/annotation/components/mean.d.ts +2 -0
  30. package/dist/cjs/annotation/components/mean.js +50 -0
  31. package/dist/cjs/annotation/components/median.d.ts +2 -0
  32. package/dist/cjs/annotation/components/median.js +49 -0
  33. package/dist/cjs/annotation/components/min-x.d.ts +2 -0
  34. package/dist/cjs/annotation/components/min-x.js +41 -0
  35. package/dist/cjs/annotation/components/min-y.d.ts +2 -0
  36. package/dist/cjs/annotation/components/min-y.js +41 -0
  37. package/dist/cjs/annotation/components/outlier.d.ts +3 -0
  38. package/dist/cjs/annotation/components/outlier.js +83 -0
  39. package/dist/cjs/annotation/components/path.d.ts +20 -0
  40. package/dist/cjs/annotation/components/path.js +147 -0
  41. package/dist/cjs/annotation/components/peak.d.ts +2 -0
  42. package/dist/cjs/annotation/components/peak.js +42 -0
  43. package/dist/cjs/annotation/components/point.d.ts +26 -0
  44. package/dist/cjs/annotation/components/point.js +241 -0
  45. package/dist/cjs/annotation/components/quadrant.d.ts +3 -0
  46. package/dist/cjs/annotation/components/quadrant.js +97 -0
  47. package/dist/cjs/annotation/components/quantile.d.ts +2 -0
  48. package/dist/cjs/annotation/components/quantile.js +49 -0
  49. package/dist/cjs/annotation/components/range-inside.d.ts +2 -0
  50. package/dist/cjs/annotation/components/range-inside.js +65 -0
  51. package/dist/cjs/annotation/components/range-outside.d.ts +2 -0
  52. package/dist/cjs/annotation/components/range-outside.js +65 -0
  53. package/dist/cjs/annotation/components/range-x.d.ts +2 -0
  54. package/dist/cjs/annotation/components/range-x.js +39 -0
  55. package/dist/cjs/annotation/components/range-y.d.ts +2 -0
  56. package/dist/cjs/annotation/components/range-y.js +39 -0
  57. package/dist/cjs/annotation/components/range.d.ts +15 -0
  58. package/dist/cjs/annotation/components/range.js +87 -0
  59. package/dist/cjs/annotation/components/target.d.ts +2 -0
  60. package/dist/cjs/annotation/components/target.js +51 -0
  61. package/dist/cjs/annotation/components/text.d.ts +15 -0
  62. package/dist/cjs/annotation/components/text.js +74 -0
  63. package/dist/cjs/annotation/components/threshold-highlight.d.ts +3 -0
  64. package/dist/cjs/annotation/components/threshold-highlight.js +223 -0
  65. package/dist/cjs/annotation/components/threshold-x.d.ts +2 -0
  66. package/dist/cjs/annotation/components/threshold-x.js +39 -0
  67. package/dist/cjs/annotation/components/threshold-y.d.ts +2 -0
  68. package/dist/cjs/annotation/components/threshold-y.js +40 -0
  69. package/dist/cjs/annotation/components/top-n.d.ts +2 -0
  70. package/dist/cjs/annotation/components/top-n.js +57 -0
  71. package/dist/cjs/annotation/components/valley.d.ts +2 -0
  72. package/dist/cjs/annotation/components/valley.js +42 -0
  73. package/dist/cjs/annotation/index.d.ts +1 -0
  74. package/dist/cjs/annotation/index.js +29 -0
  75. package/dist/cjs/annotation/label.d.ts +38 -0
  76. package/dist/cjs/annotation/label.js +347 -0
  77. package/dist/cjs/annotation/layout.d.ts +12 -0
  78. package/dist/cjs/annotation/layout.js +142 -0
  79. package/dist/cjs/annotation/merge.d.ts +19 -0
  80. package/dist/cjs/annotation/merge.js +60 -0
  81. package/dist/cjs/annotation/registry.d.ts +190 -0
  82. package/dist/cjs/annotation/registry.js +134 -0
  83. package/dist/cjs/annotation/runtime/g2.d.ts +90 -0
  84. package/dist/cjs/annotation/runtime/g2.js +521 -0
  85. package/dist/cjs/annotation/runtime/g6.d.ts +40 -0
  86. package/dist/cjs/annotation/runtime/g6.js +310 -0
  87. package/dist/cjs/annotation/runtime/index.d.ts +11 -0
  88. package/dist/cjs/annotation/runtime/index.js +41 -0
  89. package/dist/cjs/annotation/runtime/summary.d.ts +17 -0
  90. package/dist/cjs/annotation/runtime/summary.js +39 -0
  91. package/dist/cjs/annotation/runtime/table.d.ts +16 -0
  92. package/dist/cjs/annotation/runtime/table.js +39 -0
  93. package/dist/cjs/annotation/utils.d.ts +40 -0
  94. package/dist/cjs/annotation/utils.js +275 -0
  95. package/dist/cjs/theme/annotation.d.ts +236 -0
  96. package/dist/cjs/theme/annotation.js +167 -0
  97. package/dist/cjs/theme/g2.js +13 -15
  98. package/dist/cjs/theme/g6.js +2 -2
  99. package/dist/cjs/theme/summary.js +2 -2
  100. package/dist/cjs/types/annotation.d.ts +310 -0
  101. package/dist/cjs/types/annotation.js +17 -0
  102. package/dist/cjs/types/index.d.ts +1 -0
  103. package/dist/cjs/util/axis.d.ts +28 -0
  104. package/dist/cjs/util/axis.js +184 -0
  105. package/dist/cjs/util/components.d.ts +0 -10
  106. package/dist/cjs/util/components.js +9 -64
  107. package/dist/cjs/util/index.d.ts +7 -4
  108. package/dist/cjs/util/index.js +53 -9
  109. package/dist/cjs/vis/area/index.d.ts +2 -0
  110. package/dist/cjs/vis/area/index.js +30 -13
  111. package/dist/cjs/vis/bar/index.d.ts +2 -0
  112. package/dist/cjs/vis/bar/index.js +37 -7
  113. package/dist/cjs/vis/boxplot/index.js +14 -3
  114. package/dist/cjs/vis/column/index.d.ts +2 -0
  115. package/dist/cjs/vis/column/index.js +28 -9
  116. package/dist/cjs/vis/dual-axes/index.js +9 -9
  117. package/dist/cjs/vis/fishbone-diagram/index.js +2 -2
  118. package/dist/cjs/vis/flow-diagram/index.js +2 -2
  119. package/dist/cjs/vis/funnel/index.js +10 -13
  120. package/dist/cjs/vis/histogram/index.js +2 -2
  121. package/dist/cjs/vis/indented-tree/index.js +2 -2
  122. package/dist/cjs/vis/line/index.d.ts +2 -0
  123. package/dist/cjs/vis/line/index.js +26 -10
  124. package/dist/cjs/vis/liquid/index.js +2 -2
  125. package/dist/cjs/vis/mindmap/index.js +2 -2
  126. package/dist/cjs/vis/network-graph/index.d.ts +2 -0
  127. package/dist/cjs/vis/network-graph/index.js +24 -3
  128. package/dist/cjs/vis/organization-chart/index.js +2 -2
  129. package/dist/cjs/vis/pie/index.d.ts +2 -0
  130. package/dist/cjs/vis/pie/index.js +21 -10
  131. package/dist/cjs/vis/radar/index.js +4 -6
  132. package/dist/cjs/vis/sankey/index.js +14 -1
  133. package/dist/cjs/vis/scatter/index.d.ts +10 -3
  134. package/dist/cjs/vis/scatter/index.js +18 -7
  135. package/dist/cjs/vis/summary/index.d.ts +9 -2
  136. package/dist/cjs/vis/summary/index.js +25 -8
  137. package/dist/cjs/vis/table/index.d.ts +2 -0
  138. package/dist/cjs/vis/table/index.js +48 -30
  139. package/dist/cjs/vis/venn/index.js +2 -2
  140. package/dist/cjs/vis/violin/index.js +14 -3
  141. package/dist/cjs/vis/waterfall/index.js +17 -9
  142. package/dist/cjs/vis/word-cloud/index.js +4 -6
  143. package/dist/esm/annotation/components/bottom-n.d.ts +2 -0
  144. package/dist/esm/annotation/components/bottom-n.js +42 -0
  145. package/dist/esm/annotation/components/centroid.d.ts +2 -0
  146. package/dist/esm/annotation/components/centroid.js +73 -0
  147. package/dist/esm/annotation/components/connector.d.ts +25 -0
  148. package/dist/esm/annotation/components/connector.js +332 -0
  149. package/dist/esm/annotation/components/contribution.d.ts +3 -0
  150. package/dist/esm/annotation/components/contribution.js +174 -0
  151. package/dist/esm/annotation/components/crossing.d.ts +3 -0
  152. package/dist/esm/annotation/components/crossing.js +665 -0
  153. package/dist/esm/annotation/components/event.d.ts +2 -0
  154. package/dist/esm/annotation/components/event.js +46 -0
  155. package/dist/esm/annotation/components/first.d.ts +2 -0
  156. package/dist/esm/annotation/components/first.js +18 -0
  157. package/dist/esm/annotation/components/group.d.ts +3 -0
  158. package/dist/esm/annotation/components/group.js +64 -0
  159. package/dist/esm/annotation/components/highlight.d.ts +14 -0
  160. package/dist/esm/annotation/components/highlight.js +838 -0
  161. package/dist/esm/annotation/components/index.d.ts +34 -0
  162. package/dist/esm/annotation/components/index.js +34 -0
  163. package/dist/esm/annotation/components/last.d.ts +2 -0
  164. package/dist/esm/annotation/components/last.js +18 -0
  165. package/dist/esm/annotation/components/max-x.d.ts +2 -0
  166. package/dist/esm/annotation/components/max-x.js +17 -0
  167. package/dist/esm/annotation/components/max-y.d.ts +2 -0
  168. package/dist/esm/annotation/components/max-y.js +17 -0
  169. package/dist/esm/annotation/components/mean.d.ts +2 -0
  170. package/dist/esm/annotation/components/mean.js +40 -0
  171. package/dist/esm/annotation/components/median.d.ts +2 -0
  172. package/dist/esm/annotation/components/median.js +32 -0
  173. package/dist/esm/annotation/components/min-x.d.ts +2 -0
  174. package/dist/esm/annotation/components/min-x.js +17 -0
  175. package/dist/esm/annotation/components/min-y.d.ts +2 -0
  176. package/dist/esm/annotation/components/min-y.js +17 -0
  177. package/dist/esm/annotation/components/outlier.d.ts +3 -0
  178. package/dist/esm/annotation/components/outlier.js +98 -0
  179. package/dist/esm/annotation/components/path.d.ts +20 -0
  180. package/dist/esm/annotation/components/path.js +165 -0
  181. package/dist/esm/annotation/components/peak.d.ts +2 -0
  182. package/dist/esm/annotation/components/peak.js +20 -0
  183. package/dist/esm/annotation/components/point.d.ts +26 -0
  184. package/dist/esm/annotation/components/point.js +277 -0
  185. package/dist/esm/annotation/components/quadrant.d.ts +3 -0
  186. package/dist/esm/annotation/components/quadrant.js +83 -0
  187. package/dist/esm/annotation/components/quantile.d.ts +2 -0
  188. package/dist/esm/annotation/components/quantile.js +32 -0
  189. package/dist/esm/annotation/components/range-inside.d.ts +2 -0
  190. package/dist/esm/annotation/components/range-inside.js +55 -0
  191. package/dist/esm/annotation/components/range-outside.d.ts +2 -0
  192. package/dist/esm/annotation/components/range-outside.js +55 -0
  193. package/dist/esm/annotation/components/range-x.d.ts +2 -0
  194. package/dist/esm/annotation/components/range-x.js +15 -0
  195. package/dist/esm/annotation/components/range-y.d.ts +2 -0
  196. package/dist/esm/annotation/components/range-y.js +15 -0
  197. package/dist/esm/annotation/components/range.d.ts +15 -0
  198. package/dist/esm/annotation/components/range.js +92 -0
  199. package/dist/esm/annotation/components/target.d.ts +2 -0
  200. package/dist/esm/annotation/components/target.js +44 -0
  201. package/dist/esm/annotation/components/text.d.ts +15 -0
  202. package/dist/esm/annotation/components/text.js +78 -0
  203. package/dist/esm/annotation/components/threshold-highlight.d.ts +3 -0
  204. package/dist/esm/annotation/components/threshold-highlight.js +297 -0
  205. package/dist/esm/annotation/components/threshold-x.d.ts +2 -0
  206. package/dist/esm/annotation/components/threshold-x.js +23 -0
  207. package/dist/esm/annotation/components/threshold-y.d.ts +2 -0
  208. package/dist/esm/annotation/components/threshold-y.js +24 -0
  209. package/dist/esm/annotation/components/top-n.d.ts +2 -0
  210. package/dist/esm/annotation/components/top-n.js +42 -0
  211. package/dist/esm/annotation/components/valley.d.ts +2 -0
  212. package/dist/esm/annotation/components/valley.js +20 -0
  213. package/dist/esm/annotation/index.d.ts +1 -0
  214. package/dist/esm/annotation/index.js +1 -0
  215. package/dist/esm/annotation/label.d.ts +38 -0
  216. package/dist/esm/annotation/label.js +449 -0
  217. package/dist/esm/annotation/layout.d.ts +12 -0
  218. package/dist/esm/annotation/layout.js +182 -0
  219. package/dist/esm/annotation/merge.d.ts +19 -0
  220. package/dist/esm/annotation/merge.js +67 -0
  221. package/dist/esm/annotation/registry.d.ts +190 -0
  222. package/dist/esm/annotation/registry.js +220 -0
  223. package/dist/esm/annotation/runtime/g2.d.ts +90 -0
  224. package/dist/esm/annotation/runtime/g2.js +754 -0
  225. package/dist/esm/annotation/runtime/g6.d.ts +40 -0
  226. package/dist/esm/annotation/runtime/g6.js +447 -0
  227. package/dist/esm/annotation/runtime/index.d.ts +11 -0
  228. package/dist/esm/annotation/runtime/index.js +26 -0
  229. package/dist/esm/annotation/runtime/summary.d.ts +17 -0
  230. package/dist/esm/annotation/runtime/summary.js +21 -0
  231. package/dist/esm/annotation/runtime/table.d.ts +16 -0
  232. package/dist/esm/annotation/runtime/table.js +21 -0
  233. package/dist/esm/annotation/utils.d.ts +40 -0
  234. package/dist/esm/annotation/utils.js +370 -0
  235. package/dist/esm/theme/annotation.d.ts +236 -0
  236. package/dist/esm/theme/annotation.js +186 -0
  237. package/dist/esm/theme/g2.js +2 -10
  238. package/dist/esm/theme/g6.js +1 -1
  239. package/dist/esm/theme/summary.js +1 -1
  240. package/dist/esm/types/annotation.d.ts +310 -0
  241. package/dist/esm/types/annotation.js +1 -0
  242. package/dist/esm/types/index.d.ts +1 -0
  243. package/dist/esm/util/axis.d.ts +28 -0
  244. package/dist/esm/util/axis.js +222 -0
  245. package/dist/esm/util/components.d.ts +0 -10
  246. package/dist/esm/util/components.js +24 -69
  247. package/dist/esm/util/index.d.ts +7 -4
  248. package/dist/esm/util/index.js +7 -4
  249. package/dist/esm/vis/area/index.d.ts +2 -0
  250. package/dist/esm/vis/area/index.js +32 -9
  251. package/dist/esm/vis/bar/index.d.ts +2 -0
  252. package/dist/esm/vis/bar/index.js +37 -6
  253. package/dist/esm/vis/boxplot/index.js +10 -2
  254. package/dist/esm/vis/column/index.d.ts +2 -0
  255. package/dist/esm/vis/column/index.js +33 -12
  256. package/dist/esm/vis/dual-axes/index.js +10 -10
  257. package/dist/esm/vis/fishbone-diagram/index.js +1 -1
  258. package/dist/esm/vis/flow-diagram/index.js +1 -1
  259. package/dist/esm/vis/funnel/index.js +2 -7
  260. package/dist/esm/vis/histogram/index.js +4 -3
  261. package/dist/esm/vis/indented-tree/index.js +1 -1
  262. package/dist/esm/vis/line/index.d.ts +2 -0
  263. package/dist/esm/vis/line/index.js +31 -9
  264. package/dist/esm/vis/liquid/index.js +1 -1
  265. package/dist/esm/vis/mindmap/index.js +1 -1
  266. package/dist/esm/vis/network-graph/index.d.ts +2 -0
  267. package/dist/esm/vis/network-graph/index.js +29 -2
  268. package/dist/esm/vis/organization-chart/index.js +1 -1
  269. package/dist/esm/vis/pie/index.d.ts +2 -0
  270. package/dist/esm/vis/pie/index.js +25 -8
  271. package/dist/esm/vis/radar/index.js +1 -3
  272. package/dist/esm/vis/sankey/index.js +15 -1
  273. package/dist/esm/vis/scatter/index.d.ts +10 -3
  274. package/dist/esm/vis/scatter/index.js +28 -5
  275. package/dist/esm/vis/summary/index.d.ts +9 -2
  276. package/dist/esm/vis/summary/index.js +31 -13
  277. package/dist/esm/vis/table/index.d.ts +2 -0
  278. package/dist/esm/vis/table/index.js +50 -33
  279. package/dist/esm/vis/venn/index.js +1 -1
  280. package/dist/esm/vis/violin/index.js +10 -2
  281. package/dist/esm/vis/waterfall/index.js +16 -13
  282. package/dist/esm/vis/word-cloud/index.js +1 -3
  283. package/dist/umd/index.min.js +1 -1
  284. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ /** Length inside a rectangle, also used to score paths without treating their whole bounds as solid. */
13
+ function insideLength(_ref, box) {
14
+ var _ref2 = _slicedToArray(_ref, 2),
15
+ a = _ref2[0],
16
+ b = _ref2[1];
17
+ var start = 0;
18
+ var end = 1;
19
+ for (var _i = 0, _arr = [[0, box.x, box.x + box.width], [1, box.y, box.y + box.height]]; _i < _arr.length; _i++) {
20
+ var _arr$_i = _slicedToArray(_arr[_i], 3),
21
+ axis = _arr$_i[0],
22
+ low = _arr$_i[1],
23
+ high = _arr$_i[2];
24
+ var delta = b[axis] - a[axis];
25
+ if (!delta) {
26
+ if (a[axis] < low || a[axis] > high) return 0;
27
+ } else {
28
+ var t0 = (low - a[axis]) / delta;
29
+ var t1 = (high - a[axis]) / delta;
30
+ start = Math.max(start, Math.min(t0, t1));
31
+ end = Math.min(end, Math.max(t0, t1));
32
+ }
33
+ }
34
+ return Math.max(0, end - start) * Math.hypot(b[0] - a[0], b[1] - a[1]);
35
+ }
36
+ function padded(box) {
37
+ return {
38
+ x: box.x - 4,
39
+ y: box.y - 4,
40
+ width: box.width + 8,
41
+ height: box.height + 8
42
+ };
43
+ }
44
+ function overlap(a, b) {
45
+ return Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));
46
+ }
47
+
48
+ /** Keep a preferred native position when clear; otherwise try nearby spaces and obstacle edges. */
49
+ export function placeLabel(anchor, size, view, gap, boxes, segments, preferred) {
50
+ var _anchor = _slicedToArray(anchor, 2),
51
+ x = _anchor[0],
52
+ y = _anchor[1];
53
+ var _size = _slicedToArray(size, 2),
54
+ width = _size[0],
55
+ height = _size[1];
56
+ var above = [x - width / 2, y - gap - height];
57
+ var candidates = [preferred !== null && preferred !== void 0 ? preferred : above, above, [x - width / 2, y + gap], [x + gap, y - height / 2], [x - gap - width, y - height / 2], [x - gap - width, y - gap - height], [x + gap, y - gap - height], [x - gap - width, y + gap], [x + gap, y + gap]];
58
+ var left = Math.min.apply(Math, _toConsumableArray(candidates.map(function (_ref3) {
59
+ var _ref4 = _slicedToArray(_ref3, 1),
60
+ x = _ref4[0];
61
+ return x;
62
+ })));
63
+ var top = Math.min.apply(Math, _toConsumableArray(candidates.map(function (_ref5) {
64
+ var _ref6 = _slicedToArray(_ref5, 2),
65
+ y = _ref6[1];
66
+ return y;
67
+ })));
68
+ var near = {
69
+ x: left - 4,
70
+ y: top - 4,
71
+ width: Math.max.apply(Math, _toConsumableArray(candidates.map(function (_ref7) {
72
+ var _ref8 = _slicedToArray(_ref7, 1),
73
+ x = _ref8[0];
74
+ return x;
75
+ }))) - left + width + 8,
76
+ height: Math.max.apply(Math, _toConsumableArray(candidates.map(function (_ref9) {
77
+ var _ref10 = _slicedToArray(_ref9, 2),
78
+ y = _ref10[1];
79
+ return y;
80
+ }))) - top + height + 8
81
+ };
82
+ var _iterator = _createForOfIteratorHelper(boxes),
83
+ _step;
84
+ try {
85
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
86
+ var box = _step.value;
87
+ if (!overlap(box, near)) continue;
88
+ candidates.push([box.x - width - 4, y - height / 2], [box.x + box.width + 4, y - height / 2], [x - width / 2, box.y - height - 4], [x - width / 2, box.y + box.height + 4]);
89
+ }
90
+ } catch (err) {
91
+ _iterator.e(err);
92
+ } finally {
93
+ _iterator.f();
94
+ }
95
+ var best;
96
+ var bestScore = Infinity;
97
+ var _loop = function _loop() {
98
+ var _candidates$_i = _slicedToArray(_candidates[_i2], 2),
99
+ left = _candidates$_i[0],
100
+ top = _candidates$_i[1];
101
+ var box = {
102
+ x: Math.max(0, Math.min(left, view[0] - width)),
103
+ y: Math.max(0, Math.min(top, view[1] - height)),
104
+ width: width,
105
+ height: height
106
+ };
107
+ var collisions = boxes.reduce(function (sum, other) {
108
+ return sum + overlap(box, padded(other));
109
+ }, 0) + segments.reduce(function (sum, segment) {
110
+ return sum + insideLength(segment, padded(box)) * 6;
111
+ }, 0);
112
+ var score = collisions * 100 + Math.hypot(box.x - candidates[0][0], box.y - candidates[0][1]);
113
+ if (score < bestScore) {
114
+ best = box;
115
+ bestScore = score;
116
+ }
117
+ };
118
+ for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
119
+ _loop();
120
+ }
121
+ return best;
122
+ }
123
+
124
+ /** Route only explanation leaders; explicit annotation lines retain their original geometry. */
125
+ export function routeLeader(anchor, target, boxes, segments) {
126
+ var _anchor2 = _slicedToArray(anchor, 2),
127
+ x = _anchor2[0],
128
+ y = _anchor2[1];
129
+ var edge = [Math.max(target.x, Math.min(x, target.x + target.width)), Math.max(target.y, Math.min(y, target.y + target.height))];
130
+ if (edge[0] === x && edge[1] === y) return [];
131
+ var obstacles = boxes.filter(function (box) {
132
+ return box !== target && !(x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height);
133
+ });
134
+ var routes = [[anchor, edge], [anchor, [edge[0], y], edge], [anchor, [x, edge[1]], edge]];
135
+ var _iterator2 = _createForOfIteratorHelper(obstacles),
136
+ _step2;
137
+ try {
138
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
139
+ var box = _step2.value;
140
+ if (!insideLength([anchor, edge], padded(box))) continue;
141
+ for (var _i3 = 0, _arr2 = [box.x - 6, box.x + box.width + 6]; _i3 < _arr2.length; _i3++) {
142
+ var lane = _arr2[_i3];
143
+ routes.push([anchor, [lane, y], [lane, edge[1]], edge]);
144
+ }
145
+ for (var _i4 = 0, _arr3 = [box.y - 6, box.y + box.height + 6]; _i4 < _arr3.length; _i4++) {
146
+ var _lane = _arr3[_i4];
147
+ routes.push([anchor, [x, _lane], [edge[0], _lane], edge]);
148
+ }
149
+ }
150
+ } catch (err) {
151
+ _iterator2.e(err);
152
+ } finally {
153
+ _iterator2.f();
154
+ }
155
+ var score = function score(route) {
156
+ return route.slice(1).reduce(function (sum, point, index) {
157
+ var segment = [route[index], point];
158
+ return sum + Math.hypot(point[0] - segment[0][0], point[1] - segment[0][1]) + obstacles.reduce(function (cost, box) {
159
+ return cost + insideLength(segment, box) * 100;
160
+ }, 0) + segments.reduce(function (cost, other) {
161
+ return cost + (crosses(segment, other) ? 40 : 0);
162
+ }, 0) +
163
+ // A leader must approach the card from outside, never travel through its text.
164
+ insideLength(segment, target) * 100;
165
+ }, 0);
166
+ };
167
+ return routes.reduce(function (best, route) {
168
+ return score(route) < score(best) ? route : best;
169
+ });
170
+ }
171
+ function crosses(_ref11, _ref12) {
172
+ var _ref13 = _slicedToArray(_ref11, 2),
173
+ a = _ref13[0],
174
+ b = _ref13[1];
175
+ var _ref14 = _slicedToArray(_ref12, 2),
176
+ c = _ref14[0],
177
+ d = _ref14[1];
178
+ var side = function side(p, q, r) {
179
+ return (q[0] - p[0]) * (r[1] - p[1]) - (q[1] - p[1]) * (r[0] - p[0]);
180
+ };
181
+ return side(a, b, c) * side(a, b, d) < 0 && side(c, d, a) * side(c, d, b) < 0;
182
+ }
@@ -0,0 +1,19 @@
1
+ import type { AnnotationResult } from './registry';
2
+ export interface AnnotationEntry<A extends {
3
+ type: string;
4
+ }, C, R = AnnotationResult> {
5
+ annotation: A;
6
+ draw: (annotations: A[], context: C) => R;
7
+ }
8
+ export interface AnnotationGroup<A extends {
9
+ type: string;
10
+ }, C, R = AnnotationResult> {
11
+ annotations: A[];
12
+ draw: AnnotationEntry<A, C, R>['draw'];
13
+ }
14
+ /** Group configurations into shared drawing calls; components resolve the selected data. */
15
+ export declare function mergeAnnotations<A extends {
16
+ type: string;
17
+ }, C, R = AnnotationResult>(entries: AnnotationEntry<A, C, R>[]): AnnotationGroup<A, C, R>[];
18
+ /** Reused primitives retain their native marks, update hooks and resource cleanup. */
19
+ export declare function mergeResults(results: AnnotationResult[]): AnnotationResult;
@@ -0,0 +1,67 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ /** Group configurations into shared drawing calls; components resolve the selected data. */
5
+ export function mergeAnnotations(entries) {
6
+ var groups = [];
7
+ var shared = new Map();
8
+ var _iterator = _createForOfIteratorHelper(entries),
9
+ _step;
10
+ try {
11
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12
+ var _step$value = _step.value,
13
+ annotation = _step$value.annotation,
14
+ draw = _step$value.draw;
15
+ var existing = shared.get(annotation.type);
16
+ if (existing) {
17
+ existing.annotations.push(annotation);
18
+ continue;
19
+ }
20
+ var previous = groups.at(-1);
21
+ if ((previous === null || previous === void 0 ? void 0 : previous.annotations[0].type) === annotation.type) {
22
+ previous.annotations.push(annotation);
23
+ continue;
24
+ }
25
+ var group = {
26
+ annotations: [annotation],
27
+ draw: draw
28
+ };
29
+ groups.push(group);
30
+ // Native appearance changes share a pass even when reference marks separate their configs.
31
+ if (annotation.type === 'highlight' || annotation.type === 'thresholdHighlight') shared.set(annotation.type, group);
32
+ }
33
+ } catch (err) {
34
+ _iterator.e(err);
35
+ } finally {
36
+ _iterator.f();
37
+ }
38
+ return groups;
39
+ }
40
+
41
+ /** Reused primitives retain their native marks, update hooks and resource cleanup. */
42
+ export function mergeResults(results) {
43
+ var updates = results.flatMap(function (_ref) {
44
+ var update = _ref.update;
45
+ return update ? [update] : [];
46
+ });
47
+ var cleanups = results.flatMap(function (_ref2) {
48
+ var cleanup = _ref2.cleanup;
49
+ return cleanup ? [cleanup] : [];
50
+ });
51
+ return {
52
+ marks: results.flatMap(function (_ref3) {
53
+ var marks = _ref3.marks;
54
+ return marks !== null && marks !== void 0 ? marks : [];
55
+ }),
56
+ update: updates.length ? function () {
57
+ return updates.forEach(function (update) {
58
+ return update();
59
+ });
60
+ } : undefined,
61
+ cleanup: cleanups.length ? function () {
62
+ return cleanups.forEach(function (cleanup) {
63
+ return cleanup();
64
+ });
65
+ } : undefined
66
+ };
67
+ }
@@ -0,0 +1,190 @@
1
+ import type { Annotation, RendererAnnotationOptions } from '../types/annotation';
2
+ import type { ChartType } from '../types/theme';
3
+ import { type AnnotationEntry, type AnnotationGroup } from './merge';
4
+ import type { G2AnnotationContext, G6AnnotationContext, MarkOptions, SummaryContext, TableContext } from './runtime';
5
+ interface AnnotationContexts<T extends object> {
6
+ g2: G2AnnotationContext<T>;
7
+ g6: G6AnnotationContext<T>;
8
+ table: TableContext<T>;
9
+ summary: SummaryContext;
10
+ }
11
+ type AnnotationRenderer = keyof AnnotationContexts<object>;
12
+ type AnnotationType = Annotation['type'];
13
+ type ComponentRenderer<K extends AnnotationType> = {
14
+ [R in AnnotationRenderer]: Extract<RendererAnnotationOptions<object, R>, {
15
+ type: K;
16
+ }> extends never ? never : R;
17
+ }[AnnotationRenderer];
18
+ /** Internal renderer constraints keep table mappings out of statistical-chart suggestions. */
19
+ export type RendererAnnotation<T extends object, R extends AnnotationRenderer, C extends ChartType | undefined = undefined> = [C] extends [undefined] ? RendererAnnotationOptions<T, R> : Extract<RendererAnnotationOptions<T, R>, {
20
+ type: SupportedAnnotationType<Exclude<C, undefined>>;
21
+ }>;
22
+ type SupportedAnnotationType<C extends ChartType> = {
23
+ [K in AnnotationType]: Extract<C, (typeof components)[K]['charts'][number]> extends never ? never : K;
24
+ }[AnnotationType];
25
+ /** Expansion reads source data and defaults; only deferred drawing can change a scene. */
26
+ interface AnnotationSources<T extends object> {
27
+ g2: Pick<G2AnnotationContext<T>, 'mapping' | 'defaults' | 'chartType'> & Partial<Pick<G2AnnotationContext<T>, 'sourceMarks' | 'isVisible'>>;
28
+ g6: Pick<G6AnnotationContext<T>, 'chartType' | 'data'>;
29
+ table: Pick<TableContext<T>, 'chartType' | 'data' | 'defaults'>;
30
+ summary: SummaryContext;
31
+ }
32
+ export interface AnnotationResult {
33
+ marks?: MarkOptions[];
34
+ update?: () => void;
35
+ cleanup?: () => void;
36
+ }
37
+ export type AnnotationDraw<K extends AnnotationType, R extends AnnotationRenderer> = <T extends object>(annotations: Extract<RendererAnnotation<T, R>, {
38
+ type: K;
39
+ }>[], context: AnnotationContexts<T>[R]) => AnnotationResult;
40
+ /** Components return configurations and/or deferred drawing, never drawing during preparation. */
41
+ export type AnnotationComponent<K extends AnnotationType, R extends AnnotationRenderer = ComponentRenderer<K>> = {
42
+ [P in R]: <T extends object>(annotations: Extract<RendererAnnotation<T, P>, {
43
+ type: K;
44
+ }>[], context: AnnotationSources<T>[P]) => (RendererAnnotation<T, P> | AnnotationDraw<K, P>)[] | AnnotationDraw<K, P>;
45
+ };
46
+ type DrawingEntry<T extends object, R extends AnnotationRenderer> = AnnotationEntry<RendererAnnotation<T, R>, AnnotationContexts<T>[R]>;
47
+ /** Registration is the single source for chart support in both types and runtime checks. */
48
+ declare const components: {
49
+ readonly path: {
50
+ readonly component: AnnotationComponent<"path", "g2" | "g6">;
51
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "network-graph"];
52
+ };
53
+ readonly range: {
54
+ readonly component: AnnotationComponent<"range", "g2">;
55
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
56
+ };
57
+ readonly connector: {
58
+ readonly component: AnnotationComponent<"connector", "g2" | "g6">;
59
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "network-graph"];
60
+ };
61
+ readonly point: {
62
+ readonly component: AnnotationComponent<"point", "g2" | "g6">;
63
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "network-graph"];
64
+ };
65
+ readonly text: {
66
+ readonly component: AnnotationComponent<"text", "g2" | "g6">;
67
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "network-graph"];
68
+ };
69
+ readonly highlight: {
70
+ readonly component: AnnotationComponent<"highlight", ComponentRenderer<"highlight">>;
71
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "pie", "network-graph", "table", "summary"];
72
+ };
73
+ readonly mean: {
74
+ readonly component: AnnotationComponent<"mean">;
75
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
76
+ };
77
+ readonly median: {
78
+ readonly component: AnnotationComponent<"median">;
79
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
80
+ };
81
+ readonly quantile: {
82
+ readonly component: AnnotationComponent<"quantile">;
83
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
84
+ };
85
+ readonly thresholdX: {
86
+ readonly component: AnnotationComponent<"thresholdX">;
87
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
88
+ };
89
+ readonly thresholdY: {
90
+ readonly component: AnnotationComponent<"thresholdY">;
91
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
92
+ };
93
+ readonly target: {
94
+ readonly component: AnnotationComponent<"target">;
95
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
96
+ };
97
+ readonly event: {
98
+ readonly component: AnnotationComponent<"event">;
99
+ readonly charts: readonly ["line", "area", "column", "bar"];
100
+ };
101
+ readonly rangeX: {
102
+ readonly component: AnnotationComponent<"rangeX">;
103
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
104
+ };
105
+ readonly rangeY: {
106
+ readonly component: AnnotationComponent<"rangeY">;
107
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
108
+ };
109
+ readonly quadrant: {
110
+ readonly component: AnnotationComponent<"quadrant">;
111
+ readonly charts: readonly ["scatter"];
112
+ };
113
+ readonly centroid: {
114
+ readonly component: AnnotationComponent<"centroid">;
115
+ readonly charts: readonly ["scatter"];
116
+ };
117
+ readonly crossing: {
118
+ readonly component: AnnotationComponent<"crossing">;
119
+ readonly charts: readonly ["line", "area"];
120
+ };
121
+ readonly maxX: {
122
+ readonly component: AnnotationComponent<"maxX", "g2">;
123
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
124
+ };
125
+ readonly minX: {
126
+ readonly component: AnnotationComponent<"minX", "g2">;
127
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
128
+ };
129
+ readonly maxY: {
130
+ readonly component: AnnotationComponent<"maxY", "g2">;
131
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
132
+ };
133
+ readonly minY: {
134
+ readonly component: AnnotationComponent<"minY", "g2">;
135
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
136
+ };
137
+ readonly first: {
138
+ readonly component: AnnotationComponent<"first", "g2">;
139
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
140
+ };
141
+ readonly last: {
142
+ readonly component: AnnotationComponent<"last", "g2">;
143
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
144
+ };
145
+ readonly peak: {
146
+ readonly component: AnnotationComponent<"peak", "g2">;
147
+ readonly charts: readonly ["line", "area"];
148
+ };
149
+ readonly valley: {
150
+ readonly component: AnnotationComponent<"valley", "g2">;
151
+ readonly charts: readonly ["line", "area"];
152
+ };
153
+ readonly topN: {
154
+ readonly component: AnnotationComponent<"topN", "table" | "g2">;
155
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "pie", "table"];
156
+ };
157
+ readonly bottomN: {
158
+ readonly component: AnnotationComponent<"bottomN", "table" | "g2">;
159
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "pie", "table"];
160
+ };
161
+ readonly thresholdHighlight: {
162
+ readonly component: AnnotationComponent<"thresholdHighlight", "table" | "g2">;
163
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "table"];
164
+ };
165
+ readonly rangeInside: {
166
+ readonly component: AnnotationComponent<"rangeInside", "table" | "g2">;
167
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "table"];
168
+ };
169
+ readonly rangeOutside: {
170
+ readonly component: AnnotationComponent<"rangeOutside", "table" | "g2">;
171
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "table"];
172
+ };
173
+ readonly outlier: {
174
+ readonly component: AnnotationComponent<"outlier", "table" | "g2">;
175
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "table"];
176
+ };
177
+ readonly group: {
178
+ readonly component: AnnotationComponent<"group", "g2">;
179
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter"];
180
+ };
181
+ readonly contribution: {
182
+ readonly component: AnnotationComponent<"contribution", "table" | "g2">;
183
+ readonly charts: readonly ["line", "area", "column", "bar", "scatter", "pie", "table"];
184
+ };
185
+ };
186
+ export declare function renderAnnotations<T extends object, R extends AnnotationRenderer>(renderer: R, annotations: RendererAnnotation<T, R>[], context: AnnotationContexts<T>[R]): AnnotationResult;
187
+ /** Expand semantic configurations and prepare deferred drawing without changing the scene. */
188
+ export declare function prepareAnnotations<T extends object, R extends AnnotationRenderer>(renderer: R, annotations: RendererAnnotation<T, R>[], context: AnnotationSources<T>[R]): DrawingEntry<T, R>[];
189
+ export declare function drawAnnotations<T extends object, R extends AnnotationRenderer>(groups: AnnotationGroup<RendererAnnotation<T, R>, AnnotationContexts<T>[R]>[], context: AnnotationContexts<T>[R]): AnnotationResult;
190
+ export {};
@@ -0,0 +1,220 @@
1
+ import { bottomN, centroid, connector, contribution, crossing, event, first, group, highlight, last, maxX, maxY, mean, median, minX, minY, outlier, path, peak, point, quadrant, quantile, range, rangeInside, rangeOutside, rangeX, rangeY, target, text, thresholdHighlight, thresholdX, thresholdY, topN, valley } from "./components";
2
+ import { mergeAnnotations, mergeResults } from "./merge";
3
+
4
+ /** Internal renderer constraints keep table mappings out of statistical-chart suggestions. */
5
+
6
+ /** Expansion reads source data and defaults; only deferred drawing can change a scene. */
7
+
8
+ /** Components return configurations and/or deferred drawing, never drawing during preparation. */
9
+
10
+ var drawingComponents = {
11
+ path: path,
12
+ range: range,
13
+ connector: connector,
14
+ point: point,
15
+ text: text,
16
+ highlight: highlight,
17
+ thresholdHighlight: thresholdHighlight
18
+ };
19
+ var cartesianCharts = ['line', 'area', 'column', 'bar', 'scatter'];
20
+
21
+ /** Registration is the single source for chart support in both types and runtime checks. */
22
+ var components = {
23
+ path: {
24
+ component: path,
25
+ charts: [].concat(cartesianCharts, ['network-graph'])
26
+ },
27
+ range: {
28
+ component: range,
29
+ charts: cartesianCharts
30
+ },
31
+ connector: {
32
+ component: connector,
33
+ charts: [].concat(cartesianCharts, ['network-graph'])
34
+ },
35
+ point: {
36
+ component: point,
37
+ charts: [].concat(cartesianCharts, ['network-graph'])
38
+ },
39
+ text: {
40
+ component: text,
41
+ charts: [].concat(cartesianCharts, ['network-graph'])
42
+ },
43
+ highlight: {
44
+ component: highlight,
45
+ charts: [].concat(cartesianCharts, ['pie', 'network-graph', 'table', 'summary'])
46
+ },
47
+ mean: {
48
+ component: mean,
49
+ charts: cartesianCharts
50
+ },
51
+ median: {
52
+ component: median,
53
+ charts: cartesianCharts
54
+ },
55
+ quantile: {
56
+ component: quantile,
57
+ charts: cartesianCharts
58
+ },
59
+ thresholdX: {
60
+ component: thresholdX,
61
+ charts: cartesianCharts
62
+ },
63
+ thresholdY: {
64
+ component: thresholdY,
65
+ charts: cartesianCharts
66
+ },
67
+ target: {
68
+ component: target,
69
+ charts: cartesianCharts
70
+ },
71
+ event: {
72
+ component: event,
73
+ charts: ['line', 'area', 'column', 'bar']
74
+ },
75
+ rangeX: {
76
+ component: rangeX,
77
+ charts: cartesianCharts
78
+ },
79
+ rangeY: {
80
+ component: rangeY,
81
+ charts: cartesianCharts
82
+ },
83
+ quadrant: {
84
+ component: quadrant,
85
+ charts: ['scatter']
86
+ },
87
+ centroid: {
88
+ component: centroid,
89
+ charts: ['scatter']
90
+ },
91
+ crossing: {
92
+ component: crossing,
93
+ charts: ['line', 'area']
94
+ },
95
+ maxX: {
96
+ component: maxX,
97
+ charts: cartesianCharts
98
+ },
99
+ minX: {
100
+ component: minX,
101
+ charts: cartesianCharts
102
+ },
103
+ maxY: {
104
+ component: maxY,
105
+ charts: cartesianCharts
106
+ },
107
+ minY: {
108
+ component: minY,
109
+ charts: cartesianCharts
110
+ },
111
+ first: {
112
+ component: first,
113
+ charts: cartesianCharts
114
+ },
115
+ last: {
116
+ component: last,
117
+ charts: cartesianCharts
118
+ },
119
+ peak: {
120
+ component: peak,
121
+ charts: ['line', 'area']
122
+ },
123
+ valley: {
124
+ component: valley,
125
+ charts: ['line', 'area']
126
+ },
127
+ topN: {
128
+ component: topN,
129
+ charts: [].concat(cartesianCharts, ['pie', 'table'])
130
+ },
131
+ bottomN: {
132
+ component: bottomN,
133
+ charts: [].concat(cartesianCharts, ['pie', 'table'])
134
+ },
135
+ thresholdHighlight: {
136
+ component: thresholdHighlight,
137
+ charts: [].concat(cartesianCharts, ['table'])
138
+ },
139
+ rangeInside: {
140
+ component: rangeInside,
141
+ charts: [].concat(cartesianCharts, ['table'])
142
+ },
143
+ rangeOutside: {
144
+ component: rangeOutside,
145
+ charts: [].concat(cartesianCharts, ['table'])
146
+ },
147
+ outlier: {
148
+ component: outlier,
149
+ charts: [].concat(cartesianCharts, ['table'])
150
+ },
151
+ group: {
152
+ component: group,
153
+ charts: cartesianCharts
154
+ },
155
+ contribution: {
156
+ component: contribution,
157
+ charts: [].concat(cartesianCharts, ['pie', 'table'])
158
+ }
159
+ };
160
+ export function renderAnnotations(renderer, annotations, context) {
161
+ var prepared = prepareAnnotations(renderer, annotations, context);
162
+ var groups = mergeAnnotations(prepared);
163
+ return drawAnnotations(groups, context);
164
+ }
165
+
166
+ /** Expand semantic configurations and prepare deferred drawing without changing the scene. */
167
+ export function prepareAnnotations(renderer, annotations, context) {
168
+ var expanded = expandAnnotations(renderer, annotations, context);
169
+ // Group selections before deriving points; the final merge groups the resulting drawing tasks.
170
+ var groups = mergeAnnotations(expanded);
171
+ return groups.flatMap(function (_ref) {
172
+ var annotations = _ref.annotations,
173
+ prepare = _ref.draw;
174
+ var result = prepare(annotations, context);
175
+ return (Array.isArray(result) ? result : [result]).flatMap(function (prepared) {
176
+ return typeof prepared === 'function' ? annotations.map(function (annotation) {
177
+ return {
178
+ annotation: annotation,
179
+ draw: prepared
180
+ };
181
+ }) : prepareAnnotations(renderer, [prepared], context);
182
+ });
183
+ });
184
+ }
185
+ export function drawAnnotations(groups, context) {
186
+ return mergeResults(groups.map(function (_ref2) {
187
+ var annotations = _ref2.annotations,
188
+ draw = _ref2.draw;
189
+ return draw(annotations, context);
190
+ }));
191
+ }
192
+
193
+ /** Semantic sugar expands into native capabilities; their preparation waits for merged selections. */
194
+ function expandAnnotations(renderer, annotations, context) {
195
+ // Validate the whole batch before expanding any semantic component or changing a scene.
196
+ var entries = annotations.map(function (annotation) {
197
+ var registration = Object.hasOwn(components, annotation.type) ? components[annotation.type] : undefined;
198
+ // The registry preserves the type/renderer pairing; erase it only at this dynamic lookup.
199
+ var prepare = registration && registration.component[renderer];
200
+ if (!registration || !prepare || !registration.charts.includes(context.chartType)) throw new Error("Unsupported ".concat(context.chartType, " annotation type: ").concat(annotation.type, "."));
201
+ return {
202
+ annotation: annotation,
203
+ draw: prepare
204
+ };
205
+ });
206
+ return entries.flatMap(function (_ref3) {
207
+ var annotation = _ref3.annotation,
208
+ prepare = _ref3.draw;
209
+ if (Object.hasOwn(drawingComponents, annotation.type)) return [{
210
+ annotation: annotation,
211
+ draw: prepare
212
+ }];
213
+ var result = prepare([annotation], context);
214
+ if (typeof result === 'function') throw new Error('Semantic annotations must return configurations.');
215
+ return result.flatMap(function (config) {
216
+ if (typeof config === 'function') throw new Error('Semantic annotations must return configurations.');
217
+ return expandAnnotations(renderer, [config], context);
218
+ });
219
+ });
220
+ }