@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
@@ -8,15 +8,18 @@ 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 { getCartesianAxis, getChartAnimation, getPointHighlightState } from "../../util";
13
- import { getColorLegend } from "../../util/components";
14
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
13
+ import { CHART_STYLE_DEFAULTS, getCartesianAxis, getChartAnimation, getColorLegend, getPointHighlightState } from "../../util";
15
14
 
16
15
  /**
17
16
  * ScatterDataItem is the type for each data item in the scatter chart.
18
17
  */
19
18
 
19
+ /** Accept business fields without requiring caller interfaces to have an index signature. */
20
+
21
+ /** Distribute row alternatives so custom selector and weight fields remain available. */
22
+
20
23
  /**
21
24
  * ScatterConfig defines the configuration for rendering the scatter chart.
22
25
  */
@@ -57,6 +60,7 @@ export var Scatter = function Scatter(options) {
57
60
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
58
61
  var chart = null;
59
62
  var hasRendered = false;
63
+ var cleanupAnnotations;
60
64
 
61
65
  /**
62
66
  * Render the scatter chart with the given configuration.
@@ -76,6 +80,8 @@ export var Scatter = function Scatter(options) {
76
80
 
77
81
  // Clean up previous chart if exists
78
82
  if (chart) {
83
+ var _cleanupAnnotations;
84
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
79
85
  chart.destroy();
80
86
  }
81
87
 
@@ -146,8 +152,9 @@ export var Scatter = function Scatter(options) {
146
152
  scale: scaleConfig,
147
153
  axis: getCartesianAxis({
148
154
  axisXTitle: axisXTitle,
149
- axisYTitle: axisYTitle
150
- }),
155
+ axisYTitle: axisYTitle,
156
+ xType: 'number'
157
+ }, rendererTheme),
151
158
  style: _objectSpread(_objectSpread({}, pointMark), !hasGroupField ? {
152
159
  fill: colors[0]
153
160
  } : {}),
@@ -175,6 +182,19 @@ export var Scatter = function Scatter(options) {
175
182
  theme: rendererTheme
176
183
  };
177
184
  chart.options(chartOptions);
185
+ cleanupAnnotations = bindAnnotations({
186
+ renderer: 'g2',
187
+ chartType: 'scatter',
188
+ chart: chart,
189
+ annotations: config.annotations,
190
+ mapping: {
191
+ x: 'x',
192
+ y: 'y',
193
+ series: hasGroupField ? 'group' : undefined,
194
+ data: data
195
+ },
196
+ themeObject: appearance
197
+ });
178
198
  chart.render();
179
199
  hasRendered = true;
180
200
  };
@@ -183,6 +203,9 @@ export var Scatter = function Scatter(options) {
183
203
  * Destroy the chart instance and clean up resources.
184
204
  */
185
205
  var destroy = function destroy() {
206
+ var _cleanupAnnotations2;
207
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
208
+ cleanupAnnotations = undefined;
186
209
  if (chart) {
187
210
  chart.destroy();
188
211
  chart = null;
@@ -1,6 +1,7 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { VisualizationOptions } from '../../types';
2
3
  /**
3
- * SummaryConfig is a T8 Syntax string for narrative text visualization.
4
+ * T8 syntax, or an object pairing syntax with text highlight annotations.
4
5
  * Supports markdown-like syntax with special annotations for metrics.
5
6
  * @example
6
7
  * ```
@@ -8,7 +9,13 @@ import type { VisualizationOptions } from '../../types';
8
9
  * Total sales reached [¥1,234,567](metric_value, origin=1234567).
9
10
  * ```
10
11
  */
11
- export type SummaryConfig = string;
12
+ export type SummaryConfig = string | {
13
+ type?: 'summary';
14
+ text: string;
15
+ annotations?: RendererAnnotation<{
16
+ text: string;
17
+ }, 'summary', 'summary'>[];
18
+ };
12
19
  /**
13
20
  * SummaryInstance represents a summary instance with render and destroy methods.
14
21
  */
@@ -1,8 +1,10 @@
1
1
  import { Text } from '@antv/t8';
2
+ import { bindAnnotations } from "../../annotation";
3
+ import { getAnnotationDefaults } from "../../theme/annotation";
2
4
  import { getThemeObject } from "../../theme/summary";
3
5
 
4
6
  /**
5
- * SummaryConfig is a T8 Syntax string for narrative text visualization.
7
+ * T8 syntax, or an object pairing syntax with text highlight annotations.
6
8
  * Supports markdown-like syntax with special annotations for metrics.
7
9
  * @example
8
10
  * ```
@@ -50,16 +52,20 @@ export var Summary = function Summary(options) {
50
52
  wrapper.className = 'gpt-vis-summary';
51
53
  container.appendChild(wrapper);
52
54
  var text = null;
55
+ var cleanupAnnotations;
53
56
 
54
57
  /**
55
- * Render the summary with the given T8 syntax string.
58
+ * Render T8 syntax, optionally paired with highlight annotations.
56
59
  * Supports an optional `theme <value>` line in the syntax to override the theme.
57
60
  */
58
- var render = function render(syntax) {
59
- // Clean up previous instance if exists
60
- if (text) {
61
- text.unmount();
62
- }
61
+ var render = function render(config) {
62
+ var _cleanupAnnotations, _text;
63
+ var _ref = typeof config === 'string' ? {
64
+ text: config,
65
+ annotations: undefined
66
+ } : config,
67
+ syntax = _ref.text,
68
+ annotations = _ref.annotations;
63
69
 
64
70
  // Extract optional `theme <value>` line from syntax
65
71
  var activeTheme = theme;
@@ -67,9 +73,13 @@ export var Summary = function Summary(options) {
67
73
  activeTheme = t;
68
74
  return '';
69
75
  });
70
-
71
- // Create T8 Text instance
72
- text = new Text(wrapper);
76
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
77
+ cleanupAnnotations = undefined;
78
+ (_text = text) === null || _text === void 0 || _text.unmount();
79
+ var content = document.createElement('div');
80
+ wrapper.textContent = '';
81
+ wrapper.appendChild(content);
82
+ text = new Text(content);
73
83
 
74
84
  // Set background color and padding on the wrapper
75
85
  wrapper.style.backgroundColor = appearance.backgrounds[activeTheme];
@@ -78,19 +88,27 @@ export var Summary = function Summary(options) {
78
88
  // Set theme and render syntax
79
89
  text.theme(activeTheme, appearance.summary);
80
90
  text.render(cleanedSyntax.trim());
91
+ cleanupAnnotations = bindAnnotations({
92
+ renderer: 'summary',
93
+ container: wrapper,
94
+ content: content,
95
+ annotations: annotations,
96
+ defaults: getAnnotationDefaults('summary', activeTheme === theme ? options.theme : activeTheme)
97
+ });
81
98
  };
82
99
 
83
100
  /**
84
101
  * Destroy the summary instance and clean up resources.
85
102
  */
86
103
  var destroy = function destroy() {
104
+ var _cleanupAnnotations2;
105
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
106
+ cleanupAnnotations = undefined;
87
107
  if (text) {
88
108
  text.unmount();
89
109
  text = null;
90
110
  }
91
- if (wrapper.parentNode) {
92
- wrapper.parentNode.removeChild(wrapper);
93
- }
111
+ wrapper.remove();
94
112
  };
95
113
  return {
96
114
  render: render,
@@ -1,3 +1,4 @@
1
+ import type { RendererAnnotation } from '../../annotation/registry';
1
2
  import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
3
  /**
3
4
  * TableConfig defines the configuration for rendering the table.
@@ -9,6 +10,7 @@ export interface TableConfig {
9
10
  subtitle?: string;
10
11
  theme?: VisualizationTheme;
11
12
  style?: ThemeStyle;
13
+ annotations?: RendererAnnotation<Record<string, unknown>, 'table', 'table'>[];
12
14
  }
13
15
  /**
14
16
  * TableInstance represents a table instance with render and destroy methods.
@@ -1,9 +1,15 @@
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1
5
  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
6
  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
7
  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
8
  import { measureText } from 'measury';
9
+ import { bindAnnotations } from "../../annotation";
10
+ import { getAnnotationDefaults } from "../../theme/annotation";
5
11
  import { getThemeObject } from "../../theme/table";
6
- import { escapeHtml } from "../../util/html";
12
+ import { escapeHtml } from "../../util";
7
13
 
8
14
  /**
9
15
  * TableConfig defines the configuration for rendering the table.
@@ -127,11 +133,13 @@ export var Table = function Table(options) {
127
133
  throw new Error('Container not found');
128
134
  }
129
135
  var tableWrapper = null;
136
+ var cleanupAnnotations;
130
137
 
131
138
  /**
132
139
  * Render the table with the given configuration.
133
140
  */
134
141
  var render = function render(config) {
142
+ var _cleanupAnnotations, _tableWrapper, _config$annotations;
135
143
  var _config$data = config.data,
136
144
  data = _config$data === void 0 ? [] : _config$data,
137
145
  title = config.title,
@@ -145,53 +153,62 @@ export var Table = function Table(options) {
145
153
 
146
154
  // Inject styles if not already present
147
155
  injectStyles();
148
-
149
- // Clean up previous render
150
- if (tableWrapper) {
151
- tableWrapper.remove();
152
- }
156
+ (_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
157
+ cleanupAnnotations = undefined;
158
+ (_tableWrapper = tableWrapper) === null || _tableWrapper === void 0 || _tableWrapper.remove();
153
159
 
154
160
  // Create wrapper element
155
- tableWrapper = document.createElement('div');
156
- tableWrapper.className = SCOPE_ID;
161
+ var wrapper = document.createElement('div');
162
+ tableWrapper = wrapper;
163
+ container.appendChild(wrapper);
164
+ wrapper.className = SCOPE_ID;
157
165
  if (rendererTheme === 'dark') {
158
- tableWrapper.setAttribute('data-theme', 'dark');
166
+ wrapper.setAttribute('data-theme', 'dark');
159
167
  }
160
- if (style.backgroundColor) tableWrapper.style.backgroundColor = style.backgroundColor;
168
+ if (style.backgroundColor) wrapper.style.backgroundColor = style.backgroundColor;
161
169
  var titleHTML = title || subtitle ? "<div class=\"table-heading\">\n ".concat(title ? "<div class=\"table-title\">".concat(escapeHtml(title), "</div>") : '', "\n ").concat(subtitle ? "<div class=\"table-subtitle\">".concat(escapeHtml(subtitle), "</div>") : '', "\n </div>") : '';
162
170
 
163
171
  // Handle empty data case
164
172
  if (data.length === 0) {
165
- tableWrapper.innerHTML = "\n ".concat(titleHTML, "\n <div class=\"table-empty\">No data available</div>\n ");
166
- applyResolvedTableStyle(tableWrapper, style);
167
- container.appendChild(tableWrapper);
168
- return;
173
+ wrapper.innerHTML = "\n ".concat(titleHTML, "\n <div class=\"table-empty\">No data available</div>\n ");
174
+ } else {
175
+ // Get columns from the first data item
176
+ var columns = Object.keys(data[0]);
177
+ var minWidth = Math.max(calculateTableMinWidth(data, columns), columns.length * 100);
178
+ var headerHTML = columns.map(function (column) {
179
+ return "<th>".concat(escapeHtml(column), "</th>");
180
+ }).join('');
181
+ var bodyHTML = data.map(function (row) {
182
+ return "<tr>".concat(columns.map(function (column) {
183
+ return "<td>".concat(escapeHtml(row[column]), "</td>");
184
+ }).join(''), "</tr>");
185
+ }).join('');
186
+ wrapper.innerHTML = "\n ".concat(titleHTML, "\n <table style=\"min-width: ").concat(minWidth, "px;\">\n <thead><tr>").concat(headerHTML, "</tr></thead>\n <tbody>").concat(bodyHTML, "</tbody>\n </table>\n ");
187
+ }
188
+ applyResolvedTableStyle(wrapper, style);
189
+ if ((_config$annotations = config.annotations) !== null && _config$annotations !== void 0 && _config$annotations.length) {
190
+ var content = document.createElement('div');
191
+ content.style.overflow = 'auto';
192
+ content.append.apply(content, _toConsumableArray(wrapper.childNodes));
193
+ wrapper.appendChild(content);
194
+ cleanupAnnotations = bindAnnotations({
195
+ renderer: 'table',
196
+ container: wrapper,
197
+ content: content,
198
+ data: data,
199
+ annotations: config.annotations,
200
+ defaults: getAnnotationDefaults('table', theme, localStyle)
201
+ });
169
202
  }
170
-
171
- // Get columns from the first data item
172
- var columns = Object.keys(data[0]);
173
-
174
- // Calculate the minimum width needed for the table using pure function
175
- var minWidth = calculateTableMinWidth(data, columns);
176
- // Ensure a minimum width for columns
177
- minWidth = Math.max(minWidth, columns.length * 100);
178
- var headerHTML = columns.map(function (column) {
179
- return "<th>".concat(escapeHtml(column), "</th>");
180
- }).join('');
181
- var bodyHTML = data.map(function (row) {
182
- return "<tr>".concat(columns.map(function (column) {
183
- return "<td>".concat(escapeHtml(row[column]), "</td>");
184
- }).join(''), "</tr>");
185
- }).join('');
186
- tableWrapper.innerHTML = "\n ".concat(titleHTML, "\n <table style=\"min-width: ").concat(minWidth, "px;\">\n <thead><tr>").concat(headerHTML, "</tr></thead>\n <tbody>").concat(bodyHTML, "</tbody>\n </table>\n ");
187
- applyResolvedTableStyle(tableWrapper, style);
188
- container.appendChild(tableWrapper);
189
203
  };
190
204
 
191
205
  /**
192
206
  * Destroy the table instance and clean up resources.
193
207
  */
194
208
  var destroy = function destroy() {
209
+ var _cleanupAnnotations2;
210
+ (_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
211
+ cleanupAnnotations = undefined;
195
212
  if (tableWrapper) {
196
213
  tableWrapper.remove();
197
214
  tableWrapper = null;
@@ -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 { getDataLabels } from "../../util/components";
9
+ import { getDataLabels } from "../../util";
10
10
 
11
11
  /**
12
12
  * VennDataItem is the type for each data item in the venn 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, getColorLegend } from "../../util/components";
9
+ import { getCartesianAxis, getColorLegend } from "../../util";
10
10
 
11
11
  /**
12
12
  * ViolinDataItem is the type for each data item in the violin chart.
@@ -207,9 +207,17 @@ export var Violin = function Violin(options) {
207
207
  subtitle: subtitle
208
208
  } : '',
209
209
  axis: getCartesianAxis({
210
+ xType: 'category',
211
+ xValues: data.map(function (_ref) {
212
+ var category = _ref.category;
213
+ return category;
214
+ }),
215
+ container: container,
216
+ chartWidth: width,
217
+ chartHeight: height,
210
218
  axisXTitle: axisXTitle,
211
219
  axisYTitle: axisYTitle
212
- }),
220
+ }, rendererTheme),
213
221
  scale: {
214
222
  y: {
215
223
  nice: true,
@@ -12,7 +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 { getDataLabels } from "../../util/components";
15
+ import { getCartesianAxis, getDataLabels } from "../../util";
16
16
 
17
17
  /**
18
18
  * WaterfallDataItem is the type for each data item in the waterfall chart.
@@ -156,6 +156,19 @@ export var Waterfall = function Waterfall(options) {
156
156
 
157
157
  // Generate link data for connecting lines
158
158
  var linkData = generateLinkData(transformedData);
159
+ var cartesianAxis = getCartesianAxis({
160
+ xType: 'category',
161
+ xValues: data.map(function (_ref3) {
162
+ var category = _ref3.category;
163
+ return category;
164
+ }),
165
+ container: container,
166
+ chartWidth: width,
167
+ chartHeight: height,
168
+ axisXTitle: axisXTitle,
169
+ axisYTitle: axisYTitle
170
+ }, rendererTheme);
171
+ cartesianAxis.y.labelFormatter = '~s';
159
172
 
160
173
  // Create chart
161
174
  chart = new Chart({
@@ -176,16 +189,7 @@ export var Waterfall = function Waterfall(options) {
176
189
  title: title,
177
190
  subtitle: subtitle
178
191
  } : '',
179
- marginRight: 28,
180
- axis: {
181
- x: {
182
- title: axisXTitle || false
183
- },
184
- y: {
185
- title: axisYTitle || false,
186
- labelFormatter: '~s'
187
- }
188
- },
192
+ axis: cartesianAxis,
189
193
  scale: {
190
194
  y: {
191
195
  nice: true
@@ -208,8 +212,7 @@ export var Waterfall = function Waterfall(options) {
208
212
  labels: getDataLabels(rendererTheme, {
209
213
  style: {
210
214
  fontSize: 10,
211
- fontWeight: 600,
212
- stroke: '#fff'
215
+ fontWeight: 600
213
216
  },
214
217
  defaultVisible: true,
215
218
  text: '__value__',
@@ -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 { resolveChartLocale } from "../../util/components";
10
- import { getElementHoverScaleInteraction } from "../../util/interaction";
11
- import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
9
+ import { CHART_STYLE_DEFAULTS, getElementHoverScaleInteraction, resolveChartLocale } from "../../util";
12
10
  var WORD_CLOUD_MAX_WORDS = 50;
13
11
  var WORD_CLOUD_FONT_FAMILY = 'Impact';
14
12
  var WORD_CLOUD_ROTATIONS = [-90, -60, -30, 0, 30, 60];