@antv/gpt-vis 1.3.1 → 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 (286) 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/cjs/vis-wrapper/index.js +2 -1
  144. package/dist/esm/annotation/components/bottom-n.d.ts +2 -0
  145. package/dist/esm/annotation/components/bottom-n.js +42 -0
  146. package/dist/esm/annotation/components/centroid.d.ts +2 -0
  147. package/dist/esm/annotation/components/centroid.js +73 -0
  148. package/dist/esm/annotation/components/connector.d.ts +25 -0
  149. package/dist/esm/annotation/components/connector.js +332 -0
  150. package/dist/esm/annotation/components/contribution.d.ts +3 -0
  151. package/dist/esm/annotation/components/contribution.js +174 -0
  152. package/dist/esm/annotation/components/crossing.d.ts +3 -0
  153. package/dist/esm/annotation/components/crossing.js +665 -0
  154. package/dist/esm/annotation/components/event.d.ts +2 -0
  155. package/dist/esm/annotation/components/event.js +46 -0
  156. package/dist/esm/annotation/components/first.d.ts +2 -0
  157. package/dist/esm/annotation/components/first.js +18 -0
  158. package/dist/esm/annotation/components/group.d.ts +3 -0
  159. package/dist/esm/annotation/components/group.js +64 -0
  160. package/dist/esm/annotation/components/highlight.d.ts +14 -0
  161. package/dist/esm/annotation/components/highlight.js +838 -0
  162. package/dist/esm/annotation/components/index.d.ts +34 -0
  163. package/dist/esm/annotation/components/index.js +34 -0
  164. package/dist/esm/annotation/components/last.d.ts +2 -0
  165. package/dist/esm/annotation/components/last.js +18 -0
  166. package/dist/esm/annotation/components/max-x.d.ts +2 -0
  167. package/dist/esm/annotation/components/max-x.js +17 -0
  168. package/dist/esm/annotation/components/max-y.d.ts +2 -0
  169. package/dist/esm/annotation/components/max-y.js +17 -0
  170. package/dist/esm/annotation/components/mean.d.ts +2 -0
  171. package/dist/esm/annotation/components/mean.js +40 -0
  172. package/dist/esm/annotation/components/median.d.ts +2 -0
  173. package/dist/esm/annotation/components/median.js +32 -0
  174. package/dist/esm/annotation/components/min-x.d.ts +2 -0
  175. package/dist/esm/annotation/components/min-x.js +17 -0
  176. package/dist/esm/annotation/components/min-y.d.ts +2 -0
  177. package/dist/esm/annotation/components/min-y.js +17 -0
  178. package/dist/esm/annotation/components/outlier.d.ts +3 -0
  179. package/dist/esm/annotation/components/outlier.js +98 -0
  180. package/dist/esm/annotation/components/path.d.ts +20 -0
  181. package/dist/esm/annotation/components/path.js +165 -0
  182. package/dist/esm/annotation/components/peak.d.ts +2 -0
  183. package/dist/esm/annotation/components/peak.js +20 -0
  184. package/dist/esm/annotation/components/point.d.ts +26 -0
  185. package/dist/esm/annotation/components/point.js +277 -0
  186. package/dist/esm/annotation/components/quadrant.d.ts +3 -0
  187. package/dist/esm/annotation/components/quadrant.js +83 -0
  188. package/dist/esm/annotation/components/quantile.d.ts +2 -0
  189. package/dist/esm/annotation/components/quantile.js +32 -0
  190. package/dist/esm/annotation/components/range-inside.d.ts +2 -0
  191. package/dist/esm/annotation/components/range-inside.js +55 -0
  192. package/dist/esm/annotation/components/range-outside.d.ts +2 -0
  193. package/dist/esm/annotation/components/range-outside.js +55 -0
  194. package/dist/esm/annotation/components/range-x.d.ts +2 -0
  195. package/dist/esm/annotation/components/range-x.js +15 -0
  196. package/dist/esm/annotation/components/range-y.d.ts +2 -0
  197. package/dist/esm/annotation/components/range-y.js +15 -0
  198. package/dist/esm/annotation/components/range.d.ts +15 -0
  199. package/dist/esm/annotation/components/range.js +92 -0
  200. package/dist/esm/annotation/components/target.d.ts +2 -0
  201. package/dist/esm/annotation/components/target.js +44 -0
  202. package/dist/esm/annotation/components/text.d.ts +15 -0
  203. package/dist/esm/annotation/components/text.js +78 -0
  204. package/dist/esm/annotation/components/threshold-highlight.d.ts +3 -0
  205. package/dist/esm/annotation/components/threshold-highlight.js +297 -0
  206. package/dist/esm/annotation/components/threshold-x.d.ts +2 -0
  207. package/dist/esm/annotation/components/threshold-x.js +23 -0
  208. package/dist/esm/annotation/components/threshold-y.d.ts +2 -0
  209. package/dist/esm/annotation/components/threshold-y.js +24 -0
  210. package/dist/esm/annotation/components/top-n.d.ts +2 -0
  211. package/dist/esm/annotation/components/top-n.js +42 -0
  212. package/dist/esm/annotation/components/valley.d.ts +2 -0
  213. package/dist/esm/annotation/components/valley.js +20 -0
  214. package/dist/esm/annotation/index.d.ts +1 -0
  215. package/dist/esm/annotation/index.js +1 -0
  216. package/dist/esm/annotation/label.d.ts +38 -0
  217. package/dist/esm/annotation/label.js +449 -0
  218. package/dist/esm/annotation/layout.d.ts +12 -0
  219. package/dist/esm/annotation/layout.js +182 -0
  220. package/dist/esm/annotation/merge.d.ts +19 -0
  221. package/dist/esm/annotation/merge.js +67 -0
  222. package/dist/esm/annotation/registry.d.ts +190 -0
  223. package/dist/esm/annotation/registry.js +220 -0
  224. package/dist/esm/annotation/runtime/g2.d.ts +90 -0
  225. package/dist/esm/annotation/runtime/g2.js +754 -0
  226. package/dist/esm/annotation/runtime/g6.d.ts +40 -0
  227. package/dist/esm/annotation/runtime/g6.js +447 -0
  228. package/dist/esm/annotation/runtime/index.d.ts +11 -0
  229. package/dist/esm/annotation/runtime/index.js +26 -0
  230. package/dist/esm/annotation/runtime/summary.d.ts +17 -0
  231. package/dist/esm/annotation/runtime/summary.js +21 -0
  232. package/dist/esm/annotation/runtime/table.d.ts +16 -0
  233. package/dist/esm/annotation/runtime/table.js +21 -0
  234. package/dist/esm/annotation/utils.d.ts +40 -0
  235. package/dist/esm/annotation/utils.js +370 -0
  236. package/dist/esm/theme/annotation.d.ts +236 -0
  237. package/dist/esm/theme/annotation.js +186 -0
  238. package/dist/esm/theme/g2.js +2 -10
  239. package/dist/esm/theme/g6.js +1 -1
  240. package/dist/esm/theme/summary.js +1 -1
  241. package/dist/esm/types/annotation.d.ts +310 -0
  242. package/dist/esm/types/annotation.js +1 -0
  243. package/dist/esm/types/index.d.ts +1 -0
  244. package/dist/esm/util/axis.d.ts +28 -0
  245. package/dist/esm/util/axis.js +222 -0
  246. package/dist/esm/util/components.d.ts +0 -10
  247. package/dist/esm/util/components.js +24 -69
  248. package/dist/esm/util/index.d.ts +7 -4
  249. package/dist/esm/util/index.js +7 -4
  250. package/dist/esm/vis/area/index.d.ts +2 -0
  251. package/dist/esm/vis/area/index.js +32 -9
  252. package/dist/esm/vis/bar/index.d.ts +2 -0
  253. package/dist/esm/vis/bar/index.js +37 -6
  254. package/dist/esm/vis/boxplot/index.js +10 -2
  255. package/dist/esm/vis/column/index.d.ts +2 -0
  256. package/dist/esm/vis/column/index.js +33 -12
  257. package/dist/esm/vis/dual-axes/index.js +10 -10
  258. package/dist/esm/vis/fishbone-diagram/index.js +1 -1
  259. package/dist/esm/vis/flow-diagram/index.js +1 -1
  260. package/dist/esm/vis/funnel/index.js +2 -7
  261. package/dist/esm/vis/histogram/index.js +4 -3
  262. package/dist/esm/vis/indented-tree/index.js +1 -1
  263. package/dist/esm/vis/line/index.d.ts +2 -0
  264. package/dist/esm/vis/line/index.js +31 -9
  265. package/dist/esm/vis/liquid/index.js +1 -1
  266. package/dist/esm/vis/mindmap/index.js +1 -1
  267. package/dist/esm/vis/network-graph/index.d.ts +2 -0
  268. package/dist/esm/vis/network-graph/index.js +29 -2
  269. package/dist/esm/vis/organization-chart/index.js +1 -1
  270. package/dist/esm/vis/pie/index.d.ts +2 -0
  271. package/dist/esm/vis/pie/index.js +25 -8
  272. package/dist/esm/vis/radar/index.js +1 -3
  273. package/dist/esm/vis/sankey/index.js +15 -1
  274. package/dist/esm/vis/scatter/index.d.ts +10 -3
  275. package/dist/esm/vis/scatter/index.js +28 -5
  276. package/dist/esm/vis/summary/index.d.ts +9 -2
  277. package/dist/esm/vis/summary/index.js +31 -13
  278. package/dist/esm/vis/table/index.d.ts +2 -0
  279. package/dist/esm/vis/table/index.js +50 -33
  280. package/dist/esm/vis/venn/index.js +1 -1
  281. package/dist/esm/vis/violin/index.js +10 -2
  282. package/dist/esm/vis/waterfall/index.js +16 -13
  283. package/dist/esm/vis/word-cloud/index.js +1 -3
  284. package/dist/esm/vis-wrapper/index.js +2 -1
  285. package/dist/umd/index.min.js +1 -1
  286. package/package.json +2 -2
@@ -0,0 +1,46 @@
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
+ import { annotationField, axisPosition, finiteValue, selectRows } from "../utils";
8
+ import { path } from "./path";
9
+ export var event = {
10
+ g2: function g2(annotations, _ref) {
11
+ var mapping = _ref.mapping;
12
+ return annotations.flatMap(function (annotation) {
13
+ var _annotation$axis;
14
+ var field = annotationField(mapping, (_annotation$axis = annotation.axis) !== null && _annotation$axis !== void 0 ? _annotation$axis : 'x');
15
+ var targets = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
16
+ if (!targets.length) throw new Error('Invalid annotation: event needs target data.');
17
+ return targets.flatMap(function (selector) {
18
+ var _annotation$label;
19
+ var anchor = (selector === null || selector === void 0 ? void 0 : selector[field]) !== undefined && Object.keys(selector).every(function (key) {
20
+ return key === field;
21
+ }) ? selector : resolveAnchor(selector, mapping);
22
+ var value = anchor[field];
23
+ return path.create({
24
+ data: axisPosition(field, value),
25
+ label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Event: ".concat(value),
26
+ style: _objectSpread({
27
+ lineDash: [4, 4]
28
+ }, annotation.style)
29
+ });
30
+ });
31
+ });
32
+ }
33
+ };
34
+ function resolveAnchor(selector, mapping) {
35
+ if (!selector || _typeof(selector) !== 'object' || Array.isArray(selector)) throw new Error('Invalid annotation: anchor needs an original-field selector or coordinates.');
36
+ if (selector[mapping.x] !== undefined && selector[mapping.y] !== undefined && Object.keys(selector).every(function (key) {
37
+ return key === mapping.x || key === mapping.y;
38
+ })) {
39
+ axisPosition(mapping.x, selector[mapping.x]);
40
+ finiteValue(selector[mapping.y], mapping.y);
41
+ return selector;
42
+ }
43
+ var rows = selectRows(mapping.data, selector);
44
+ if (rows.length !== 1) throw new Error("Invalid annotation: anchor matches ".concat(rows.length, " observations; expected one."));
45
+ return rows[0];
46
+ }
@@ -0,0 +1,2 @@
1
+ import type { AnnotationComponent } from '../registry';
2
+ export declare const first: AnnotationComponent<'first', 'g2'>;
@@ -0,0 +1,18 @@
1
+ import { selectRows } from "../utils";
2
+ import { highlight } from "./highlight";
3
+ export var first = {
4
+ g2: function g2(annotations, _ref) {
5
+ var mapping = _ref.mapping;
6
+ return annotations.flatMap(function (annotation) {
7
+ var rows = selectRows(mapping.data, annotation.data);
8
+ return rows.slice(0, 1).flatMap(function (row) {
9
+ var _annotation$label;
10
+ return highlight.create({
11
+ data: [row],
12
+ label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "First: ".concat(row[mapping.y]),
13
+ style: annotation.style
14
+ });
15
+ });
16
+ });
17
+ }
18
+ };
@@ -0,0 +1,3 @@
1
+ import type { AnnotationComponent } from '../registry';
2
+ /** Emphasize selected series with their native colors; no clustering is inferred. */
3
+ export declare const group: AnnotationComponent<'group', 'g2'>;
@@ -0,0 +1,64 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _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; }
7
+ import { groupLabels } from "../label";
8
+ import { highlight } from "./highlight";
9
+
10
+ /** Emphasize selected series with their native colors; no clustering is inferred. */
11
+ export var group = {
12
+ g2: function g2(annotations, _ref) {
13
+ var mapping = _ref.mapping,
14
+ chartType = _ref.chartType,
15
+ sourceMarks = _ref.sourceMarks;
16
+ return annotations.flatMap(function (annotation) {
17
+ switch (chartType) {
18
+ case 'column':
19
+ case 'bar':
20
+ if (!(sourceMarks !== null && sourceMarks !== void 0 && sourceMarks.some(function (mark) {
21
+ var _mark$transform;
22
+ return (_mark$transform = mark.transform) === null || _mark$transform === void 0 ? void 0 : _mark$transform.some(function (transform) {
23
+ return transform.type === 'dodgeX' || transform.type === 'stackY';
24
+ });
25
+ }))) throw new Error('Invalid annotation: group requires grouped or stacked bars.');
26
+ break;
27
+ }
28
+ var field = mapping.series;
29
+ if (!field) throw new Error('Invalid annotation: group requires a series mapping.');
30
+ var targets = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
31
+ if (!targets.length || targets.some(function (target) {
32
+ return !target || Object.keys(target).length !== 1 || Object.keys(target)[0] !== 'group' || typeof target.group !== 'string';
33
+ })) throw new Error('Invalid annotation: group selects complete series with data.group.');
34
+ var names = new Set(targets.map(function (target) {
35
+ return target.group;
36
+ }));
37
+ var available = new Set(mapping.data.map(function (row) {
38
+ return row[field];
39
+ }));
40
+ if (mapping.data.length && targets.some(function (target) {
41
+ return !available.has(target.group);
42
+ })) throw new Error('Invalid annotation: group matches no series.');
43
+ var highlights = annotation.label === undefined ? _toConsumableArray(names).flatMap(function (name) {
44
+ return highlight.create({
45
+ data: mapping.data.filter(function (row) {
46
+ return row[field] === name;
47
+ }),
48
+ label: String(name),
49
+ style: annotation.style
50
+ });
51
+ }) : highlight.create({
52
+ data: mapping.data.filter(function (row) {
53
+ return names.has(row[field]);
54
+ }),
55
+ label: annotation.label,
56
+ style: annotation.style
57
+ });
58
+ highlights.forEach(function (highlight) {
59
+ return groupLabels.add(highlight);
60
+ });
61
+ return highlights;
62
+ });
63
+ }
64
+ };
@@ -0,0 +1,14 @@
1
+ import type { Annotation } from '../../types/annotation';
2
+ import type { AnnotationComponent } from '../registry';
3
+ /** Highlight batches share selection and dimming so overlapping targets form a union. */
4
+ export declare const highlight: AnnotationComponent<'highlight'> & {
5
+ create: typeof createHighlight;
6
+ };
7
+ type HighlightConfig<T extends object> = Omit<Extract<Annotation, {
8
+ type: 'highlight';
9
+ }>, 'data'> & {
10
+ data: T | T[];
11
+ };
12
+ /** Create configurations for later merging and drawing; empty selections are a no-op. */
13
+ declare function createHighlight<T extends object>(options: Omit<HighlightConfig<T>, 'type'>, computed?: boolean): HighlightConfig<T>[];
14
+ export {};