@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
@@ -5,10 +5,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
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
7
  import { Chart } from '@antv/g2';
8
+ import { bindAnnotations } from "../../annotation";
8
9
  import { getThemeObject } from "../../theme/g2";
9
- import { getCartesianAxis, getCartesianLayout, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction } from "../../util";
10
- import { getColorLegend, getDataLabels } from "../../util/components";
11
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
10
+ import { CHART_STYLE_DEFAULTS, getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getColorLegend, getDataLabels } from "../../util";
12
11
 
13
12
  /**
14
13
  * ColumnDataItem is the type for each data item in the column chart.
@@ -55,6 +54,7 @@ export var Column = function Column(options) {
55
54
  _options$theme = options.theme,
56
55
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
57
56
  var chart = null;
57
+ var cleanupAnnotations;
58
58
 
59
59
  /**
60
60
  * Render the column chart with the given configuration.
@@ -79,17 +79,22 @@ export var Column = function Column(options) {
79
79
 
80
80
  // Clean up previous chart if exists
81
81
  if (chart) {
82
+ var _cleanupAnnotations;
83
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
82
84
  chart.destroy();
83
85
  }
84
86
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
85
87
  var cartesianAxisOptions = {
86
- axisXTitle: axisXTitle,
87
- axisYTitle: axisYTitle,
88
- xLabels: data.map(function (_ref) {
88
+ xType: 'category',
89
+ xValues: data.map(function (_ref) {
89
90
  var category = _ref.category;
90
91
  return category;
91
92
  }),
92
- chartWidth: width
93
+ axisXTitle: axisXTitle,
94
+ axisYTitle: axisYTitle,
95
+ container: container,
96
+ chartWidth: width,
97
+ chartHeight: height
93
98
  };
94
99
  var appearance = getThemeObject('column', theme, localStyle);
95
100
  var rendererTheme = appearance.theme;
@@ -156,7 +161,7 @@ export var Column = function Column(options) {
156
161
  // Configure chart options
157
162
  // Note: Using 'any' type due to G2's complex type system with transformations
158
163
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
159
- var chartOptions = _objectSpread(_objectSpread({
164
+ var chartOptions = {
160
165
  // G2 growInY currently computes interval label bounds from the animated
161
166
  // clip path, which leaves inside labels at the axis baseline. Keep the
162
167
  // interval and its labels in sync until the upstream runtime is fixed.
@@ -169,9 +174,8 @@ export var Column = function Column(options) {
169
174
  } : '',
170
175
  encode: encode,
171
176
  transform: transform,
172
- scale: scaleConfig
173
- }, getCartesianLayout(cartesianAxisOptions)), {}, {
174
- axis: getCartesianAxis(cartesianAxisOptions),
177
+ scale: scaleConfig,
178
+ axis: getCartesianAxis(cartesianAxisOptions, rendererTheme),
175
179
  legend: getColorLegend(hasGroupField),
176
180
  labels: getDataLabels(rendererTheme, {
177
181
  visible: label,
@@ -195,8 +199,22 @@ export var Column = function Column(options) {
195
199
  },
196
200
  style: intervalMark,
197
201
  theme: rendererTheme
198
- });
202
+ };
199
203
  chart.options(chartOptions);
204
+ cleanupAnnotations = bindAnnotations({
205
+ renderer: 'g2',
206
+ chartType: 'column',
207
+ chart: chart,
208
+ annotations: config.annotations,
209
+ mapping: {
210
+ x: 'category',
211
+ y: 'value',
212
+ series: hasGroupField ? 'group' : undefined,
213
+ data: data,
214
+ interval: true
215
+ },
216
+ themeObject: appearance
217
+ });
200
218
  chart.render();
201
219
  };
202
220
 
@@ -204,6 +222,9 @@ export var Column = function Column(options) {
204
222
  * Destroy the chart instance and clean up resources.
205
223
  */
206
224
  var destroy = function destroy() {
225
+ var _cleanupAnnotations2;
226
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
227
+ cleanupAnnotations = undefined;
207
228
  if (chart) {
208
229
  chart.destroy();
209
230
  chart = null;
@@ -6,9 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
7
  import { Chart } from '@antv/g2';
8
8
  import { getThemeObject } from "../../theme/g2";
9
- import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
10
- import { getColorLegend } from "../../util/components";
11
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
9
+ import { bindCrosshairAxisLabels, CHART_STYLE_DEFAULTS, getCartesianAxis, getChartAnimation, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
12
10
 
13
11
  /**
14
12
  * DualAxesSeriesItem defines a single series in the dual-axes chart.
@@ -104,13 +102,16 @@ export var DualAxes = function DualAxes(options) {
104
102
  chart.destroy();
105
103
  }
106
104
  var cartesianAxisOptions = {
105
+ xType: 'category',
106
+ xValues: categories,
107
107
  axisXTitle: axisXTitle,
108
- xLabels: categories,
109
- chartWidth: width
108
+ container: container,
109
+ chartWidth: width,
110
+ chartHeight: height
110
111
  };
111
- var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
112
112
  var appearance = getThemeObject('dual-axes', theme, localStyle);
113
113
  var rendererTheme = appearance.theme;
114
+ var cartesianAxis = getCartesianAxis(cartesianAxisOptions, rendererTheme);
114
115
  var intervalMark = _objectSpread(_objectSpread({
115
116
  fillOpacity: 0.86,
116
117
  columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
@@ -261,15 +262,14 @@ export var DualAxes = function DualAxes(options) {
261
262
  // Configure chart options
262
263
  // Note: Using 'any' type due to G2's complex type system with transformations
263
264
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
264
- var chartOptions = _objectSpread(_objectSpread({
265
+ var chartOptions = {
265
266
  type: 'view',
266
267
  data: data,
267
268
  title: title ? {
268
269
  title: title,
269
270
  subtitle: subtitle
270
271
  } : '',
271
- children: children
272
- }, getCartesianLayout(cartesianAxisOptions)), {}, {
272
+ children: children,
273
273
  axis: {
274
274
  x: xAxis
275
275
  },
@@ -306,7 +306,7 @@ export var DualAxes = function DualAxes(options) {
306
306
  })
307
307
  }, getSeriesHighlightByColorInteraction()),
308
308
  theme: rendererTheme
309
- });
309
+ };
310
310
  chart.options(chartOptions);
311
311
  var lineYFields = seriesMeta.filter(function (_ref6) {
312
312
  var item = _ref6.item;
@@ -15,7 +15,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
15
15
  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; }
16
16
  import { Graph, treeToGraphData } from '@antv/g6';
17
17
  import { getThemeObject } from "../../theme/g6";
18
- import { getGraphTitle } from "../../util/components";
18
+ import { getGraphTitle } from "../../util";
19
19
 
20
20
  /**
21
21
  * FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
23
23
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
24
  import { ExtensionCategory, Graph, HoverActivate, idOf, register } from '@antv/g6';
25
25
  import { getThemeObject } from "../../theme/g6";
26
- import { getGraphTitle } from "../../util/components";
26
+ import { getGraphTitle } from "../../util";
27
27
 
28
28
  /**
29
29
  * FlowDiagramConfig defines the configuration for rendering the flow diagram.
@@ -12,9 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
12
12
  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); }
13
13
  import { Chart } from '@antv/g2';
14
14
  import { getThemeObject } from "../../theme/g2";
15
- import { resolveChartLocale } from "../../util";
16
- import { getDataLabels } from "../../util/components";
17
- import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../../util/tokens";
15
+ import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens, getDataLabels, resolveChartLocale } from "../../util";
18
16
 
19
17
  /**
20
18
  * FunnelDataItem is the type for each data item in the funnel chart.
@@ -178,10 +176,7 @@ export var Funnel = function Funnel(options) {
178
176
  return "".concat(d.category, "\n").concat(formatValue(d.value));
179
177
  },
180
178
  position: 'inside',
181
- contrast: 'inside',
182
- transform: [{
183
- type: 'overflowStroke'
184
- }]
179
+ contrast: 'inside'
185
180
  })) !== null && _getDataLabels !== void 0 ? _getDataLabels : [];
186
181
 
187
182
  // Create chart
@@ -6,7 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
7
  import { Chart } from '@antv/g2';
8
8
  import { getThemeObject } from "../../theme/g2";
9
- import { getCartesianAxis } from "../../util/components";
9
+ import { getCartesianAxis } from "../../util";
10
10
 
11
11
  /**
12
12
  * HistogramConfig defines the configuration for rendering the histogram chart.
@@ -114,8 +114,9 @@ export var Histogram = function Histogram(options) {
114
114
  style: intervalMark,
115
115
  axis: getCartesianAxis({
116
116
  axisXTitle: axisXTitle,
117
- axisYTitle: axisYTitle
118
- }),
117
+ axisYTitle: axisYTitle,
118
+ xType: 'number'
119
+ }, rendererTheme),
119
120
  scale: {
120
121
  y: {
121
122
  nice: true
@@ -28,7 +28,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
28
28
  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; }
29
29
  import { Badge, BaseBehavior, BaseNode, CommonEvent, ExtensionCategory, Graph, NodeEvent, Polyline, iconfont, register, subStyleProps, treeToGraphData } from '@antv/g6';
30
30
  import { getThemeObject } from "../../theme/g6";
31
- import { getGraphTitle } from "../../util/components";
31
+ import { getGraphTitle } from "../../util";
32
32
 
33
33
  // ---------------------------------------------------------------------------
34
34
  // Official G6 indented-tree implementation (adapted for GPT-Vis)
@@ -1,3 +1,4 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
3
  /**
3
4
  * LineDataItem is the type for each data item in the line chart.
@@ -19,6 +20,7 @@ export interface LineConfig {
19
20
  axisYTitle?: string;
20
21
  theme?: VisualizationTheme;
21
22
  style?: ThemeStyle;
23
+ annotations?: RendererAnnotation<LineDataItem, 'g2', 'line'>[];
22
24
  }
23
25
  /**
24
26
  * LineInstance represents a line chart instance with render and destroy methods.
@@ -8,10 +8,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
9
  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); }
10
10
  import { Chart } from '@antv/g2';
11
+ import { bindAnnotations } from "../../annotation";
11
12
  import { getThemeObject } from "../../theme/g2";
12
- import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getSharedTooltipInteraction } from "../../util";
13
- import { getColorLegend } from "../../util/components";
14
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
13
+ import { bindCartesianAxisLayout, bindCrosshairAxisLabels, CHART_STYLE_DEFAULTS, createCartesianAxis, getChartAnimation, getColorLegend, getSharedTooltipInteraction } from "../../util";
15
14
 
16
15
  /**
17
16
  * LineDataItem is the type for each data item in the line chart.
@@ -60,6 +59,7 @@ export var Line = function Line(options) {
60
59
  var chart = null;
61
60
  var hasRendered = false;
62
61
  var cleanupCrosshairAxisLabels = null;
62
+ var cleanupAnnotations;
63
63
 
64
64
  /**
65
65
  * Render the line chart with the given configuration.
@@ -79,7 +79,8 @@ export var Line = function Line(options) {
79
79
 
80
80
  // Clean up previous chart if exists
81
81
  if (chart) {
82
- var _cleanupCrosshairAxis;
82
+ var _cleanupAnnotations, _cleanupCrosshairAxis;
83
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
83
84
  (_cleanupCrosshairAxis = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis === void 0 || _cleanupCrosshairAxis();
84
85
  cleanupCrosshairAxisLabels = null;
85
86
  chart.destroy();
@@ -88,14 +89,18 @@ export var Line = function Line(options) {
88
89
  var cartesianAxisOptions = {
89
90
  axisXTitle: axisXTitle,
90
91
  axisYTitle: axisYTitle,
91
- xLabels: data.map(function (_ref) {
92
+ preferHorizontal: true,
93
+ xValues: data.map(function (_ref) {
92
94
  var time = _ref.time;
93
95
  return time;
94
96
  }),
95
- chartWidth: width
97
+ container: container,
98
+ chartWidth: width,
99
+ chartHeight: height
96
100
  };
97
101
  var appearance = getThemeObject('line', theme, localStyle);
98
102
  var rendererTheme = appearance.theme;
103
+ var cartesianAxis = createCartesianAxis(cartesianAxisOptions, rendererTheme);
99
104
  var lineMark = _objectSpread({
100
105
  lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
101
106
  lineCap: 'round',
@@ -191,9 +196,9 @@ export var Line = function Line(options) {
191
196
  } : '',
192
197
  encode: encode,
193
198
  children: children,
194
- scale: scaleConfig
195
- }, getCartesianLayout(cartesianAxisOptions)), {}, {
196
- axis: getCartesianAxis(cartesianAxisOptions),
199
+ scale: scaleConfig,
200
+ axis: cartesianAxis.axis
201
+ }, cartesianAxis.layout()), {}, {
197
202
  legend: getColorLegend(hasGroupField),
198
203
  interaction: {
199
204
  tooltip: getSharedTooltipInteraction({
@@ -203,6 +208,20 @@ export var Line = function Line(options) {
203
208
  theme: rendererTheme
204
209
  });
205
210
  chart.options(chartOptions);
211
+ bindCartesianAxisLayout(chart, cartesianAxis);
212
+ cleanupAnnotations = bindAnnotations({
213
+ renderer: 'g2',
214
+ chartType: 'line',
215
+ chart: chart,
216
+ annotations: config.annotations,
217
+ mapping: {
218
+ x: 'time',
219
+ y: 'value',
220
+ series: hasGroupField ? 'group' : undefined,
221
+ data: data
222
+ },
223
+ themeObject: appearance
224
+ });
206
225
  cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, baseTheme);
207
226
  chart.render();
208
227
  hasRendered = true;
@@ -212,6 +231,9 @@ export var Line = function Line(options) {
212
231
  * Destroy the chart instance and clean up resources.
213
232
  */
214
233
  var destroy = function destroy() {
234
+ var _cleanupAnnotations2;
235
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
236
+ cleanupAnnotations = undefined;
215
237
  if (chart) {
216
238
  var _cleanupCrosshairAxis2;
217
239
  (_cleanupCrosshairAxis2 = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis2 === void 0 || _cleanupCrosshairAxis2();
@@ -6,7 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
7
  import { Chart } from '@antv/g2';
8
8
  import { getThemeObject } from "../../theme/g2";
9
- import { CHART_FONT_FAMILY } from "../../util/tokens";
9
+ import { CHART_FONT_FAMILY } from "../../util";
10
10
 
11
11
  // Default dimensions used for font size calculation when not explicitly provided
12
12
  var DEFAULT_WIDTH = 640;
@@ -16,7 +16,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
16
16
  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; }
17
17
  import { Graph, idOf, positionOf, treeToGraphData } from '@antv/g6';
18
18
  import { getThemeObject } from "../../theme/g6";
19
- import { getGraphTitle } from "../../util/components";
19
+ import { getGraphTitle } from "../../util";
20
20
 
21
21
  /**
22
22
  * MindmapConfig defines the configuration for rendering the mindmap.
@@ -1,3 +1,4 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
3
  export type NetworkGraphNode = GraphData['nodes'][number];
3
4
  export type NetworkGraphEdge = GraphData['edges'][number];
@@ -13,6 +14,7 @@ export interface NetworkGraphConfig {
13
14
  title?: string;
14
15
  subtitle?: string;
15
16
  style?: ThemeStyle;
17
+ annotations?: RendererAnnotation<NetworkGraphNode | NetworkGraphEdge, 'g6', 'network-graph'>[];
16
18
  }
17
19
  /**
18
20
  * NetworkGraphInstance represents a network graph instance with render and destroy methods.
@@ -5,8 +5,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
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
7
  import { Graph } from '@antv/g6';
8
+ import { bindAnnotations } from "../../annotation";
9
+ import { getAnnotationDefaults } from "../../theme/annotation";
8
10
  import { getThemeObject } from "../../theme/g6";
9
- import { getGraphTitle } from "../../util/components";
11
+ import { getGraphTitle } from "../../util";
10
12
 
11
13
  /**
12
14
  * NetworkGraphConfig defines the configuration for rendering the network graph.
@@ -54,6 +56,7 @@ export var NetworkGraph = function NetworkGraph(options) {
54
56
  _options$theme = options.theme,
55
57
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
56
58
  var graph = null;
59
+ var cleanupAnnotations;
57
60
 
58
61
  /**
59
62
  * Render the network graph with the given configuration.
@@ -80,6 +83,8 @@ export var NetworkGraph = function NetworkGraph(options) {
80
83
 
81
84
  // Clean up previous graph if exists
82
85
  if (graph) {
86
+ var _cleanupAnnotations;
87
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
83
88
  graph.destroy();
84
89
  graph = null;
85
90
  }
@@ -126,9 +131,17 @@ export var NetworkGraph = function NetworkGraph(options) {
126
131
  });
127
132
 
128
133
  // Build G6 edge data
129
- var edgeData = edges.map(function (edge) {
134
+ var edgeIds = edges.map(function (_, index) {
135
+ var id = "gpt-vis-edge-".concat(index);
136
+ while (nodes.some(function (node) {
137
+ return node.name === id;
138
+ })) id = "_".concat(id);
139
+ return id;
140
+ });
141
+ var edgeData = edges.map(function (edge, index) {
130
142
  var _edge$name, _edge$name2;
131
143
  return {
144
+ id: edgeIds[index],
132
145
  source: edge.source,
133
146
  target: edge.target,
134
147
  data: {
@@ -217,6 +230,17 @@ export var NetworkGraph = function NetworkGraph(options) {
217
230
  behaviors: ['drag-canvas', 'drag-element', 'click-select'],
218
231
  plugins: graphTitle.plugins
219
232
  });
233
+ cleanupAnnotations = bindAnnotations({
234
+ renderer: 'g6',
235
+ graph: graph,
236
+ annotations: config.annotations,
237
+ data: {
238
+ nodes: nodes,
239
+ edges: edges
240
+ },
241
+ edgeIds: edgeIds,
242
+ defaults: getAnnotationDefaults('network-graph', theme, localStyle)
243
+ });
220
244
  graph.render();
221
245
  };
222
246
 
@@ -224,6 +248,9 @@ export var NetworkGraph = function NetworkGraph(options) {
224
248
  * Destroy the graph instance and clean up resources.
225
249
  */
226
250
  var destroy = function destroy() {
251
+ var _cleanupAnnotations2;
252
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
253
+ cleanupAnnotations = undefined;
227
254
  if (graph) {
228
255
  graph.destroy();
229
256
  graph = null;
@@ -12,7 +12,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
12
12
  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; }
13
13
  import { Graph } from '@antv/g6';
14
14
  import { getThemeObject } from "../../theme/g6";
15
- import { getGraphTitle } from "../../util/components";
15
+ import { getGraphTitle } from "../../util";
16
16
 
17
17
  /**
18
18
  * OrganizationChartConfig defines the configuration for rendering the organization chart.
@@ -1,3 +1,4 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
3
  /**
3
4
  * PieDataItem is the type for each data item in the pie chart.
@@ -17,6 +18,7 @@ export interface PieConfig {
17
18
  title?: string;
18
19
  subtitle?: string;
19
20
  style?: ThemeStyle;
21
+ annotations?: RendererAnnotation<PieDataItem, 'g2', 'pie'>[];
20
22
  }
21
23
  /**
22
24
  * PieInstance represents a pie chart instance with render and destroy methods.
@@ -5,11 +5,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
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
7
  import { Chart } from '@antv/g2';
8
+ import { bindAnnotations } from "../../annotation";
8
9
  import { getThemeObject } from "../../theme/g2";
9
- import { getChartAnimation } from "../../util";
10
- import { getColorLegend, getDataLabels } from "../../util/components";
11
- import { getElementHoverScaleInteraction } from "../../util/interaction";
12
- import { CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../../util/tokens";
10
+ import { CHART_STYLE_DEFAULTS, getChartAnimation, getChartVisualTokens, getColorLegend, getDataLabels, getElementHoverScaleInteraction } from "../../util";
13
11
 
14
12
  /**
15
13
  * PieDataItem is the type for each data item in the pie chart.
@@ -54,6 +52,7 @@ export var Pie = function Pie(options) {
54
52
  _options$theme = options.theme,
55
53
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
56
54
  var chart = null;
55
+ var cleanupAnnotations;
57
56
  var hasRendered = false;
58
57
 
59
58
  // Precision multiplier for rounding percentages to 4 decimal places
@@ -75,6 +74,8 @@ export var Pie = function Pie(options) {
75
74
 
76
75
  // Clean up previous chart if exists
77
76
  if (chart) {
77
+ var _cleanupAnnotations;
78
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
78
79
  chart.destroy();
79
80
  }
80
81
  var sumValue = data.reduce(function (sum, item) {
@@ -132,6 +133,9 @@ export var Pie = function Pie(options) {
132
133
  var formattedPercentage = Number(percentage.toFixed(1)).toString();
133
134
  return "".concat(d.category, ": ").concat(formattedPercentage, "%");
134
135
  },
136
+ style: {
137
+ annotationNativePercentage: true
138
+ },
135
139
  position: 'outside',
136
140
  contrast: 'outside',
137
141
  transform: [{
@@ -164,21 +168,31 @@ export var Pie = function Pie(options) {
164
168
  },
165
169
  state: {
166
170
  active: {
167
- fillOpacity: 1,
168
- lineWidth: 3
171
+ fillOpacity: 1
169
172
  },
170
173
  inactive: {
171
174
  fillOpacity: 0.3
172
175
  },
173
176
  selected: {
174
- fillOpacity: 1,
175
- lineWidth: 3
177
+ fillOpacity: 1
176
178
  }
177
179
  },
178
180
  style: intervalMark,
179
181
  theme: rendererTheme
180
182
  };
181
183
  chart.options(chartOptions);
184
+ cleanupAnnotations = bindAnnotations({
185
+ renderer: 'g2',
186
+ chartType: 'pie',
187
+ chart: chart,
188
+ annotations: config.annotations,
189
+ mapping: {
190
+ x: 'category',
191
+ y: 'value',
192
+ data: data
193
+ },
194
+ themeObject: appearance
195
+ });
182
196
  chart.render();
183
197
  hasRendered = true;
184
198
  };
@@ -187,6 +201,9 @@ export var Pie = function Pie(options) {
187
201
  * Destroy the chart instance and clean up resources.
188
202
  */
189
203
  var destroy = function destroy() {
204
+ var _cleanupAnnotations2;
205
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
206
+ cleanupAnnotations = undefined;
190
207
  if (chart) {
191
208
  chart.destroy();
192
209
  chart = null;
@@ -16,9 +16,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  import { Chart } from '@antv/g2';
18
18
  import { getThemeObject } from "../../theme/g2";
19
- import { getLineHighlightState, getSeriesHighlightByColorInteraction } from "../../util";
20
- import { getColorLegend } from "../../util/components";
21
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
19
+ import { CHART_STYLE_DEFAULTS, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction } from "../../util";
22
20
 
23
21
  /**
24
22
  * RadarDataItem is the type for each data item in the radar chart.
@@ -56,6 +56,7 @@ export var Sankey = function Sankey(options) {
56
56
  * Render the sankey chart with the given configuration.
57
57
  */
58
58
  var render = function render(config) {
59
+ var _sankeyStyle$nodeFill, _sankeyStyle$linkFill;
59
60
  var _config$data = config.data,
60
61
  data = _config$data === void 0 ? [] : _config$data,
61
62
  _config$nodeAlign = config.nodeAlign,
@@ -119,8 +120,21 @@ export var Sankey = function Sankey(options) {
119
120
  style: _objectSpread({
120
121
  labelSpacing: 2,
121
122
  nodeLineWidth: 1,
122
- linkFillOpacity: 0.3
123
+ nodeFillOpacity: 0.5,
124
+ linkFillOpacity: 0.5
123
125
  }, sankeyStyle),
126
+ state: {
127
+ active: {
128
+ fillOpacity: 1
129
+ },
130
+ inactive: {
131
+ nodeFillOpacity: (_sankeyStyle$nodeFill = sankeyStyle.nodeFillOpacity) !== null && _sankeyStyle$nodeFill !== void 0 ? _sankeyStyle$nodeFill : 0.5,
132
+ linkFillOpacity: (_sankeyStyle$linkFill = sankeyStyle.linkFillOpacity) !== null && _sankeyStyle$linkFill !== void 0 ? _sankeyStyle$linkFill : 0.5
133
+ }
134
+ },
135
+ interaction: {
136
+ elementHighlight: true
137
+ },
124
138
  theme: rendererTheme,
125
139
  legend: false,
126
140
  tooltip: false
@@ -1,3 +1,4 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
3
  /**
3
4
  * ScatterDataItem is the type for each data item in the scatter chart.
@@ -7,24 +8,29 @@ export type ScatterDataItem = {
7
8
  y: number;
8
9
  group?: string;
9
10
  };
11
+ /** Accept business fields without requiring caller interfaces to have an index signature. */
12
+ type ScatterRow = ScatterDataItem | (ScatterDataItem & Record<string, unknown>);
13
+ /** Distribute row alternatives so custom selector and weight fields remain available. */
14
+ type ScatterAnnotation<T extends ScatterDataItem> = T extends ScatterDataItem ? RendererAnnotation<T, 'g2', 'scatter'> : never;
10
15
  /**
11
16
  * ScatterConfig defines the configuration for rendering the scatter chart.
12
17
  */
13
- export interface ScatterConfig {
18
+ export interface ScatterConfig<T extends ScatterDataItem = ScatterRow> {
14
19
  type?: 'scatter';
15
- data: ScatterDataItem[];
20
+ data: T[];
16
21
  title?: string;
17
22
  subtitle?: string;
18
23
  axisXTitle?: string;
19
24
  axisYTitle?: string;
20
25
  theme?: VisualizationTheme;
21
26
  style?: ThemeStyle;
27
+ annotations?: ScatterAnnotation<T>[];
22
28
  }
23
29
  /**
24
30
  * ScatterInstance represents a scatter chart instance with render and destroy methods.
25
31
  */
26
32
  export interface ScatterInstance {
27
- render: (config: ScatterConfig) => void;
33
+ render: <T extends ScatterDataItem>(config: ScatterConfig<T>) => void;
28
34
  destroy: () => void;
29
35
  }
30
36
  /**
@@ -52,3 +58,4 @@ export interface ScatterInstance {
52
58
  * ```
53
59
  */
54
60
  export declare const Scatter: (options: VisualizationOptions) => ScatterInstance;
61
+ export {};