@antv/gpt-vis 1.0.2 → 1.3.1

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 (172) hide show
  1. package/README.md +53 -7
  2. package/README.zh-CN.md +32 -9
  3. package/dist/cjs/index.d.ts +1 -1
  4. package/dist/cjs/theme/g2.d.ts +9 -0
  5. package/dist/cjs/theme/g2.js +605 -0
  6. package/dist/cjs/theme/g6.d.ts +28 -0
  7. package/dist/cjs/theme/g6.js +124 -0
  8. package/dist/cjs/theme/merge.d.ts +2 -0
  9. package/dist/cjs/theme/merge.js +49 -0
  10. package/dist/cjs/theme/presets.d.ts +5 -0
  11. package/dist/cjs/theme/presets.js +663 -0
  12. package/dist/cjs/theme/resolve.d.ts +7 -0
  13. package/dist/cjs/theme/resolve.js +59 -0
  14. package/dist/cjs/theme/shared.d.ts +7 -0
  15. package/dist/cjs/theme/shared.js +61 -0
  16. package/dist/cjs/theme/summary.d.ts +11 -0
  17. package/dist/cjs/theme/summary.js +61 -0
  18. package/dist/cjs/theme/table.d.ts +13 -0
  19. package/dist/cjs/theme/table.js +121 -0
  20. package/dist/cjs/types/index.d.ts +8 -5
  21. package/dist/cjs/types/theme.d.ts +109 -0
  22. package/dist/cjs/types/theme.js +17 -0
  23. package/dist/cjs/util/animation.js +6 -1
  24. package/dist/cjs/util/components.d.ts +20 -0
  25. package/dist/cjs/util/components.js +40 -0
  26. package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
  27. package/dist/cjs/util/crosshair-axis-labels.js +17 -0
  28. package/dist/cjs/util/index.d.ts +0 -2
  29. package/dist/cjs/util/index.js +1 -5
  30. package/dist/cjs/util/interaction.d.ts +4 -3
  31. package/dist/cjs/util/interaction.js +14 -1
  32. package/dist/cjs/util/tokens.d.ts +4 -3
  33. package/dist/cjs/util/tokens.js +9 -6
  34. package/dist/cjs/vis/area/index.d.ts +3 -6
  35. package/dist/cjs/vis/area/index.js +43 -30
  36. package/dist/cjs/vis/bar/index.d.ts +5 -5
  37. package/dist/cjs/vis/bar/index.js +34 -20
  38. package/dist/cjs/vis/boxplot/index.d.ts +4 -5
  39. package/dist/cjs/vis/boxplot/index.js +36 -23
  40. package/dist/cjs/vis/column/index.d.ts +5 -5
  41. package/dist/cjs/vis/column/index.js +38 -26
  42. package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
  43. package/dist/cjs/vis/dual-axes/index.js +70 -52
  44. package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
  45. package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
  46. package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
  47. package/dist/cjs/vis/flow-diagram/index.js +21 -22
  48. package/dist/cjs/vis/funnel/index.d.ts +3 -5
  49. package/dist/cjs/vis/funnel/index.js +63 -42
  50. package/dist/cjs/vis/histogram/index.d.ts +4 -6
  51. package/dist/cjs/vis/histogram/index.js +17 -19
  52. package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
  53. package/dist/cjs/vis/indented-tree/index.js +58 -34
  54. package/dist/cjs/vis/line/index.d.ts +3 -6
  55. package/dist/cjs/vis/line/index.js +43 -22
  56. package/dist/cjs/vis/liquid/index.d.ts +4 -6
  57. package/dist/cjs/vis/liquid/index.js +22 -17
  58. package/dist/cjs/vis/mindmap/index.d.ts +4 -6
  59. package/dist/cjs/vis/mindmap/index.js +43 -25
  60. package/dist/cjs/vis/network-graph/index.d.ts +4 -6
  61. package/dist/cjs/vis/network-graph/index.js +26 -20
  62. package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
  63. package/dist/cjs/vis/organization-chart/index.js +39 -33
  64. package/dist/cjs/vis/pie/index.d.ts +3 -5
  65. package/dist/cjs/vis/pie/index.js +45 -26
  66. package/dist/cjs/vis/radar/index.d.ts +3 -6
  67. package/dist/cjs/vis/radar/index.js +32 -24
  68. package/dist/cjs/vis/sankey/index.d.ts +4 -6
  69. package/dist/cjs/vis/sankey/index.js +17 -7
  70. package/dist/cjs/vis/scatter/index.d.ts +3 -5
  71. package/dist/cjs/vis/scatter/index.js +32 -19
  72. package/dist/cjs/vis/summary/index.js +5 -6
  73. package/dist/cjs/vis/table/index.d.ts +4 -2
  74. package/dist/cjs/vis/table/index.js +46 -4
  75. package/dist/cjs/vis/treemap/index.d.ts +4 -6
  76. package/dist/cjs/vis/treemap/index.js +11 -7
  77. package/dist/cjs/vis/venn/index.d.ts +4 -6
  78. package/dist/cjs/vis/venn/index.js +18 -16
  79. package/dist/cjs/vis/violin/index.d.ts +4 -5
  80. package/dist/cjs/vis/violin/index.js +35 -27
  81. package/dist/cjs/vis/waterfall/index.d.ts +4 -4
  82. package/dist/cjs/vis/waterfall/index.js +48 -39
  83. package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
  84. package/dist/cjs/vis/word-cloud/index.js +18 -12
  85. package/dist/esm/index.d.ts +1 -1
  86. package/dist/esm/theme/g2.d.ts +9 -0
  87. package/dist/esm/theme/g2.js +504 -0
  88. package/dist/esm/theme/g6.d.ts +28 -0
  89. package/dist/esm/theme/g6.js +84 -0
  90. package/dist/esm/theme/merge.d.ts +2 -0
  91. package/dist/esm/theme/merge.js +36 -0
  92. package/dist/esm/theme/presets.d.ts +5 -0
  93. package/dist/esm/theme/presets.js +1070 -0
  94. package/dist/esm/theme/resolve.d.ts +7 -0
  95. package/dist/esm/theme/resolve.js +31 -0
  96. package/dist/esm/theme/shared.d.ts +7 -0
  97. package/dist/esm/theme/shared.js +21 -0
  98. package/dist/esm/theme/summary.d.ts +11 -0
  99. package/dist/esm/theme/summary.js +45 -0
  100. package/dist/esm/theme/table.d.ts +13 -0
  101. package/dist/esm/theme/table.js +112 -0
  102. package/dist/esm/types/index.d.ts +8 -5
  103. package/dist/esm/types/theme.d.ts +109 -0
  104. package/dist/esm/types/theme.js +1 -0
  105. package/dist/esm/util/animation.js +12 -2
  106. package/dist/esm/util/components.d.ts +20 -0
  107. package/dist/esm/util/components.js +57 -1
  108. package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
  109. package/dist/esm/util/crosshair-axis-labels.js +18 -0
  110. package/dist/esm/util/index.d.ts +0 -2
  111. package/dist/esm/util/index.js +1 -3
  112. package/dist/esm/util/interaction.d.ts +4 -3
  113. package/dist/esm/util/interaction.js +18 -1
  114. package/dist/esm/util/tokens.d.ts +4 -3
  115. package/dist/esm/util/tokens.js +9 -6
  116. package/dist/esm/vis/area/index.d.ts +3 -6
  117. package/dist/esm/vis/area/index.js +53 -45
  118. package/dist/esm/vis/bar/index.d.ts +5 -5
  119. package/dist/esm/vis/bar/index.js +38 -27
  120. package/dist/esm/vis/boxplot/index.d.ts +4 -5
  121. package/dist/esm/vis/boxplot/index.js +47 -29
  122. package/dist/esm/vis/column/index.d.ts +5 -5
  123. package/dist/esm/vis/column/index.js +46 -36
  124. package/dist/esm/vis/dual-axes/index.d.ts +3 -4
  125. package/dist/esm/vis/dual-axes/index.js +68 -58
  126. package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
  127. package/dist/esm/vis/fishbone-diagram/index.js +52 -27
  128. package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
  129. package/dist/esm/vis/flow-diagram/index.js +28 -23
  130. package/dist/esm/vis/funnel/index.d.ts +3 -5
  131. package/dist/esm/vis/funnel/index.js +63 -54
  132. package/dist/esm/vis/histogram/index.d.ts +4 -6
  133. package/dist/esm/vis/histogram/index.js +28 -21
  134. package/dist/esm/vis/indented-tree/index.d.ts +4 -6
  135. package/dist/esm/vis/indented-tree/index.js +59 -52
  136. package/dist/esm/vis/line/index.d.ts +3 -6
  137. package/dist/esm/vis/line/index.js +44 -32
  138. package/dist/esm/vis/liquid/index.d.ts +4 -6
  139. package/dist/esm/vis/liquid/index.js +28 -21
  140. package/dist/esm/vis/mindmap/index.d.ts +4 -6
  141. package/dist/esm/vis/mindmap/index.js +32 -28
  142. package/dist/esm/vis/network-graph/index.d.ts +4 -6
  143. package/dist/esm/vis/network-graph/index.js +37 -22
  144. package/dist/esm/vis/organization-chart/index.d.ts +4 -6
  145. package/dist/esm/vis/organization-chart/index.js +47 -36
  146. package/dist/esm/vis/pie/index.d.ts +3 -5
  147. package/dist/esm/vis/pie/index.js +42 -26
  148. package/dist/esm/vis/radar/index.d.ts +3 -6
  149. package/dist/esm/vis/radar/index.js +28 -20
  150. package/dist/esm/vis/sankey/index.d.ts +4 -6
  151. package/dist/esm/vis/sankey/index.js +20 -10
  152. package/dist/esm/vis/scatter/index.d.ts +3 -5
  153. package/dist/esm/vis/scatter/index.js +32 -21
  154. package/dist/esm/vis/summary/index.js +5 -7
  155. package/dist/esm/vis/table/index.d.ts +4 -2
  156. package/dist/esm/vis/table/index.js +41 -4
  157. package/dist/esm/vis/treemap/index.d.ts +4 -6
  158. package/dist/esm/vis/treemap/index.js +16 -11
  159. package/dist/esm/vis/venn/index.d.ts +4 -6
  160. package/dist/esm/vis/venn/index.js +24 -16
  161. package/dist/esm/vis/violin/index.d.ts +4 -5
  162. package/dist/esm/vis/violin/index.js +45 -37
  163. package/dist/esm/vis/waterfall/index.d.ts +4 -4
  164. package/dist/esm/vis/waterfall/index.js +46 -36
  165. package/dist/esm/vis/word-cloud/index.d.ts +3 -5
  166. package/dist/esm/vis/word-cloud/index.js +24 -17
  167. package/dist/umd/index.min.js +1 -1
  168. package/package.json +1 -1
  169. package/dist/cjs/util/theme.d.ts +0 -20
  170. package/dist/cjs/util/theme.js +0 -372
  171. package/dist/esm/util/theme.d.ts +0 -20
  172. package/dist/esm/util/theme.js +0 -326
@@ -1,4 +1,7 @@
1
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; }
2
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; } } }; }
3
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
7
  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."); }
@@ -19,7 +22,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
19
22
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
23
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
24
  import { ExtensionCategory, Graph, HoverActivate, idOf, register } from '@antv/g6';
22
- import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
25
+ import { getThemeObject } from "../../theme/g6";
26
+ import { getGraphTitle } from "../../util/components";
23
27
 
24
28
  /**
25
29
  * FlowDiagramConfig defines the configuration for rendering the flow diagram.
@@ -119,17 +123,23 @@ export var FlowDiagram = function FlowDiagram(options) {
119
123
  var render = function render(config) {
120
124
  var data = config.data,
121
125
  title = config.title,
126
+ subtitle = config.subtitle,
122
127
  _config$theme = config.theme,
123
128
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
124
129
  _config$style = config.style,
125
- style = _config$style === void 0 ? {} : _config$style;
130
+ localStyle = _config$style === void 0 ? {} : _config$style;
126
131
  if (graph) {
127
132
  graph.destroy();
128
133
  graph = null;
129
134
  }
130
135
  ensureBehaviorRegistered();
131
- var colors = normalizePalette(style.palette, theme);
132
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
136
+ var appearance = getThemeObject('flow-diagram', theme, localStyle);
137
+ var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
138
+ var rendererTheme = appearance.theme;
139
+ var baseTheme = appearance.baseTheme;
140
+ var colors = appearance.colors;
141
+ var backgroundColor = appearance.backgroundColor;
142
+ var edgeTheme = appearance.edge.style;
133
143
 
134
144
  // Resolve container element
135
145
  var containerEl;
@@ -227,7 +237,7 @@ export var FlowDiagram = function FlowDiagram(options) {
227
237
  }
228
238
  };
229
239
  });
230
- var isDark = theme === 'dark';
240
+ var isDark = baseTheme === 'dark';
231
241
  var edgeStroke = isDark ? '#5a6b7f' : '#8b9baf';
232
242
  var labelFill = isDark ? '#aab4c0' : '#8b9baf';
233
243
  var labelBgFill = isDark ? '#1a1a2e' : '#f8f8f8';
@@ -238,21 +248,15 @@ export var FlowDiagram = function FlowDiagram(options) {
238
248
  container: containerEl,
239
249
  width: width,
240
250
  height: height,
241
- theme: getTheme(theme),
251
+ theme: rendererTheme,
242
252
  data: {
243
253
  nodes: g6Nodes,
244
254
  edges: g6Edges
245
255
  },
246
256
  autoFit: 'view',
247
257
  autoResize: true,
248
- padding: title ? [46, 20, 20, 20] : 20,
249
- plugins: title ? [{
250
- key: 'title',
251
- type: 'title',
252
- title: title,
253
- titleFill: isDark ? '#e0e6ed' : '#000',
254
- titleFontFamily: 'sans-serif'
255
- }] : [],
258
+ padding: graphTitle.padding,
259
+ plugins: graphTitle.plugins,
256
260
  node: {
257
261
  type: 'html',
258
262
  style: function style(d) {
@@ -264,7 +268,7 @@ export var FlowDiagram = function FlowDiagram(options) {
264
268
  size: size,
265
269
  dx: -DEFAULT_NODE_WIDTH / 2,
266
270
  dy: -height / 2,
267
- innerHTML: createNodeHTML(d, color, selectedBorder, theme),
271
+ innerHTML: createNodeHTML(d, color, selectedBorder, baseTheme),
268
272
  ports: [{
269
273
  placement: 'top'
270
274
  }, {
@@ -283,15 +287,11 @@ export var FlowDiagram = function FlowDiagram(options) {
283
287
  },
284
288
  edge: {
285
289
  type: 'polyline',
286
- style: {
290
+ style: _objectSpread(_objectSpread({
287
291
  lineWidth: 3,
288
292
  radius: 20,
289
293
  stroke: edgeStroke,
290
294
  endArrow: true,
291
- labelText: function labelText(d) {
292
- var _d$data2;
293
- return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
294
- },
295
295
  labelFill: labelFill,
296
296
  labelFontWeight: 600,
297
297
  labelBackground: true,
@@ -300,12 +300,17 @@ export var FlowDiagram = function FlowDiagram(options) {
300
300
  labelBackgroundLineWidth: 3,
301
301
  labelBackgroundStroke: labelBgStroke,
302
302
  labelPadding: [1, 10],
303
- labelBackgroundRadius: 4,
303
+ labelBackgroundRadius: 4
304
+ }, edgeTheme), {}, {
305
+ labelText: function labelText(d) {
306
+ var _d$data2;
307
+ return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
308
+ },
304
309
  router: {
305
310
  type: 'orth',
306
311
  padding: 40
307
312
  }
308
- },
313
+ }),
309
314
  state: {
310
315
  active: {
311
316
  stroke: ACTIVE_COLOR,
@@ -324,7 +329,7 @@ export var FlowDiagram = function FlowDiagram(options) {
324
329
  // Measure real node heights after initial render
325
330
  graph.once('afterrender', function () {
326
331
  if (graph) {
327
- measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder, theme);
332
+ measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder, baseTheme);
328
333
  }
329
334
  });
330
335
  };
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * FunnelDataItem is the type for each data item in the funnel chart.
4
4
  */
@@ -14,11 +14,9 @@ export interface FunnelConfig {
14
14
  data: FunnelDataItem[];
15
15
  theme?: VisualizationTheme;
16
16
  title?: string;
17
+ subtitle?: string;
17
18
  conversionRateLabel?: string;
18
- style?: {
19
- backgroundColor?: string;
20
- palette?: string[];
21
- };
19
+ style?: ThemeStyle;
22
20
  }
23
21
  /**
24
22
  * FunnelInstance represents a funnel chart instance with render and destroy methods.
@@ -1,17 +1,20 @@
1
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
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
3
  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."); }
9
4
  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); }
10
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
- import { CHART_FONT_FAMILY, getBackgroundColor, getChartVisualTokens, getThemeObject, normalizePalette, resolveChartLocale } from "../../util";
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
18
 
16
19
  /**
17
20
  * FunnelDataItem is the type for each data item in the funnel chart.
@@ -89,14 +92,16 @@ export var Funnel = function Funnel(options) {
89
92
  * Render the funnel chart with the given configuration.
90
93
  */
91
94
  var render = function render(config) {
95
+ var _getDataLabels;
92
96
  var _config$data = config.data,
93
97
  data = _config$data === void 0 ? [] : _config$data,
94
98
  _config$theme = config.theme,
95
99
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
96
100
  title = config.title,
101
+ subtitle = config.subtitle,
97
102
  conversionRateLabel = config.conversionRateLabel,
98
103
  _config$style = config.style,
99
- style = _config$style === void 0 ? {} : _config$style;
104
+ localStyle = _config$style === void 0 ? {} : _config$style;
100
105
  var chartLocale = resolveChartLocale(locale);
101
106
  var labels = FUNNEL_LABELS[chartLocale];
102
107
  var numberFormatter = new Intl.NumberFormat(chartLocale);
@@ -109,9 +114,26 @@ export var Funnel = function Funnel(options) {
109
114
  }
110
115
 
111
116
  // Get colors from style.palette or theme defaults
112
- var colors = normalizePalette(style.palette, theme);
113
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
114
- var tokens = getChartVisualTokens(theme);
117
+ var appearance = getThemeObject('funnel', theme, localStyle);
118
+ var rendererTheme = appearance.theme;
119
+ var intervalMark = _objectSpread(_objectSpread({
120
+ shape: 'funnel',
121
+ fillOpacity: 0.94,
122
+ stroke: getChartVisualTokens(rendererTheme.type).separator,
123
+ lineWidth: 2
124
+ }, rendererTheme.type === 'academy' ? {} : {
125
+ radius: 4
126
+ }), appearance.mark.interval);
127
+ var connectorStyle = _objectSpread({
128
+ stroke: getChartVisualTokens(rendererTheme.type).axisLine,
129
+ strokeOpacity: rendererTheme.type === 'academy' ? 1 : 0.82,
130
+ lineWidth: rendererTheme.type === 'academy' ? 1 : 0.75,
131
+ endMarker: false,
132
+ connectLength1: -12
133
+ }, appearance.mark.connector);
134
+ var colors = rendererTheme.category10;
135
+ var tokens = getChartVisualTokens(rendererTheme.type);
136
+ var connectorMark = connectorStyle;
115
137
  var formatValue = function formatValue(value) {
116
138
  return Number.isFinite(value) ? numberFormatter.format(value) : '—';
117
139
  };
@@ -144,6 +166,23 @@ export var Funnel = function Funnel(options) {
144
166
  };
145
167
  }]
146
168
  };
169
+ var primaryLabels = (_getDataLabels = getDataLabels(rendererTheme, {
170
+ style: {
171
+ fontFamily: CHART_FONT_FAMILY,
172
+ fontSize: 12,
173
+ fontWeight: 500,
174
+ lineHeight: 17
175
+ },
176
+ defaultVisible: true,
177
+ text: function text(d) {
178
+ return "".concat(d.category, "\n").concat(formatValue(d.value));
179
+ },
180
+ position: 'inside',
181
+ contrast: 'inside',
182
+ transform: [{
183
+ type: 'overflowStroke'
184
+ }]
185
+ })) !== null && _getDataLabels !== void 0 ? _getDataLabels : [];
147
186
 
148
187
  // Create chart
149
188
  chart = new Chart({
@@ -162,15 +201,17 @@ export var Funnel = function Funnel(options) {
162
201
  animate: false,
163
202
  type: 'view',
164
203
  data: data,
165
- title: title || '',
204
+ title: title ? {
205
+ title: title,
206
+ subtitle: subtitle
207
+ } : '',
166
208
  children: [{
167
209
  type: 'interval',
168
210
  data: data,
169
211
  encode: {
170
212
  x: 'category',
171
213
  y: 'value',
172
- color: 'category',
173
- shape: 'funnel' // Use funnel shape for proper funnel visualization
214
+ color: 'category'
174
215
  },
175
216
  transform: [{
176
217
  type: 'symmetryY'
@@ -190,23 +231,7 @@ export var Funnel = function Funnel(options) {
190
231
  },
191
232
  legend: false,
192
233
  tooltip: funnelTooltip,
193
- labels: [{
194
- text: function text(d) {
195
- return "".concat(d.category, "\n").concat(formatValue(d.value));
196
- },
197
- position: 'inside',
198
- transform: [{
199
- type: 'contrastReverse'
200
- }, {
201
- type: 'overflowStroke'
202
- }],
203
- style: {
204
- fontFamily: CHART_FONT_FAMILY,
205
- fontSize: 12,
206
- fontWeight: 500,
207
- lineHeight: 17
208
- }
209
- }, {
234
+ labels: [].concat(_toConsumableArray(primaryLabels), [{
210
235
  text: function text(_d, index, items) {
211
236
  return (isInverted ? index < items.length - 1 : index > 0) ? '———' : '';
212
237
  },
@@ -237,24 +262,15 @@ export var Funnel = function Funnel(options) {
237
262
  fontSize: 11,
238
263
  fontWeight: 500
239
264
  }
240
- }],
241
- style: _objectSpread({
242
- fillOpacity: 0.94,
243
- stroke: tokens.separator,
244
- lineWidth: 2
245
- }, theme === 'academy' ? {} : {
246
- radius: 4
247
- }),
265
+ }]),
266
+ style: intervalMark,
248
267
  state: {
249
268
  active: {
250
269
  fillOpacity: 1,
251
270
  stroke: tokens.separator,
252
271
  lineWidth: 3
253
272
  }
254
- },
255
- viewStyle: style.backgroundColor ? {
256
- viewFill: backgroundColor
257
- } : undefined
273
+ }
258
274
  }].concat(_toConsumableArray(data.length > 1 ? [{
259
275
  type: 'connector',
260
276
  data: [{
@@ -270,13 +286,7 @@ export var Funnel = function Funnel(options) {
270
286
  y1: 'endY'
271
287
  },
272
288
  tooltip: false,
273
- style: {
274
- stroke: tokens.axisLine,
275
- strokeOpacity: theme === 'academy' ? 1 : 0.82,
276
- lineWidth: theme === 'academy' ? 1 : 0.75,
277
- markerEnd: false,
278
- connectLength1: -12
279
- },
289
+ style: connectorMark,
280
290
  labels: [{
281
291
  text: formatMetricLabel(overallConversionRateLabel, formatConversionRate(data[0].value, data[data.length - 1].value), chartLocale),
282
292
  position: 'left',
@@ -294,12 +304,11 @@ export var Funnel = function Funnel(options) {
294
304
  axis: false,
295
305
  interaction: {
296
306
  tooltip: true,
297
- elementHighlight: true
307
+ elementHighlight: {
308
+ delay: CHART_STYLE_DEFAULTS.interactionDelay
309
+ }
298
310
  },
299
- viewStyle: style.backgroundColor ? {
300
- viewFill: backgroundColor
301
- } : undefined,
302
- theme: getThemeObject(theme)
311
+ theme: rendererTheme
303
312
  };
304
313
  chart.options(chartOptions);
305
314
  chart.render();
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * HistogramConfig defines the configuration for rendering the histogram chart.
4
4
  */
@@ -7,13 +7,11 @@ export interface HistogramConfig {
7
7
  data: number[];
8
8
  binNumber?: number;
9
9
  title?: string;
10
+ subtitle?: string;
10
11
  axisXTitle?: string;
11
12
  axisYTitle?: string;
12
- theme?: 'default' | 'academy' | 'dark';
13
- style?: {
14
- backgroundColor?: string;
15
- palette?: string[];
16
- };
13
+ theme?: VisualizationTheme;
14
+ style?: ThemeStyle;
17
15
  }
18
16
  /**
19
17
  * HistogramInstance represents a histogram chart instance with render and destroy methods.
@@ -1,5 +1,12 @@
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); }
1
7
  import { Chart } from '@antv/g2';
2
- import { getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { getThemeObject } from "../../theme/g2";
9
+ import { getCartesianAxis } from "../../util/components";
3
10
 
4
11
  /**
5
12
  * HistogramConfig defines the configuration for rendering the histogram chart.
@@ -48,11 +55,12 @@ export var Histogram = function Histogram(options) {
48
55
  _config$theme = config.theme,
49
56
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
50
57
  title = config.title,
58
+ subtitle = config.subtitle,
51
59
  axisXTitle = config.axisXTitle,
52
60
  axisYTitle = config.axisYTitle,
53
61
  binNumber = config.binNumber,
54
62
  _config$style = config.style,
55
- style = _config$style === void 0 ? {} : _config$style;
63
+ localStyle = _config$style === void 0 ? {} : _config$style;
56
64
 
57
65
  // Clean up previous chart if exists
58
66
  if (chart) {
@@ -60,7 +68,14 @@ export var Histogram = function Histogram(options) {
60
68
  }
61
69
 
62
70
  // Get colors from style.palette or theme defaults
63
- var colors = normalizePalette(style.palette, theme);
71
+ var appearance = getThemeObject('histogram', theme, localStyle);
72
+ var rendererTheme = appearance.theme;
73
+ var intervalMark = _objectSpread({
74
+ minHeight: 1,
75
+ columnWidthRatio: 1,
76
+ inset: 0.5
77
+ }, appearance.mark.interval);
78
+ var colors = rendererTheme.category10;
64
79
 
65
80
  // Create chart
66
81
  chart = new Chart({
@@ -77,7 +92,10 @@ export var Histogram = function Histogram(options) {
77
92
  animate: false,
78
93
  type: 'interval',
79
94
  data: data,
80
- title: title !== null && title !== void 0 ? title : '',
95
+ title: title ? {
96
+ title: title,
97
+ subtitle: subtitle
98
+ } : '',
81
99
  encode: {
82
100
  x: function x(d) {
83
101
  return d;
@@ -93,19 +111,11 @@ export var Histogram = function Histogram(options) {
93
111
  y: 'count',
94
112
  thresholds: binNumber
95
113
  }],
96
- style: {
97
- minHeight: 1,
98
- columnWidthRatio: 1,
99
- inset: 0.5
100
- },
101
- axis: {
102
- x: {
103
- title: axisXTitle
104
- },
105
- y: {
106
- title: axisYTitle
107
- }
108
- },
114
+ style: intervalMark,
115
+ axis: getCartesianAxis({
116
+ axisXTitle: axisXTitle,
117
+ axisYTitle: axisYTitle
118
+ }),
109
119
  scale: {
110
120
  y: {
111
121
  nice: true
@@ -121,10 +131,7 @@ export var Histogram = function Histogram(options) {
121
131
  name: '频数'
122
132
  }]
123
133
  },
124
- viewStyle: style.backgroundColor ? {
125
- viewFill: style.backgroundColor
126
- } : undefined,
127
- theme: getThemeObject(theme)
134
+ theme: rendererTheme
128
135
  };
129
136
  chart.options(chartOptions);
130
137
  chart.render();
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * Indented tree node data — only name + optional children, no description.
4
4
  * Aligns with the official G6 indented tree example data structure.
@@ -13,14 +13,12 @@ export interface IndentedTreeData {
13
13
  export interface IndentedTreeConfig {
14
14
  type?: 'indented-tree';
15
15
  data: IndentedTreeData;
16
- theme?: 'default' | 'academy' | 'dark';
16
+ theme?: VisualizationTheme;
17
17
  title?: string;
18
+ subtitle?: string;
18
19
  /** Layout direction: 'LR' = root left (default), 'RL' = root right, 'H' = root center */
19
20
  direction?: 'LR' | 'RL' | 'H';
20
- style?: {
21
- backgroundColor?: string;
22
- palette?: string[];
23
- };
21
+ style?: ThemeStyle;
24
22
  }
25
23
  /**
26
24
  * IndentedTreeInstance represents a chart instance with render and destroy methods.