@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,370 @@
1
+ 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; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
3
+ 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); }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ 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); }
9
+ 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; } } }; }
10
+ 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); }
11
+ 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; }
12
+ /** Resolve original-field selectors without reordering or modifying business data. */
13
+ export function selectRows(data, selectors) {
14
+ if (selectors === undefined) return data;
15
+ var targets = Array.isArray(selectors) ? selectors : [selectors];
16
+ if (!targets.length) throw new Error('Invalid annotation: selection needs target data.');
17
+ var selected = new Set();
18
+ var _iterator = _createForOfIteratorHelper(targets),
19
+ _step;
20
+ try {
21
+ var _loop = function _loop() {
22
+ var target = _step.value;
23
+ if (!target || _typeof(target) !== 'object' || Array.isArray(target) || !Object.keys(target).length) throw new Error('Invalid annotation: selection needs a nonempty original-field selector.');
24
+ var entries = Object.entries(target);
25
+ if (data.length && entries.some(function (_ref) {
26
+ var _ref2 = _slicedToArray(_ref, 1),
27
+ key = _ref2[0];
28
+ return !data.some(function (row) {
29
+ return Object.hasOwn(row, key);
30
+ });
31
+ })) throw new Error('Invalid annotation: selection contains an unknown field.');
32
+ var matches = data.filter(function (row) {
33
+ return entries.every(function (_ref3) {
34
+ var _ref4 = _slicedToArray(_ref3, 2),
35
+ key = _ref4[0],
36
+ value = _ref4[1];
37
+ return row[key] === value;
38
+ });
39
+ });
40
+ if (data.length && !matches.length) throw new Error('Invalid annotation: selection matches no data.');
41
+ matches.forEach(function (row) {
42
+ return selected.add(row);
43
+ });
44
+ };
45
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
+ _loop();
47
+ }
48
+ } catch (err) {
49
+ _iterator.e(err);
50
+ } finally {
51
+ _iterator.f();
52
+ }
53
+ return data.filter(function (row) {
54
+ return selected.has(row);
55
+ });
56
+ }
57
+
58
+ /** Missing and nonfinite values do not participate. Numeric strings are never coerced. */
59
+ export function numericRows(data, field) {
60
+ var temporal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
61
+ if (!field || data.length && !data.some(function (row) {
62
+ return Object.hasOwn(row, field);
63
+ })) throw new Error("Invalid annotation: unknown numeric field ".concat(field, "."));
64
+ return data.flatMap(function (row) {
65
+ var raw = row[field];
66
+ if (raw === null || raw === undefined || typeof raw === 'number' && !Number.isFinite(raw)) return [];
67
+ var value = temporal && typeof raw === 'string' && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(raw) ? Date.parse(raw) : raw;
68
+ if (typeof value !== 'number' || !Number.isFinite(value)) throw new Error("Invalid annotation: ".concat(field, " requires finite numeric").concat(temporal ? ' or ISO date' : '', " values."));
69
+ return [{
70
+ row: row,
71
+ value: value
72
+ }];
73
+ });
74
+ }
75
+ export function selectExtreme(data, field, maximum) {
76
+ var temporal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
77
+ var values = numericRows(data, field, temporal);
78
+ var extreme = values.reduce(function (result, _ref5) {
79
+ var value = _ref5.value;
80
+ return maximum ? Math.max(result, value) : Math.min(result, value);
81
+ }, maximum ? -Infinity : Infinity);
82
+ return values.filter(function (_ref6) {
83
+ var value = _ref6.value;
84
+ return value === extreme;
85
+ }).map(function (_ref7) {
86
+ var row = _ref7.row;
87
+ return row;
88
+ });
89
+ }
90
+ export function selectRank(data, field, n, descending) {
91
+ if (!Number.isSafeInteger(n) || n < 1) throw new Error('Invalid annotation: n must be a positive integer.');
92
+ return numericRows(data, field).sort(function (a, b) {
93
+ return descending ? b.value - a.value : a.value - b.value;
94
+ }).slice(0, n).map(function (_ref8) {
95
+ var row = _ref8.row;
96
+ return row;
97
+ });
98
+ }
99
+ export function selectRange(data, field, range, outside) {
100
+ if (!Array.isArray(range) || range.length !== 2 || !range.every(Number.isFinite) || range[0] > range[1]) throw new Error('Invalid annotation: range needs two finite, ordered bounds.');
101
+ return numericRows(data, field).filter(function (_ref9) {
102
+ var value = _ref9.value;
103
+ return outside ? value < range[0] || value > range[1] : value >= range[0] && value <= range[1];
104
+ }).map(function (_ref10) {
105
+ var row = _ref10.row;
106
+ return row;
107
+ });
108
+ }
109
+ export function selectedRows(data, selectors) {
110
+ if (selectors === undefined) throw new Error('Invalid annotation: selection needs target data.');
111
+ return selectRows(data, selectors);
112
+ }
113
+
114
+ /** Compare neighbours within each series in business order. Missing values break sequences. */
115
+ export function selectLocalExtrema(data, field, maximum, series) {
116
+ var _ref11 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
117
+ _ref11$minProminence = _ref11.minProminence,
118
+ minProminence = _ref11$minProminence === void 0 ? 0 : _ref11$minProminence,
119
+ _ref11$minDistance = _ref11.minDistance,
120
+ minDistance = _ref11$minDistance === void 0 ? 1 : _ref11$minDistance;
121
+ if (!Number.isFinite(minProminence) || minProminence < 0) throw new Error('Invalid annotation: minProminence must be nonnegative and finite.');
122
+ if (!Number.isSafeInteger(minDistance) || minDistance < 1) throw new Error('Invalid annotation: minDistance must be a positive integer in observations.');
123
+ var sign = maximum ? 1 : -1;
124
+ var values = new Map(numericRows(data, field).map(function (_ref12) {
125
+ var row = _ref12.row,
126
+ value = _ref12.value;
127
+ return [row, value];
128
+ }));
129
+ var groups = new Map();
130
+ var _iterator2 = _createForOfIteratorHelper(data),
131
+ _step2;
132
+ try {
133
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
134
+ var row = _step2.value;
135
+ var key = series ? row[series] : undefined;
136
+ if (!groups.has(key)) groups.set(key, []);
137
+ groups.get(key).push(row);
138
+ }
139
+ } catch (err) {
140
+ _iterator2.e(err);
141
+ } finally {
142
+ _iterator2.f();
143
+ }
144
+ var selected = new Set();
145
+ var _iterator3 = _createForOfIteratorHelper(groups.values()),
146
+ _step3;
147
+ try {
148
+ var _loop2 = function _loop2() {
149
+ var rows = _step3.value;
150
+ var candidates = [];
151
+ var _loop3 = function _loop3(_start) {
152
+ var value = values.get(rows[_start]);
153
+ if (value === undefined) {
154
+ _start++;
155
+ start = _start;
156
+ return 1; // continue
157
+ }
158
+ var end = _start;
159
+ while (end + 1 < rows.length && values.get(rows[end + 1]) === value) end++;
160
+ var left = values.get(rows[_start - 1]);
161
+ var right = values.get(rows[end + 1]);
162
+ if (left !== undefined && right !== undefined && (maximum ? value > left && value > right : value < left && value < right)) {
163
+ var height = sign * value;
164
+ var base = function base(from, step) {
165
+ var minimum = height;
166
+ for (var i = from; i >= 0 && i < rows.length; i += step) {
167
+ var current = values.get(rows[i]);
168
+ if (current === undefined || sign * current > height) break;
169
+ minimum = Math.min(minimum, sign * current);
170
+ }
171
+ return minimum;
172
+ };
173
+ candidates.push({
174
+ index: Math.floor((_start + end) / 2),
175
+ height: height,
176
+ prominence: minProminence === 0 ? 0 : height - Math.max(base(_start - 1, -1), base(end + 1, 1))
177
+ });
178
+ }
179
+ _start = end + 1;
180
+ start = _start;
181
+ };
182
+ for (var start = 1; start < rows.length - 1;) {
183
+ if (_loop3(start)) continue;
184
+ }
185
+ // Resolve spacing by height first, as in find_peaks; equal heights retain input order.
186
+ var spaced = minDistance === 1 ? candidates : [];
187
+ if (minDistance > 1) {
188
+ var _iterator4 = _createForOfIteratorHelper(candidates.sort(function (a, b) {
189
+ return b.height - a.height || a.index - b.index;
190
+ })),
191
+ _step4;
192
+ try {
193
+ var _loop4 = function _loop4() {
194
+ var candidate = _step4.value;
195
+ if (spaced.every(function (_ref13) {
196
+ var index = _ref13.index;
197
+ return Math.abs(index - candidate.index) >= minDistance;
198
+ })) spaced.push(candidate);
199
+ };
200
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
201
+ _loop4();
202
+ }
203
+ } catch (err) {
204
+ _iterator4.e(err);
205
+ } finally {
206
+ _iterator4.f();
207
+ }
208
+ }
209
+ var _iterator5 = _createForOfIteratorHelper(spaced),
210
+ _step5;
211
+ try {
212
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
213
+ var candidate = _step5.value;
214
+ if (candidate.prominence >= minProminence) selected.add(rows[candidate.index]);
215
+ }
216
+ } catch (err) {
217
+ _iterator5.e(err);
218
+ } finally {
219
+ _iterator5.f();
220
+ }
221
+ };
222
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
223
+ _loop2();
224
+ }
225
+ } catch (err) {
226
+ _iterator3.e(err);
227
+ } finally {
228
+ _iterator3.f();
229
+ }
230
+ return data.filter(function (row) {
231
+ return selected.has(row);
232
+ });
233
+ }
234
+
235
+ /** All renderers share the same dimming rule and reject invalid opacity before painting. */
236
+ export function getDimOpacity(annotations, fallback) {
237
+ var dim = 1;
238
+ var _iterator6 = _createForOfIteratorHelper(annotations),
239
+ _step6;
240
+ try {
241
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
242
+ var _style$dimOpacity;
243
+ var style = _step6.value.style;
244
+ var opacity = (_style$dimOpacity = style === null || style === void 0 ? void 0 : style.dimOpacity) !== null && _style$dimOpacity !== void 0 ? _style$dimOpacity : fallback;
245
+ if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) throw new Error('Invalid annotation: dimOpacity must be between 0 and 1.');
246
+ dim = Math.min(dim, opacity);
247
+ }
248
+ } catch (err) {
249
+ _iterator6.e(err);
250
+ } finally {
251
+ _iterator6.f();
252
+ }
253
+ return dim;
254
+ }
255
+
256
+ /** R-7 quantile of an ascending array; callers decide how to handle empty observations. */
257
+ export function quantileValue(values, p) {
258
+ if (!Number.isFinite(p) || p < 0 || p > 1) throw new Error('Invalid annotation: quantile p must be between 0 and 1.');
259
+ var index = (values.length - 1) * p;
260
+ var a = values[Math.floor(index)];
261
+ var b = values[Math.ceil(index)];
262
+ var t = index - Math.floor(index);
263
+ return Number.isFinite(b - a) ? a + (b - a) * t : a * (1 - t) + b * t;
264
+ }
265
+ export function finiteValue(value, name) {
266
+ if (typeof value !== 'number' || !Number.isFinite(value)) throw new Error("Invalid annotation: ".concat(name, " must be finite."));
267
+ return value;
268
+ }
269
+ export function annotationField(mapping) {
270
+ var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'y';
271
+ if (axis !== 'x' && axis !== 'y') throw new Error('Invalid annotation: axis must be x or y.');
272
+ return mapping[axis];
273
+ }
274
+
275
+ /** Construct mapped coordinates; field names stay business-facing throughout composition. */
276
+ export function axisPosition(field, value) {
277
+ if (typeof value === 'number') finiteValue(value, field);else if (typeof value !== 'string' || !value.length) throw new Error('Invalid annotation: axis positions need a number or nonempty string.');
278
+ return _defineProperty({}, field, value);
279
+ }
280
+
281
+ /** Map a single-axis interval without imposing a business meaning on its bounds. */
282
+ export function axisRange(field, bounds) {
283
+ if (!Array.isArray(bounds) || bounds.length !== 2) throw new Error('Invalid annotation: range needs two boundary values.');
284
+ var _iterator7 = _createForOfIteratorHelper(bounds),
285
+ _step7;
286
+ try {
287
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
288
+ var value = _step7.value;
289
+ axisPosition(field, value);
290
+ }
291
+ } catch (err) {
292
+ _iterator7.e(err);
293
+ } finally {
294
+ _iterator7.f();
295
+ }
296
+ if (_typeof(bounds[0]) !== _typeof(bounds[1])) throw new Error('Invalid annotation: range boundaries must have the same type.');
297
+ if (typeof bounds[0] === 'number' && bounds[0] > bounds[1]) throw new Error('Invalid annotation: numeric range bounds must be ordered.');
298
+ return _defineProperty({}, field, bounds);
299
+ }
300
+ export function formatNumber(value) {
301
+ return new Intl.NumberFormat('en-US', {
302
+ maximumFractionDigits: 4
303
+ }).format(value);
304
+ }
305
+
306
+ /** G2 and G6 share the native AntV scene and animation API. */
307
+ export function createPointPulse(scene, defaults, redraw) {
308
+ var rings = new Set();
309
+ var motion = window.matchMedia('(prefers-reduced-motion: reduce)');
310
+ var clear = function clear() {
311
+ var _iterator8 = _createForOfIteratorHelper(rings),
312
+ _step8;
313
+ try {
314
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
315
+ var ring = _step8.value;
316
+ ring.destroy();
317
+ }
318
+ } catch (err) {
319
+ _iterator8.e(err);
320
+ } finally {
321
+ _iterator8.f();
322
+ }
323
+ rings.clear();
324
+ };
325
+ // Rebuild halos: cancellation can still flush the old native animation frame.
326
+ motion.addEventListener('change', redraw);
327
+ return {
328
+ add: function add(parent, _ref16, size, color) {
329
+ var _ref17 = _slicedToArray(_ref16, 2),
330
+ x = _ref17[0],
331
+ y = _ref17[1];
332
+ var animated = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
333
+ var ring = scene.createElement('circle', {
334
+ className: 'annotation-pulse',
335
+ style: {
336
+ cx: x,
337
+ cy: y,
338
+ r: size * defaults.staticScale,
339
+ stroke: color,
340
+ fill: 'none',
341
+ lineWidth: defaults.lineWidth,
342
+ opacity: defaults.opacity,
343
+ pointerEvents: 'none',
344
+ zIndex: -1
345
+ }
346
+ });
347
+ parent.appendChild(ring);
348
+ rings.add(ring);
349
+ if (!animated || motion.matches) return;
350
+ var animation = ring.animate([{
351
+ r: size * defaults.startScale,
352
+ opacity: defaults.opacity
353
+ }, {
354
+ r: size * defaults.endScale,
355
+ opacity: 0
356
+ }], {
357
+ duration: defaults.duration,
358
+ iterations: Infinity,
359
+ easing: 'ease-out'
360
+ });
361
+ // Keep batches and subsequent redraws on the same pulse phase.
362
+ if (animation) animation.currentTime = performance.now() % defaults.duration;
363
+ },
364
+ clear: clear,
365
+ destroy: function destroy() {
366
+ motion.removeEventListener('change', redraw);
367
+ clear();
368
+ }
369
+ };
370
+ }
@@ -0,0 +1,236 @@
1
+ import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
2
+ import type { getThemeObject } from './g2';
3
+ /** Graph and DOM annotations follow their chart's theme and local styles. */
4
+ export declare function getAnnotationDefaults(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
5
+ stroke: string;
6
+ pointStroke: string;
7
+ lineWidth: {
8
+ path: number;
9
+ connector: number;
10
+ point: number;
11
+ };
12
+ size: number;
13
+ shape: string;
14
+ pulse: {
15
+ duration: number;
16
+ startScale: number;
17
+ endScale: number;
18
+ staticScale: number;
19
+ opacity: number;
20
+ lineWidth: number;
21
+ };
22
+ connector: {
23
+ offset: number;
24
+ extension: number;
25
+ curveRatio: number;
26
+ maxCurveHeight: number;
27
+ arrowSize: number;
28
+ };
29
+ labelFill: string;
30
+ fontFamily: string;
31
+ labelFontSize: number;
32
+ fontWeight: number | "normal" | "bold";
33
+ labels: {
34
+ path: {
35
+ padding: number[];
36
+ backgroundOpacity: number;
37
+ fill: string;
38
+ background: string;
39
+ border: string;
40
+ borderOpacity: number;
41
+ radius: number;
42
+ maxWidth: number;
43
+ gap: number;
44
+ fontWeight: number | "normal" | "bold";
45
+ };
46
+ range: {
47
+ border: string;
48
+ borderOpacity: number;
49
+ backgroundOpacity: number;
50
+ fill: string;
51
+ background: string;
52
+ padding: number[];
53
+ radius: number;
54
+ maxWidth: number;
55
+ gap: number;
56
+ fontWeight: number | "normal" | "bold";
57
+ };
58
+ connector: {
59
+ padding: number[];
60
+ fontWeight: number;
61
+ fill: string;
62
+ background: string;
63
+ backgroundOpacity: number;
64
+ border: string;
65
+ borderOpacity: number;
66
+ radius: number;
67
+ maxWidth: number;
68
+ gap: number;
69
+ };
70
+ point: {
71
+ border: string;
72
+ padding: number[];
73
+ radius: number;
74
+ maxWidth: number;
75
+ gap: number;
76
+ fontWeight: number;
77
+ fill: string;
78
+ background: string;
79
+ backgroundOpacity: number;
80
+ borderOpacity: number;
81
+ };
82
+ text: {
83
+ background: string;
84
+ padding: number[];
85
+ maxWidth: number;
86
+ gap: number;
87
+ fill: string;
88
+ backgroundOpacity: number;
89
+ border: string;
90
+ borderOpacity: number;
91
+ radius: number;
92
+ fontWeight: number | "normal" | "bold";
93
+ };
94
+ highlight: {
95
+ border: string;
96
+ padding: number[];
97
+ gap: number;
98
+ fill: string;
99
+ background: string;
100
+ backgroundOpacity: number;
101
+ borderOpacity: number;
102
+ radius: number;
103
+ maxWidth: number;
104
+ fontWeight: number | "normal" | "bold";
105
+ };
106
+ };
107
+ highlight: {
108
+ color: string;
109
+ fillOpacity: number;
110
+ dimOpacity: number;
111
+ background: string;
112
+ labelBackground: string;
113
+ labelBorder: string;
114
+ labelGap: number;
115
+ contributionDimOpacity: number;
116
+ pieDimOpacity: number;
117
+ lineWidth: number;
118
+ };
119
+ };
120
+ /** Annotation defaults follow the resolved chart theme. */
121
+ export declare function getAnnotationStyle({ theme, mark }: ReturnType<typeof getThemeObject>): {
122
+ palette: string[];
123
+ directions: {
124
+ up: string;
125
+ down: string;
126
+ };
127
+ stroke: string;
128
+ pointStroke: string;
129
+ lineWidth: {
130
+ path: number;
131
+ range: number;
132
+ connector: number;
133
+ point: number;
134
+ };
135
+ fillOpacity: number;
136
+ size: number;
137
+ shape: string;
138
+ pulse: {
139
+ duration: number;
140
+ startScale: number;
141
+ endScale: number;
142
+ staticScale: number;
143
+ opacity: number;
144
+ lineWidth: number;
145
+ };
146
+ connector: {
147
+ offset: number;
148
+ extension: number;
149
+ curveRatio: number;
150
+ maxCurveHeight: number;
151
+ arrowSize: number;
152
+ };
153
+ highlight: {
154
+ color: string;
155
+ dimOpacity: number;
156
+ contributionDimOpacity: number;
157
+ pieDimOpacity: number;
158
+ lineWidth: number;
159
+ };
160
+ fontFamily: string;
161
+ labelFontSize: number;
162
+ labels: {
163
+ path: {
164
+ padding: number[];
165
+ backgroundOpacity: number;
166
+ fill: string;
167
+ background: string;
168
+ border: string;
169
+ borderOpacity: number;
170
+ radius: number;
171
+ maxWidth: number;
172
+ gap: number;
173
+ fontWeight: number | "normal" | "bold";
174
+ };
175
+ range: {
176
+ border: string;
177
+ borderOpacity: number;
178
+ backgroundOpacity: number;
179
+ fill: string;
180
+ background: string;
181
+ padding: number[];
182
+ radius: number;
183
+ maxWidth: number;
184
+ gap: number;
185
+ fontWeight: number | "normal" | "bold";
186
+ };
187
+ connector: {
188
+ padding: number[];
189
+ fontWeight: number;
190
+ fill: string;
191
+ background: string;
192
+ backgroundOpacity: number;
193
+ border: string;
194
+ borderOpacity: number;
195
+ radius: number;
196
+ maxWidth: number;
197
+ gap: number;
198
+ };
199
+ point: {
200
+ border: string;
201
+ padding: number[];
202
+ radius: number;
203
+ maxWidth: number;
204
+ gap: number;
205
+ fontWeight: number;
206
+ fill: string;
207
+ background: string;
208
+ backgroundOpacity: number;
209
+ borderOpacity: number;
210
+ };
211
+ text: {
212
+ background: string;
213
+ padding: number[];
214
+ maxWidth: number;
215
+ gap: number;
216
+ fill: string;
217
+ backgroundOpacity: number;
218
+ border: string;
219
+ borderOpacity: number;
220
+ radius: number;
221
+ fontWeight: number | "normal" | "bold";
222
+ };
223
+ highlight: {
224
+ border: string;
225
+ padding: number[];
226
+ gap: number;
227
+ fill: string;
228
+ background: string;
229
+ backgroundOpacity: number;
230
+ borderOpacity: number;
231
+ radius: number;
232
+ maxWidth: number;
233
+ fontWeight: number | "normal" | "bold";
234
+ };
235
+ };
236
+ };