@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,25 @@
1
+ import type { Annotation } from '../../types/annotation';
2
+ import type { Point } from '../layout';
3
+ import type { AnnotationComponent } from '../registry';
4
+ /** Connector geometry, arrows and label anchors are shared by the native G2 and G6 scenes. */
5
+ export declare const connector: AnnotationComponent<'connector', 'g2' | 'g6'> & {
6
+ create: typeof createConnector;
7
+ brace: typeof brace;
8
+ arc: typeof arc;
9
+ };
10
+ declare function createConnector<T extends object>(options: Omit<Extract<Annotation<T>, {
11
+ type: 'connector';
12
+ }>, 'type'>): Extract<Annotation<T>, {
13
+ type: 'connector';
14
+ }>[];
15
+ export interface ConnectorShape {
16
+ paths: Point[][];
17
+ anchor: Point;
18
+ direction: Point;
19
+ labelAnchor?: Point;
20
+ }
21
+ /** A brace between screen-space endpoints, with its anchor at the central cusp. */
22
+ declare function brace(a: Point, b: Point, side: 'top' | 'right'): ConnectorShape;
23
+ /** An offset arc with end caps; angles are measured in turns, including across the seam. */
24
+ declare function arc(center: Point, project: (angle: number) => Point, [start, end]: Point, offset?: number): ConnectorShape;
25
+ export {};
@@ -0,0 +1,332 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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 _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; } } }; }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ 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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ /** Connector geometry, arrows and label anchors are shared by the native G2 and G6 scenes. */
19
+ export var connector = {
20
+ create: createConnector,
21
+ brace: brace,
22
+ arc: arc,
23
+ g2: function g2() {
24
+ return drawG2;
25
+ },
26
+ g6: function g6() {
27
+ return drawG6;
28
+ }
29
+ };
30
+ function createConnector(options) {
31
+ return [_objectSpread(_objectSpread({}, options), {}, {
32
+ type: 'connector'
33
+ })];
34
+ }
35
+ var drawG2 = function drawG2(annotations, context) {
36
+ return {
37
+ marks: annotations.map(function (annotation) {
38
+ var _annotation$style$lab, _annotation$style;
39
+ var defaults = context.defaults;
40
+ var paint = getPaint(annotation.style, defaults);
41
+ var _geometry;
42
+ return context.createMark(annotation, {
43
+ nativeType: 'link',
44
+ style: _objectSpread(_objectSpread({}, paint), {}, {
45
+ fill: 'none'
46
+ }),
47
+ draw: function draw(scene) {
48
+ return createConnectorShape(scene, _geometry, paint, defaults.connector);
49
+ },
50
+ decorate: function decorate(element) {
51
+ return element.setAttribute('annotationSegments', _geometry.segments);
52
+ },
53
+ label: {
54
+ annotationAnchor: function annotationAnchor() {
55
+ return _geometry.anchor;
56
+ },
57
+ fill: (_annotation$style$lab = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.labelFill) !== null && _annotation$style$lab !== void 0 ? _annotation$style$lab : paint.stroke,
58
+ position: 'inside'
59
+ },
60
+ geometry: function geometry(native) {
61
+ return function (_index, scale, value, coordinate) {
62
+ var points = annotation.data.map(function (datum) {
63
+ return context.position(datum, coordinate);
64
+ });
65
+ if (points.some(function (point) {
66
+ return !point;
67
+ })) return [[], []];
68
+ var _ref = points,
69
+ _ref2 = _slicedToArray(_ref, 2),
70
+ from = _ref2[0],
71
+ to = _ref2[1];
72
+ _geometry = getConnectorGeometry(coordinate.map(from), coordinate.map(to), annotation, coordinate.getSize(), defaults.connector);
73
+ return native([0], scale, _objectSpread(_objectSpread({}, value), {}, {
74
+ x: [from[0]],
75
+ y: [from[1]],
76
+ x1: [to[0]],
77
+ y1: [to[1]]
78
+ }), coordinate);
79
+ };
80
+ }
81
+ });
82
+ })
83
+ };
84
+ };
85
+ var drawG6 = function drawG6(annotations, context) {
86
+ var _iterator = _createForOfIteratorHelper(annotations),
87
+ _step;
88
+ try {
89
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
90
+ var _context$segments;
91
+ var annotation = _step.value;
92
+ var positions = annotation.data.map(function (datum) {
93
+ return context.position(datum);
94
+ });
95
+ if (positions.some(function (point) {
96
+ return !point;
97
+ })) continue;
98
+ var _ref3 = positions,
99
+ _ref4 = _slicedToArray(_ref3, 2),
100
+ a = _ref4[0],
101
+ b = _ref4[1];
102
+ var defaults = context.defaults;
103
+ var paint = getPaint(annotation.style, defaults);
104
+ var geometry = getConnectorGeometry(a, b, annotation, context.size, defaults.connector);
105
+ (_context$segments = context.segments).push.apply(_context$segments, _toConsumableArray(geometry.segments));
106
+ var shape = createConnectorShape(context.scene, geometry, paint, defaults.connector);
107
+ shape.className = 'annotation-mark';
108
+ context.root.appendChild(shape);
109
+ context.label(annotation, geometry.anchor, {
110
+ fill: paint.stroke
111
+ });
112
+ }
113
+ } catch (err) {
114
+ _iterator.e(err);
115
+ } finally {
116
+ _iterator.f();
117
+ }
118
+ return {};
119
+ };
120
+ function getPaint(style, defaults) {
121
+ var _style$stroke, _style$lineWidth;
122
+ return {
123
+ stroke: (_style$stroke = style === null || style === void 0 ? void 0 : style.stroke) !== null && _style$stroke !== void 0 ? _style$stroke : defaults.stroke,
124
+ lineWidth: (_style$lineWidth = style === null || style === void 0 ? void 0 : style.lineWidth) !== null && _style$lineWidth !== void 0 ? _style$lineWidth : defaults.lineWidth.connector,
125
+ lineDash: style === null || style === void 0 ? void 0 : style.lineDash
126
+ };
127
+ }
128
+
129
+ /** Shared screen geometry; adapters resolve data anchors before calling this. */
130
+ function getConnectorGeometry(a, b, _ref5, _ref6, defaults) {
131
+ var _ref5$shape = _ref5.shape,
132
+ shape = _ref5$shape === void 0 ? 'line' : _ref5$shape,
133
+ orientation = _ref5.orientation;
134
+ var _ref7 = _slicedToArray(_ref6, 2),
135
+ width = _ref7[0],
136
+ height = _ref7[1];
137
+ var points = [a, b];
138
+ var path = [['M'].concat(_toConsumableArray(a)), ['L'].concat(_toConsumableArray(b))];
139
+ var guides = [];
140
+ var anchor = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
141
+ var guideSegments = [];
142
+ var length = Math.hypot(b[0] - a[0], b[1] - a[1]);
143
+ if (shape === 'curve' && length) {
144
+ // Prefer the upper side; for a vertical segment prefer its left side.
145
+ var nx = (b[1] - a[1]) / length;
146
+ var ny = (a[0] - b[0]) / length;
147
+ if (ny > 0 || ny === 0 && nx > 0) {
148
+ nx = -nx;
149
+ ny = -ny;
150
+ }
151
+ var bend = Math.min(defaults.maxCurveHeight, length * defaults.curveRatio);
152
+ if (anchor[0] + nx * bend * 2 < 0 || anchor[0] + nx * bend * 2 > width || anchor[1] + ny * bend * 2 < 0 || anchor[1] + ny * bend * 2 > height) {
153
+ nx = -nx;
154
+ ny = -ny;
155
+ }
156
+ var control = [anchor[0] + nx * bend * 2, anchor[1] + ny * bend * 2];
157
+ path = [['M'].concat(_toConsumableArray(a)), ['Q'].concat(control, _toConsumableArray(b))];
158
+ // Sample only for label collision scoring; the native path draws the actual curve.
159
+ points = Array.from({
160
+ length: 17
161
+ }, function (_, i) {
162
+ var t = i / 16;
163
+ return [0, 1].map(function (axis) {
164
+ return Math.pow(1 - t, 2) * a[axis] + 2 * (1 - t) * t * control[axis] + Math.pow(t, 2) * b[axis];
165
+ });
166
+ });
167
+ anchor = points[8];
168
+ } else if (shape === 'dimension' || shape === 'bracket') {
169
+ var horizontal = (orientation !== null && orientation !== void 0 ? orientation : shape === 'dimension' ? 'vertical' : 'horizontal') === 'horizontal';
170
+ var cross = horizontal ? 1 : 0;
171
+ // Horizontal comparisons prefer above; vertical comparisons prefer the right.
172
+ var side = horizontal ? -1 : 1;
173
+ var lane = (side < 0 ? Math.min(a[cross], b[cross]) : Math.max(a[cross], b[cross])) + side * defaults.offset;
174
+ if (lane < 0 || lane > (horizontal ? height : width)) {
175
+ side = -side;
176
+ lane = (side < 0 ? Math.min(a[cross], b[cross]) : Math.max(a[cross], b[cross])) + side * defaults.offset;
177
+ }
178
+ lane = Math.max(0, Math.min(horizontal ? height : width, lane));
179
+ var p = horizontal ? [a[0], lane] : [lane, a[1]];
180
+ var q = horizontal ? [b[0], lane] : [lane, b[1]];
181
+ anchor = [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2];
182
+ if (shape === 'bracket') {
183
+ points = [a, p, q, b];
184
+ path = points.map(function (_ref8, i) {
185
+ var _ref9 = _slicedToArray(_ref8, 2),
186
+ x = _ref9[0],
187
+ y = _ref9[1];
188
+ return [i ? 'L' : 'M', x, y];
189
+ });
190
+ } else {
191
+ points = [p, q];
192
+ path = [['M'].concat(p), ['L'].concat(q)];
193
+ for (var _i = 0, _arr = [[a, p], [b, q]]; _i < _arr.length; _i++) {
194
+ var _arr$_i = _slicedToArray(_arr[_i], 2),
195
+ source = _arr$_i[0],
196
+ target = _arr$_i[1];
197
+ var end = _toConsumableArray(target);
198
+ end[cross] += Math.sign(target[cross] - source[cross]) * defaults.extension;
199
+ guides.push(['M'].concat(_toConsumableArray(source)), ['L'].concat(_toConsumableArray(end)));
200
+ guideSegments.push([source, end]);
201
+ }
202
+ }
203
+ }
204
+ return {
205
+ path: path,
206
+ guides: guides,
207
+ anchor: anchor,
208
+ points: points,
209
+ segments: [].concat(_toConsumableArray(points.slice(1).map(function (point, i) {
210
+ return [points[i], point];
211
+ })), guideSegments),
212
+ arrows: shape === 'bracket' ? 'none' : shape === 'dimension' ? 'both' : 'end'
213
+ };
214
+ }
215
+
216
+ /** Native paths and markers share the same geometry in G2 and G6. */
217
+ function createConnectorShape(scene, geometry, paint, defaults) {
218
+ var _paint$lineWidth;
219
+ var group = scene.createElement('g', {
220
+ style: {
221
+ pointerEvents: 'none'
222
+ }
223
+ });
224
+ var style = _objectSpread(_objectSpread({}, paint), {}, {
225
+ fill: 'none',
226
+ pointerEvents: 'none',
227
+ lineCap: 'round',
228
+ lineJoin: 'round'
229
+ });
230
+ var path = function path(attributes) {
231
+ return scene.createElement('path', {
232
+ style: _objectSpread(_objectSpread({}, style), attributes)
233
+ });
234
+ };
235
+ if (geometry.guides.length) group.appendChild(path({
236
+ d: geometry.guides,
237
+ strokeOpacity: 0.5,
238
+ lineWidth: 1
239
+ }));
240
+ var length = geometry.points.slice(1).reduce(function (sum, p, i) {
241
+ return sum + Math.hypot(p[0] - geometry.points[i][0], p[1] - geometry.points[i][1]);
242
+ }, 0);
243
+ var head = Math.min(length * 0.35, Math.max(defaults.arrowSize, ((_paint$lineWidth = paint.lineWidth) !== null && _paint$lineWidth !== void 0 ? _paint$lineWidth : 0) * 3));
244
+ var marker = function marker() {
245
+ return path({
246
+ lineDash: undefined,
247
+ d: [['M', head, -head / 2], ['L', 0, 0], ['L', head, head / 2]]
248
+ });
249
+ };
250
+ group.appendChild(path({
251
+ d: geometry.path,
252
+ markerStart: length && geometry.arrows === 'both' ? marker() : undefined,
253
+ markerEnd: length && geometry.arrows !== 'none' ? marker() : undefined
254
+ }));
255
+ return group;
256
+ }
257
+ /** A brace between screen-space endpoints, with its anchor at the central cusp. */
258
+ function brace(a, b, side) {
259
+ var horizontal = side === 'top';
260
+ var axis = horizontal ? 0 : 1;
261
+ var start = Math.min(a[axis], b[axis]);
262
+ var end = Math.max(a[axis], b[axis]);
263
+ if (end - start < 12) {
264
+ start -= 6;
265
+ end += 6;
266
+ }
267
+ var middle = (start + end) / 2;
268
+ var depth = Math.min(6, (end - start) / 6);
269
+ var edge = a[1 - axis];
270
+ var convert = function convert(_ref10) {
271
+ var _ref11 = _slicedToArray(_ref10, 2),
272
+ a = _ref11[0],
273
+ b = _ref11[1];
274
+ return horizontal ? [a, edge - b] : [edge + b, a];
275
+ };
276
+ var curves = [[[start, -depth], [start, 0], [start, 0], [start + depth, 0]], [[start + depth, 0], [middle - depth, 0], [middle - depth, 0], [middle, depth]], [[middle, depth], [middle + depth, 0], [middle + depth, 0], [end - depth, 0]], [[end - depth, 0], [end, 0], [end, 0], [end, -depth]]];
277
+ var path = curves.flatMap(function (_ref12, index) {
278
+ var _ref13 = _slicedToArray(_ref12, 4),
279
+ a = _ref13[0],
280
+ b = _ref13[1],
281
+ c = _ref13[2],
282
+ d = _ref13[3];
283
+ return Array.from({
284
+ length: 9
285
+ }, function (_, i) {
286
+ return i / 8;
287
+ }).filter(function (t) {
288
+ return !index || t > 0;
289
+ }).map(function (t) {
290
+ return convert([0, 1].map(function (axis) {
291
+ return Math.pow(1 - t, 3) * a[axis] + 3 * Math.pow(1 - t, 2) * t * b[axis] + 3 * (1 - t) * t * t * c[axis] + Math.pow(t, 3) * d[axis];
292
+ }));
293
+ });
294
+ });
295
+ return {
296
+ paths: [path],
297
+ anchor: convert([middle, depth]),
298
+ direction: horizontal ? [0, -1] : [1, 0]
299
+ };
300
+ }
301
+
302
+ /** An offset arc with end caps; angles are measured in turns, including across the seam. */
303
+ function arc(center, project, _ref14) {
304
+ var _ref15 = _slicedToArray(_ref14, 2),
305
+ start = _ref15[0],
306
+ end = _ref15[1];
307
+ var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
308
+ var outer = function outer(angle, offset) {
309
+ var point = project(angle % 1);
310
+ var radius = Math.hypot(point[0] - center[0], point[1] - center[1]);
311
+ return point.map(function (value, axis) {
312
+ return center[axis] + (value - center[axis]) * (1 + offset / radius);
313
+ });
314
+ };
315
+ var full = end - start >= 1 - 1e-6;
316
+ var trim = full ? 0 : Math.min(0.008, (end - start) / 8);
317
+ var from = start + trim,
318
+ to = end - trim;
319
+ var steps = Math.max(8, Math.ceil((to - from) * 120));
320
+ var points = Array.from({
321
+ length: steps + 1
322
+ }, function (_, i) {
323
+ return outer(from + (to - from) * i / steps, offset);
324
+ });
325
+ var anchor = outer((start + end) / 2, offset);
326
+ var radius = Math.hypot(anchor[0] - center[0], anchor[1] - center[1]);
327
+ return {
328
+ paths: [full ? points : [outer(from, offset - 5)].concat(points, [outer(to, offset - 5)])],
329
+ anchor: anchor,
330
+ direction: [(anchor[0] - center[0]) / radius, (anchor[1] - center[1]) / radius]
331
+ };
332
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnnotationComponent } from '../registry';
2
+ /** Compute selected observations' contribution to the full input total. */
3
+ export declare const contribution: AnnotationComponent<'contribution', 'g2' | 'table'>;
@@ -0,0 +1,174 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ 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; } } }; }
12
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
+ 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."); }
14
+ 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); }
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+ 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; }
18
+ import { labelConnectors, nativePercentageLabels } from "../label";
19
+ import { numericRows, selectedRows } from "../utils";
20
+ import { connector } from "./connector";
21
+ import { highlight } from "./highlight";
22
+
23
+ /** Compute selected observations' contribution to the full input total. */
24
+ export var contribution = {
25
+ g2: function g2(annotations, _ref) {
26
+ var mapping = _ref.mapping,
27
+ chartType = _ref.chartType;
28
+ return annotations.flatMap(function (annotation) {
29
+ var rows = selectedRows(mapping.data, annotation.data);
30
+ var share = contributionShare(mapping.data, rows, mapping.y);
31
+ if (share === undefined) return [];
32
+ var highlights = highlight.create({
33
+ data: rows,
34
+ label: getLabel(annotation.label, share, rows.length),
35
+ style: annotation.style
36
+ });
37
+ highlights.forEach(function (highlight) {
38
+ return labelConnectors.set(highlight, contributionConnector(chartType));
39
+ });
40
+ if (rows.length === 1 && annotation.label === undefined) highlights.forEach(function (highlight) {
41
+ return nativePercentageLabels.add(highlight);
42
+ });
43
+ return highlights;
44
+ });
45
+ },
46
+ table: function table(annotations, _ref2) {
47
+ var data = _ref2.data;
48
+ return annotations.flatMap(function (annotation) {
49
+ var rows = selectedRows(data, annotation.data.row);
50
+ var share = contributionShare(data, rows, annotation.data.field);
51
+ if (share === undefined) return [];
52
+ var highlights = highlight.create({
53
+ data: rows.map(function (row) {
54
+ return {
55
+ row: row,
56
+ column: annotation.data.column
57
+ };
58
+ }),
59
+ label: getLabel(annotation.label, share, rows.length),
60
+ style: annotation.style
61
+ });
62
+ highlights.forEach(function (highlight) {
63
+ return labelConnectors.set(highlight, contributionConnector('bar'));
64
+ });
65
+ return highlights;
66
+ });
67
+ }
68
+ };
69
+
70
+ /** Select the aggregate span and compose primitive connectors around the measured observations. */
71
+ function contributionConnector(chartType) {
72
+ return function (anchors, geometry, coordinate, index, count) {
73
+ if (!anchors.length) return undefined;
74
+ if (chartType !== 'pie' || !coordinate) {
75
+ var horizontal = chartType !== 'bar';
76
+ var axis = horizontal ? 0 : 1;
77
+ var measured = (['bar', 'column'].includes(chartType) ? geometry.flatMap(function (_ref3) {
78
+ var points = _ref3.points;
79
+ return points;
80
+ }) : []).filter(function (point) {
81
+ return point === null || point === void 0 ? void 0 : point.every(Number.isFinite);
82
+ });
83
+ var points = measured.length ? measured : anchors;
84
+ var start = Math.min.apply(Math, _toConsumableArray(points.map(function (point) {
85
+ return point[axis];
86
+ })));
87
+ var end = Math.max.apply(Math, _toConsumableArray(points.map(function (point) {
88
+ return point[axis];
89
+ })));
90
+ var edge = horizontal ? Math.min.apply(Math, _toConsumableArray(points.map(function (point) {
91
+ return point[1];
92
+ }))) - 12 - index * 14 : Math.max.apply(Math, _toConsumableArray(points.map(function (point) {
93
+ return point[0];
94
+ }))) + 12 + index * 14;
95
+ return connector.brace(horizontal ? [start, edge] : [edge, start], horizontal ? [end, edge] : [edge, end], horizontal ? 'top' : 'right');
96
+ }
97
+ // Merge selected sectors only; gaps must continue to exclude unselected observations.
98
+ var intervals = geometry.flatMap(function (_ref4) {
99
+ var y = _ref4.y,
100
+ y1 = _ref4.y1;
101
+ return Number.isFinite(y) && Number.isFinite(y1) && y !== y1 ? [[Math.min(y, y1), Math.max(y, y1)]] : [];
102
+ }).sort(function (a, b) {
103
+ return a[0] - b[0];
104
+ });
105
+ var runs = [];
106
+ var _iterator = _createForOfIteratorHelper(intervals),
107
+ _step;
108
+ try {
109
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
110
+ var _step$value = _slicedToArray(_step.value, 2),
111
+ _start = _step$value[0],
112
+ _end = _step$value[1];
113
+ var last = runs.at(-1);
114
+ if (last && _start <= last[1] + 1e-6) last[1] = Math.max(last[1], _end);else runs.push([_start, _end]);
115
+ }
116
+ } catch (err) {
117
+ _iterator.e(err);
118
+ } finally {
119
+ _iterator.f();
120
+ }
121
+ if (runs.length > 1 && runs[0][0] < 1e-6 && runs.at(-1)[1] > 1 - 1e-6) {
122
+ var first = runs.shift();
123
+ runs.at(-1)[1] = first[1] + 1;
124
+ }
125
+ if (!runs.length) return undefined;
126
+ var center = coordinate.getCenter();
127
+ var shapes = runs.map(function (run) {
128
+ return connector.arc(center, function (angle) {
129
+ return coordinate.map([0, angle]);
130
+ }, run, 10 + index * 12);
131
+ });
132
+ var primary = runs.reduce(function (best, run) {
133
+ return run[1] - run[0] > best[1] - best[0] ? run : best;
134
+ });
135
+ var inner = coordinate.map([1, 0]);
136
+ var innerRadius = Math.hypot(inner[0] - center[0], inner[1] - center[1]);
137
+ return _objectSpread(_objectSpread({}, shapes[runs.indexOf(primary)]), {}, {
138
+ paths: shapes.flatMap(function (_ref5) {
139
+ var paths = _ref5.paths;
140
+ return paths;
141
+ }),
142
+ labelAnchor: innerRadius >= 50 ? [center[0], center[1] + (index - (count - 1) / 2) * 34] : undefined
143
+ });
144
+ };
145
+ }
146
+ function getLabel(label, share, count) {
147
+ if (label !== undefined) return label;
148
+ var percentage = new Intl.NumberFormat('en-US', {
149
+ style: 'percent',
150
+ maximumFractionDigits: 1
151
+ }).format(share);
152
+ return "".concat(count > 1 ? "Selected ".concat(count, " items") : 'Contribution', ": ").concat(percentage);
153
+ }
154
+ function contributionShare(data, rows, field) {
155
+ var values = numericRows(data, field);
156
+ if (values.some(function (_ref6) {
157
+ var value = _ref6.value;
158
+ return value < 0;
159
+ })) throw new Error('Invalid annotation: contribution requires nonnegative values.');
160
+ var total = values.reduce(function (sum, _ref7) {
161
+ var value = _ref7.value;
162
+ return sum + value;
163
+ }, 0);
164
+ if (total === 0) return undefined;
165
+ if (!Number.isFinite(total)) throw new Error('Invalid annotation: contribution requires a finite total.');
166
+ var selected = new Set(rows);
167
+ return values.filter(function (_ref8) {
168
+ var row = _ref8.row;
169
+ return selected.has(row);
170
+ }).reduce(function (sum, _ref9) {
171
+ var value = _ref9.value;
172
+ return sum + value;
173
+ }, 0) / total;
174
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnnotationComponent } from '../registry';
2
+ /** Resolve native curve crossings, then reuse paths and directional point presets. */
3
+ export declare const crossing: AnnotationComponent<'crossing'>;