@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,40 @@
1
+ import { type Graph } from '@antv/g6';
2
+ import type { getAnnotationDefaults } from '../../theme/annotation';
3
+ import type { GraphData } from '../../types';
4
+ import type { AnnotationData } from '../../types/annotation';
5
+ import { type Box, type Point, type Segment } from '../layout';
6
+ import type { RendererAnnotation } from '../registry';
7
+ import { createPointPulse } from '../utils';
8
+ import type { AnnotationBindingOptions } from './index';
9
+ type Scene = ReturnType<Graph['getCanvas']>['document'];
10
+ export interface G6AnnotationContext<T extends object> {
11
+ chartType: 'network-graph';
12
+ data: T[];
13
+ scene: Scene;
14
+ root: Pick<ReturnType<Scene['createElement']>, 'appendChild'>;
15
+ defaults: ReturnType<typeof getAnnotationDefaults>;
16
+ size: Point;
17
+ centers: Point[];
18
+ boxes: Box[];
19
+ segments: Segment[];
20
+ pulse(): ReturnType<typeof createPointPulse>;
21
+ position(data: AnnotationData<T>): Point | undefined;
22
+ add(tag: string, style: Record<string, unknown>, className?: string): void;
23
+ label(annotation: RendererAnnotation<T, 'g6'>, anchor: Point, options?: {
24
+ standalone?: boolean;
25
+ gap?: number;
26
+ fill?: string;
27
+ }): void;
28
+ }
29
+ type Datum = GraphData['nodes'][number] | GraphData['edges'][number];
30
+ export interface G6AnnotationOptions {
31
+ renderer: 'g6';
32
+ graph: Graph;
33
+ annotations?: RendererAnnotation<Datum, 'g6'>[];
34
+ data: GraphData;
35
+ edgeIds: string[];
36
+ defaults: ReturnType<typeof getAnnotationDefaults>;
37
+ }
38
+ /** Business data selects graph elements; generated edge IDs stay inside the runtime. */
39
+ export declare function bindAnnotations<T extends object>(options: AnnotationBindingOptions<T>): (() => void) | undefined;
40
+ export {};
@@ -0,0 +1,447 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
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 _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; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 { Label } from '@antv/g6';
19
+ import { placeLabel, routeLeader } from "../layout";
20
+ import { mergeAnnotations } from "../merge";
21
+ import { drawAnnotations, prepareAnnotations } from "../registry";
22
+ import { createPointPulse, getDimOpacity, selectedRows } from "../utils";
23
+ /** Business data selects graph elements; generated edge IDs stay inside the runtime. */
24
+ export function bindAnnotations(options) {
25
+ var _options$annotations;
26
+ if (options.renderer !== 'g6') return;
27
+ var graph = options.graph,
28
+ data = options.data,
29
+ edgeIds = options.edgeIds,
30
+ defaults = options.defaults;
31
+ if (!((_options$annotations = options.annotations) !== null && _options$annotations !== void 0 && _options$annotations.length)) return function () {};
32
+ var rows = [].concat(_toConsumableArray(data.nodes), _toConsumableArray(data.edges));
33
+ var prepared = prepareAnnotations('g6', options.annotations, {
34
+ chartType: 'network-graph',
35
+ data: rows
36
+ });
37
+ var annotations = prepared.map(function (_ref) {
38
+ var annotation = _ref.annotation;
39
+ return annotation;
40
+ });
41
+ var groups = mergeAnnotations(prepared);
42
+ var cleanupHighlights = bindHighlights(options, annotations);
43
+ var position = function position(selector) {
44
+ var _rows$find;
45
+ var row = (_rows$find = rows.find(function (row) {
46
+ return row === selector;
47
+ })) !== null && _rows$find !== void 0 ? _rows$find : selectDatum(rows, selector);
48
+ var id = 'source' in row ? edgeIds[data.edges.indexOf(row)] : row.name;
49
+ if (graph.getElementVisibility(id) === 'hidden') return undefined;
50
+ var anchor = 'source' in row ? graph.getElementRenderBounds(id).center : graph.getElementPosition(id);
51
+ var center = graph.getViewportByCanvas(anchor);
52
+ return [center[0], center[1]];
53
+ };
54
+ var layer;
55
+ var events = ['afterlayout', 'afterdraw', 'aftertransform', 'aftersizechange'];
56
+ var draw = function draw() {
57
+ var _layer;
58
+ return (_layer = layer) === null || _layer === void 0 ? void 0 : _layer.draw();
59
+ };
60
+ var render = function render() {
61
+ var _layer2;
62
+ (_layer2 = layer) !== null && _layer2 !== void 0 ? _layer2 : layer = createLayer(graph, groups, position, defaults, data);
63
+ draw();
64
+ };
65
+ graph.on('afterrender', render);
66
+ for (var _i = 0, _events = events; _i < _events.length; _i++) {
67
+ var event = _events[_i];
68
+ graph.on(event, draw);
69
+ }
70
+ var cleanup = function cleanup() {
71
+ var _layer3;
72
+ graph.off('afterrender', render);
73
+ for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
74
+ var _event = _events2[_i2];
75
+ graph.off(_event, draw);
76
+ }
77
+ graph.off('beforedestroy', cleanup);
78
+ (_layer3 = layer) === null || _layer3 === void 0 || _layer3.destroy();
79
+ cleanupHighlights();
80
+ };
81
+ graph.on('beforedestroy', cleanup);
82
+ return cleanup;
83
+ }
84
+
85
+ /** Apply native graph data styles before render; never add replacement nodes or edges. */
86
+ function bindHighlights(_ref2, annotations) {
87
+ var graph = _ref2.graph,
88
+ data = _ref2.data,
89
+ edgeIds = _ref2.edgeIds,
90
+ defaults = _ref2.defaults;
91
+ var highlights = annotations.filter(function (annotation) {
92
+ return annotation.type === 'highlight';
93
+ });
94
+ if (!highlights.length) return function () {};
95
+ var rows = [].concat(_toConsumableArray(data.nodes), _toConsumableArray(data.edges));
96
+ var selections = highlights.map(function (annotation) {
97
+ var selected = selectedRows(rows, annotation.data);
98
+ if (!selected.length) throw new Error('Invalid annotation: highlight matches no data.');
99
+ return {
100
+ annotation: annotation,
101
+ rows: selected
102
+ };
103
+ });
104
+ var dim = getDimOpacity(highlights, defaults.highlight.dimOpacity);
105
+ var restore = [];
106
+ var _iterator = _createForOfIteratorHelper(rows.entries()),
107
+ _step;
108
+ try {
109
+ var _loop = function _loop() {
110
+ var _original$style$opaci, _original$style;
111
+ var _step$value = _slicedToArray(_step.value, 2),
112
+ index = _step$value[0],
113
+ row = _step$value[1];
114
+ var edge = index >= data.nodes.length;
115
+ var id = edge ? edgeIds[index - data.nodes.length] : data.nodes[index].name;
116
+ var original = edge ? graph.getEdgeData(id) : graph.getNodeData(id);
117
+ var matches = selections.filter(function (_ref3) {
118
+ var rows = _ref3.rows;
119
+ return rows.includes(row);
120
+ });
121
+ var style = matches.length ? {} : {
122
+ opacity: Number((_original$style$opaci = (_original$style = original.style) === null || _original$style === void 0 ? void 0 : _original$style.opacity) !== null && _original$style$opaci !== void 0 ? _original$style$opaci : 1) * dim
123
+ };
124
+ var _iterator2 = _createForOfIteratorHelper(matches),
125
+ _step2;
126
+ try {
127
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
128
+ var _annotation = _step2.value.annotation;
129
+ var _iterator3 = _createForOfIteratorHelper(['fill', 'stroke', 'lineWidth', 'fillOpacity']),
130
+ _step3;
131
+ try {
132
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
133
+ var _annotation$style;
134
+ var key = _step3.value;
135
+ if (((_annotation$style = _annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style[key]) !== undefined) style[key] = _annotation.style[key];
136
+ }
137
+ } catch (err) {
138
+ _iterator3.e(err);
139
+ } finally {
140
+ _iterator3.f();
141
+ }
142
+ }
143
+ } catch (err) {
144
+ _iterator2.e(err);
145
+ } finally {
146
+ _iterator2.f();
147
+ }
148
+ var previous = Object.fromEntries(Object.keys(style).map(function (key) {
149
+ var _original$style2;
150
+ return [key, (_original$style2 = original.style) === null || _original$style2 === void 0 ? void 0 : _original$style2[key]];
151
+ }));
152
+ if (edge) {
153
+ graph.updateEdgeData([{
154
+ id: id,
155
+ style: style
156
+ }]);
157
+ restore.push(function () {
158
+ return graph.updateEdgeData([{
159
+ id: id,
160
+ style: previous
161
+ }]);
162
+ });
163
+ } else {
164
+ graph.updateNodeData([{
165
+ id: id,
166
+ style: style
167
+ }]);
168
+ restore.push(function () {
169
+ return graph.updateNodeData([{
170
+ id: id,
171
+ style: previous
172
+ }]);
173
+ });
174
+ }
175
+ };
176
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
177
+ _loop();
178
+ }
179
+ } catch (err) {
180
+ _iterator.e(err);
181
+ } finally {
182
+ _iterator.f();
183
+ }
184
+ var disposed = false;
185
+ return function () {
186
+ if (disposed) return;
187
+ disposed = true;
188
+ restore.forEach(function (reset) {
189
+ return reset();
190
+ });
191
+ };
192
+ }
193
+ function selectDatum(data, selector) {
194
+ var entries = Object.entries(selector);
195
+ var matches = data.filter(function (row) {
196
+ return entries.every(function (_ref4) {
197
+ var _ref5 = _slicedToArray(_ref4, 2),
198
+ key = _ref5[0],
199
+ value = _ref5[1];
200
+ return row[key] === value;
201
+ });
202
+ });
203
+ if (matches.length !== 1) throw new Error("Invalid annotation: selector matches ".concat(matches.length, " objects; expected one."));
204
+ return matches[0];
205
+ }
206
+
207
+ /** Native canvas shapes and labels, independent of the graph's own node and edge labels. */
208
+ function createLayer(graph, groups, position, defaults, data) {
209
+ var canvas = graph.getCanvas();
210
+ var scene = canvas.document;
211
+ var root = scene.createElement('g', {
212
+ className: 'annotations',
213
+ style: {
214
+ pointerEvents: 'none',
215
+ zIndex: 1000
216
+ }
217
+ });
218
+ canvas.appendChild(root);
219
+ var disposed = false;
220
+ var cleanupAnnotations;
221
+ var pulse;
222
+ var draw = function draw() {
223
+ var _cleanupAnnotations, _pulse;
224
+ if (disposed) return;
225
+ var _canvas$getSize = canvas.getSize(),
226
+ _canvas$getSize2 = _slicedToArray(_canvas$getSize, 2),
227
+ width = _canvas$getSize2[0],
228
+ height = _canvas$getSize2[1];
229
+ // Cancel the camera transform so marks, text and stroke widths stay in screen pixels.
230
+ root.setLocalPosition(graph.getCanvasByViewport([0, 0]));
231
+ root.setLocalScale(1 / graph.getZoom());
232
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
233
+ (_pulse = pulse) === null || _pulse === void 0 || _pulse.clear();
234
+ root.destroyChildren();
235
+ var boxes = [];
236
+ var segments = [];
237
+ var centers = [];
238
+ var _iterator4 = _createForOfIteratorHelper(data.nodes),
239
+ _step4;
240
+ try {
241
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
242
+ var node = _step4.value;
243
+ if (graph.getElementVisibility(node.name) === 'hidden') continue;
244
+ var _graph$getViewportByC = graph.getViewportByCanvas(graph.getElementPosition(node.name)),
245
+ _graph$getViewportByC2 = _slicedToArray(_graph$getViewportByC, 2),
246
+ x = _graph$getViewportByC2[0],
247
+ y = _graph$getViewportByC2[1];
248
+ centers.push([x, y]);
249
+ var _graph$getElementRend = graph.getElementRenderBounds(node.name),
250
+ _min = _graph$getElementRend.min,
251
+ max = _graph$getElementRend.max;
252
+ var a = graph.getViewportByCanvas(_min);
253
+ var b = graph.getViewportByCanvas(max);
254
+ boxes.push({
255
+ x: a[0],
256
+ y: a[1],
257
+ width: b[0] - a[0],
258
+ height: b[1] - a[1]
259
+ });
260
+ }
261
+ } catch (err) {
262
+ _iterator4.e(err);
263
+ } finally {
264
+ _iterator4.f();
265
+ }
266
+ var _iterator5 = _createForOfIteratorHelper(data.edges),
267
+ _step5;
268
+ try {
269
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
270
+ var edge = _step5.value;
271
+ if ([edge.source, edge.target].some(function (id) {
272
+ return graph.getElementVisibility(id) === 'hidden';
273
+ })) continue;
274
+ var points = [edge.source, edge.target].map(function (id) {
275
+ return graph.getViewportByCanvas(graph.getElementPosition(id));
276
+ });
277
+ segments.push([[points[0][0], points[0][1]], [points[1][0], points[1][1]]]);
278
+ }
279
+ } catch (err) {
280
+ _iterator5.e(err);
281
+ } finally {
282
+ _iterator5.f();
283
+ }
284
+ var cards = [];
285
+ var add = function add(tag, style) {
286
+ var className = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'annotation-mark';
287
+ var shape = scene.createElement(tag, {
288
+ className: className,
289
+ style: _objectSpread(_objectSpread({}, style), {}, {
290
+ pointerEvents: 'none'
291
+ })
292
+ });
293
+ root.appendChild(shape);
294
+ };
295
+ var label = function label(annotation, _ref6) {
296
+ var _options$standalone, _annotation$style$lab, _annotation$style2, _ref8, _annotation$style$lab2, _annotation$style3, _options$gap;
297
+ var _ref7 = _slicedToArray(_ref6, 2),
298
+ x = _ref7[0],
299
+ y = _ref7[1];
300
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
301
+ if (!annotation.label) return;
302
+ var standalone = (_options$standalone = options.standalone) !== null && _options$standalone !== void 0 ? _options$standalone : false;
303
+ var style = defaults.labels[annotation.type];
304
+ var fontSize = (_annotation$style$lab = (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.labelFontSize) !== null && _annotation$style$lab !== void 0 ? _annotation$style$lab : defaults.labelFontSize;
305
+ var _style$padding = _slicedToArray(style.padding, 2),
306
+ px = _style$padding[1];
307
+ var card = new Label({
308
+ className: "annotation-label annotation-".concat(annotation.type),
309
+ style: {
310
+ text: annotation.label,
311
+ fill: (_ref8 = (_annotation$style$lab2 = (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.labelFill) !== null && _annotation$style$lab2 !== void 0 ? _annotation$style$lab2 : options.fill) !== null && _ref8 !== void 0 ? _ref8 : style.fill,
312
+ fontFamily: defaults.fontFamily,
313
+ fontSize: fontSize,
314
+ fontWeight: style.fontWeight,
315
+ lineHeight: Math.ceil(fontSize * 1.5),
316
+ textAlign: standalone ? 'center' : 'left',
317
+ wordWrapWidth: Math.max(fontSize, Math.min(style.maxWidth, width) - px * 2),
318
+ maxLines: Infinity,
319
+ textOverflow: 'clip',
320
+ padding: style.padding,
321
+ background: !standalone,
322
+ backgroundFill: style.background,
323
+ backgroundFillOpacity: style.backgroundOpacity,
324
+ backgroundOpacity: 1,
325
+ backgroundStroke: style.border,
326
+ backgroundStrokeOpacity: style.borderOpacity,
327
+ backgroundLineWidth: 1,
328
+ backgroundRadius: style.radius,
329
+ pointerEvents: 'none',
330
+ zIndex: 2
331
+ }
332
+ });
333
+ root.appendChild(card);
334
+ var bounds = card.getGeometryBounds();
335
+ var _bounds$halfExtents$m = bounds.halfExtents.map(function (size) {
336
+ return size * 2;
337
+ }),
338
+ _bounds$halfExtents$m2 = _slicedToArray(_bounds$halfExtents$m, 2),
339
+ labelWidth = _bounds$halfExtents$m2[0],
340
+ labelHeight = _bounds$halfExtents$m2[1];
341
+ if (standalone) {
342
+ card.setLocalPosition([x - bounds.center[0], y - bounds.center[1]]);
343
+ boxes.push({
344
+ x: x - labelWidth / 2,
345
+ y: y - labelHeight / 2,
346
+ width: labelWidth,
347
+ height: labelHeight
348
+ });
349
+ return;
350
+ }
351
+ cards.push({
352
+ card: card,
353
+ annotation: annotation,
354
+ anchor: [x, y],
355
+ extraGap: (_options$gap = options.gap) !== null && _options$gap !== void 0 ? _options$gap : 0,
356
+ min: [bounds.min[0], bounds.min[1]],
357
+ bounds: {
358
+ x: 0,
359
+ y: 0,
360
+ width: labelWidth,
361
+ height: labelHeight
362
+ }
363
+ });
364
+ };
365
+ var context = {
366
+ chartType: 'network-graph',
367
+ data: [].concat(_toConsumableArray(data.nodes), _toConsumableArray(data.edges)),
368
+ scene: scene,
369
+ root: root,
370
+ defaults: defaults,
371
+ size: [width, height],
372
+ centers: centers,
373
+ boxes: boxes,
374
+ segments: segments,
375
+ position: position,
376
+ add: add,
377
+ label: label,
378
+ pulse: function (_pulse2) {
379
+ function pulse() {
380
+ return _pulse2.apply(this, arguments);
381
+ }
382
+ pulse.toString = function () {
383
+ return _pulse2.toString();
384
+ };
385
+ return pulse;
386
+ }(function () {
387
+ var _pulse3;
388
+ return (_pulse3 = pulse) !== null && _pulse3 !== void 0 ? _pulse3 : pulse = createPointPulse(scene, defaults.pulse, draw);
389
+ })
390
+ };
391
+ var result = drawAnnotations(groups, context);
392
+ cleanupAnnotations = result.cleanup;
393
+ // Measure every fixed text and mark before placing any attached card, regardless of input order.
394
+ for (var _i3 = 0, _cards = cards; _i3 < _cards.length; _i3++) {
395
+ var item = _cards[_i3];
396
+ var _annotation2 = item.annotation,
397
+ _anchor = item.anchor,
398
+ card = item.card,
399
+ min = item.min;
400
+ var gap = defaults.labels[_annotation2.type].gap + item.extraGap;
401
+ item.bounds = placeLabel(_anchor, [item.bounds.width, item.bounds.height], [width, height], gap, boxes, segments);
402
+ boxes.push(item.bounds);
403
+ card.setLocalPosition([item.bounds.x - min[0], item.bounds.y - min[1]]);
404
+ }
405
+ var _loop2 = function _loop2() {
406
+ var _annotation$style$str, _annotation$style4;
407
+ var _cards2$_i = _cards2[_i4],
408
+ annotation = _cards2$_i.annotation,
409
+ anchor = _cards2$_i.anchor,
410
+ bounds = _cards2$_i.bounds;
411
+ var route = routeLeader(anchor, bounds, boxes, segments);
412
+ if (!route.length) return 1; // continue
413
+ add('path', {
414
+ d: route.map(function (_ref9, index) {
415
+ var _ref10 = _slicedToArray(_ref9, 2),
416
+ x = _ref10[0],
417
+ y = _ref10[1];
418
+ return [index ? 'L' : 'M', x, y];
419
+ }),
420
+ stroke: annotation.type === 'text' ? defaults.stroke : (_annotation$style$str = (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.stroke) !== null && _annotation$style$str !== void 0 ? _annotation$style$str : defaults.stroke,
421
+ lineWidth: 1,
422
+ strokeOpacity: 0.5,
423
+ zIndex: 1
424
+ }, 'annotation-leader');
425
+ route.slice(1).forEach(function (point, index) {
426
+ return segments.push([route[index], point]);
427
+ });
428
+ };
429
+ for (var _i4 = 0, _cards2 = cards; _i4 < _cards2.length; _i4++) {
430
+ if (_loop2()) continue;
431
+ }
432
+ };
433
+ // Wrapping now depends on font metrics, so update once web fonts become available.
434
+ document.fonts.ready.then(draw);
435
+ document.fonts.addEventListener('loadingdone', draw);
436
+ return {
437
+ draw: draw,
438
+ destroy: function destroy() {
439
+ var _cleanupAnnotations2, _pulse4;
440
+ disposed = true;
441
+ document.fonts.removeEventListener('loadingdone', draw);
442
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
443
+ (_pulse4 = pulse) === null || _pulse4 === void 0 || _pulse4.destroy();
444
+ root.destroy();
445
+ }
446
+ };
447
+ }
@@ -0,0 +1,11 @@
1
+ import { type G2AnnotationOptions } from './g2';
2
+ import { type G6AnnotationOptions } from './g6';
3
+ import { type SummaryAnnotationOptions } from './summary';
4
+ import { type TableAnnotationOptions } from './table';
5
+ export type { G2AnnotationContext, MarkElement, MarkOptions, Scene } from './g2';
6
+ export type { G6AnnotationContext } from './g6';
7
+ export type { SummaryContext } from './summary';
8
+ export type { TableContext } from './table';
9
+ export type AnnotationBindingOptions<T extends object> = G2AnnotationOptions<T> | G6AnnotationOptions | TableAnnotationOptions<T> | SummaryAnnotationOptions;
10
+ /** Each runtime checks the explicit renderer and returns its cleanup when applicable. */
11
+ export declare function bindAnnotations<T extends object>(options: AnnotationBindingOptions<T>): () => void;
@@ -0,0 +1,26 @@
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
+ import { bindAnnotations as bindG2 } from "./g2";
5
+ import { bindAnnotations as bindG6 } from "./g6";
6
+ import { bindAnnotations as bindSummary } from "./summary";
7
+ import { bindAnnotations as bindTable } from "./table";
8
+ var binders = [bindG2, bindG6, bindTable, bindSummary];
9
+
10
+ /** Each runtime checks the explicit renderer and returns its cleanup when applicable. */
11
+ export function bindAnnotations(options) {
12
+ var _iterator = _createForOfIteratorHelper(binders),
13
+ _step;
14
+ try {
15
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
+ var bind = _step.value;
17
+ var cleanup = bind(options);
18
+ if (cleanup) return cleanup;
19
+ }
20
+ } catch (err) {
21
+ _iterator.e(err);
22
+ } finally {
23
+ _iterator.f();
24
+ }
25
+ throw new Error('Unsupported annotation runtime.');
26
+ }
@@ -0,0 +1,17 @@
1
+ import type { getAnnotationDefaults } from '../../theme/annotation';
2
+ import type { RendererAnnotation } from '../registry';
3
+ import type { AnnotationBindingOptions } from './index';
4
+ export interface SummaryContext {
5
+ chartType: 'summary';
6
+ container: HTMLElement;
7
+ content: HTMLElement;
8
+ defaults: ReturnType<typeof getAnnotationDefaults>;
9
+ }
10
+ export interface SummaryAnnotationOptions extends Omit<SummaryContext, 'chartType'> {
11
+ renderer: 'summary';
12
+ annotations?: RendererAnnotation<{
13
+ text: string;
14
+ }, 'summary'>[];
15
+ }
16
+ /** Bind summary annotations and return the resources to clean up on the next render. */
17
+ export declare function bindAnnotations<T extends object>(options: AnnotationBindingOptions<T>): (() => void) | undefined;
@@ -0,0 +1,21 @@
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
+ var _excluded = ["annotations"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ import { renderAnnotations } from "../registry";
11
+ /** Bind summary annotations and return the resources to clean up on the next render. */
12
+ export function bindAnnotations(options) {
13
+ var _renderAnnotations$cl;
14
+ if (options.renderer !== 'summary') return;
15
+ var annotations = options.annotations,
16
+ context = _objectWithoutProperties(options, _excluded);
17
+ if (!(annotations !== null && annotations !== void 0 && annotations.length)) return function () {};
18
+ return (_renderAnnotations$cl = renderAnnotations('summary', annotations, _objectSpread(_objectSpread({}, context), {}, {
19
+ chartType: 'summary'
20
+ })).cleanup) !== null && _renderAnnotations$cl !== void 0 ? _renderAnnotations$cl : function () {};
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { getAnnotationDefaults } from '../../theme/annotation';
2
+ import type { RendererAnnotation } from '../registry';
3
+ import type { AnnotationBindingOptions } from './index';
4
+ export interface TableContext<T extends object> {
5
+ chartType: 'table';
6
+ container: HTMLElement;
7
+ content: HTMLElement;
8
+ data: T[];
9
+ defaults: ReturnType<typeof getAnnotationDefaults>;
10
+ }
11
+ export interface TableAnnotationOptions<T extends object> extends Omit<TableContext<T>, 'chartType'> {
12
+ renderer: 'table';
13
+ annotations?: RendererAnnotation<T, 'table'>[];
14
+ }
15
+ /** Bind table annotations and return the resources to clean up on the next render. */
16
+ export declare function bindAnnotations<T extends object>(options: AnnotationBindingOptions<T>): (() => void) | undefined;
@@ -0,0 +1,21 @@
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
+ var _excluded = ["annotations"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ import { renderAnnotations } from "../registry";
11
+ /** Bind table annotations and return the resources to clean up on the next render. */
12
+ export function bindAnnotations(options) {
13
+ var _renderAnnotations$cl;
14
+ if (options.renderer !== 'table') return;
15
+ var annotations = options.annotations,
16
+ context = _objectWithoutProperties(options, _excluded);
17
+ if (!(annotations !== null && annotations !== void 0 && annotations.length)) return function () {};
18
+ return (_renderAnnotations$cl = renderAnnotations('table', annotations, _objectSpread(_objectSpread({}, context), {}, {
19
+ chartType: 'table'
20
+ })).cleanup) !== null && _renderAnnotations$cl !== void 0 ? _renderAnnotations$cl : function () {};
21
+ }
@@ -0,0 +1,40 @@
1
+ import type { ShapeComponent } from '@antv/g2';
2
+ import type { getAnnotationDefaults } from '../theme/annotation';
3
+ import type { Annotation, AnnotationData } from '../types/annotation';
4
+ import type { Point } from './layout';
5
+ import type { G2AnnotationContext } from './runtime/g2';
6
+ /** Resolve original-field selectors without reordering or modifying business data. */
7
+ export declare function selectRows<T extends object>(data: T[], selectors?: AnnotationData<T> | AnnotationData<T>[]): T[];
8
+ /** Missing and nonfinite values do not participate. Numeric strings are never coerced. */
9
+ export declare function numericRows<T extends object>(data: T[], field: keyof T & string, temporal?: boolean): {
10
+ row: T;
11
+ value: number | (T[keyof T & string] & number);
12
+ }[];
13
+ export declare function selectExtreme<T extends object>(data: T[], field: keyof T & string, maximum: boolean, temporal?: boolean): T[];
14
+ export declare function selectRank<T extends object>(data: T[], field: keyof T & string, n: number, descending: boolean): T[];
15
+ export declare function selectRange<T extends object>(data: T[], field: keyof T & string, range: [number, number], outside: boolean): T[];
16
+ export declare function selectedRows<T extends object>(data: T[], selectors: AnnotationData<T> | AnnotationData<T>[]): T[];
17
+ /** Compare neighbours within each series in business order. Missing values break sequences. */
18
+ export declare function selectLocalExtrema<T extends object>(data: T[], field: keyof T & string, maximum: boolean, series?: keyof T & string, { minProminence, minDistance }?: {
19
+ minProminence?: number;
20
+ minDistance?: number;
21
+ }): T[];
22
+ /** All renderers share the same dimming rule and reject invalid opacity before painting. */
23
+ export declare function getDimOpacity(annotations: Pick<Extract<Annotation, {
24
+ type: 'highlight';
25
+ }>, 'style'>[], fallback: number): number;
26
+ /** R-7 quantile of an ascending array; callers decide how to handle empty observations. */
27
+ export declare function quantileValue(values: number[], p: number): number;
28
+ export declare function finiteValue(value: unknown, name: string): number;
29
+ export declare function annotationField<T extends object>(mapping: G2AnnotationContext<T>['mapping'], axis?: 'x' | 'y'): keyof T & string;
30
+ /** Construct mapped coordinates; field names stay business-facing throughout composition. */
31
+ export declare function axisPosition<T extends object>(field: keyof T & string, value: unknown): Partial<T>;
32
+ /** Map a single-axis interval without imposing a business meaning on its bounds. */
33
+ export declare function axisRange<T extends object>(field: keyof T & string, bounds: unknown): { [K in keyof T]?: [T[K], T[K]] | undefined; };
34
+ export declare function formatNumber(value: number): string;
35
+ /** G2 and G6 share the native AntV scene and animation API. */
36
+ export declare function createPointPulse(scene: NonNullable<Parameters<ShapeComponent>[1]>['document'], defaults: ReturnType<typeof getAnnotationDefaults>['pulse'], redraw: () => void): {
37
+ add(parent: Pick<import("@antv/component/lib/shapes").DisplayObject<any, any>, "appendChild">, [x, y]: Point, size: number, color: string, animated?: boolean): void;
38
+ clear: () => void;
39
+ destroy(): void;
40
+ };