@antv/gpt-vis 1.0.1 → 1.3.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 (172) hide show
  1. package/README.md +113 -36
  2. package/README.zh-CN.md +113 -36
  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/resolve.d.ts +7 -0
  11. package/dist/cjs/theme/resolve.js +58 -0
  12. package/dist/cjs/theme/shared.d.ts +7 -0
  13. package/dist/cjs/theme/shared.js +61 -0
  14. package/dist/cjs/theme/summary.d.ts +11 -0
  15. package/dist/cjs/theme/summary.js +61 -0
  16. package/dist/cjs/theme/table.d.ts +13 -0
  17. package/dist/cjs/theme/table.js +121 -0
  18. package/dist/cjs/types/index.d.ts +8 -5
  19. package/dist/cjs/types/theme.d.ts +107 -0
  20. package/dist/cjs/types/theme.js +17 -0
  21. package/dist/cjs/util/animation.js +6 -1
  22. package/dist/cjs/util/components.d.ts +20 -0
  23. package/dist/cjs/util/components.js +40 -0
  24. package/dist/cjs/util/crosshair-axis-labels.d.ts +7 -2
  25. package/dist/cjs/util/crosshair-axis-labels.js +144 -30
  26. package/dist/cjs/util/html.d.ts +1 -0
  27. package/dist/cjs/util/html.js +29 -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 +13 -10
  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 +87 -51
  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 -6
  49. package/dist/cjs/vis/funnel/index.js +77 -58
  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 +56 -8
  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/resolve.d.ts +7 -0
  93. package/dist/esm/theme/resolve.js +27 -0
  94. package/dist/esm/theme/shared.d.ts +7 -0
  95. package/dist/esm/theme/shared.js +21 -0
  96. package/dist/esm/theme/summary.d.ts +11 -0
  97. package/dist/esm/theme/summary.js +45 -0
  98. package/dist/esm/theme/table.d.ts +13 -0
  99. package/dist/esm/theme/table.js +112 -0
  100. package/dist/esm/types/index.d.ts +8 -5
  101. package/dist/esm/types/theme.d.ts +107 -0
  102. package/dist/esm/types/theme.js +1 -0
  103. package/dist/esm/util/animation.js +12 -2
  104. package/dist/esm/util/components.d.ts +20 -0
  105. package/dist/esm/util/components.js +57 -1
  106. package/dist/esm/util/crosshair-axis-labels.d.ts +7 -2
  107. package/dist/esm/util/crosshair-axis-labels.js +156 -35
  108. package/dist/esm/util/html.d.ts +1 -0
  109. package/dist/esm/util/html.js +3 -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 +13 -10
  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 +97 -57
  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 -6
  131. package/dist/esm/vis/funnel/index.js +78 -68
  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 +48 -11
  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
@@ -15,7 +15,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
15
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
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
- import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
18
+ import { getThemeObject } from "../../theme/g6";
19
+ import { getGraphTitle } from "../../util/components";
19
20
 
20
21
  /**
21
22
  * MindmapConfig defines the configuration for rendering the mindmap.
@@ -131,8 +132,9 @@ export var Mindmap = function Mindmap(options) {
131
132
  _config$theme = config.theme,
132
133
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
133
134
  title = config.title,
135
+ subtitle = config.subtitle,
134
136
  _config$style = config.style,
135
- style = _config$style === void 0 ? {} : _config$style;
137
+ localStyle = _config$style === void 0 ? {} : _config$style;
136
138
  if (!data || !data.name) {
137
139
  throw new Error('Mindmap: data with a name field is required');
138
140
  }
@@ -145,9 +147,15 @@ export var Mindmap = function Mindmap(options) {
145
147
  throw new Error('Mindmap: container element not found');
146
148
  }
147
149
  containerEl.innerHTML = '';
148
- var colors = normalizePalette(style.palette, theme);
149
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
150
- var isDark = theme === 'dark';
150
+ var appearance = getThemeObject('mindmap', theme, localStyle);
151
+ var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
152
+ var rendererTheme = appearance.theme;
153
+ var baseTheme = appearance.baseTheme;
154
+ var colors = appearance.colors;
155
+ var backgroundColor = appearance.backgroundColor;
156
+ var isDark = baseTheme === 'dark';
157
+ var nodeTheme = appearance.node.style;
158
+ var edgeTheme = appearance.edge.style;
151
159
  containerEl.style.background = backgroundColor;
152
160
 
153
161
  // Convert tree data and assign branch colors before rendering
@@ -159,13 +167,13 @@ export var Mindmap = function Mindmap(options) {
159
167
  _step2;
160
168
  try {
161
169
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
162
- var _node$depth;
170
+ var _node$depth, _nodeTheme$labelFontS;
163
171
  var node = _step2.value;
164
172
  var label = String(node.id);
165
173
  var depth = (_node$depth = node.depth) !== null && _node$depth !== void 0 ? _node$depth : 0;
166
- var fontSize = depth === 0 ? 24 : 16;
174
+ var fontSize = (_nodeTheme$labelFontS = nodeTheme.labelFontSize) !== null && _nodeTheme$labelFontS !== void 0 ? _nodeTheme$labelFontS : depth === 0 ? 24 : 16;
167
175
  var pad = depth === 0 ? 64 : 36;
168
- node.layoutSize = [estimateNodeWidth(label, fontSize, pad), depth === 0 ? 60 : 48];
176
+ node.layoutSize = [estimateNodeWidth(label, fontSize, pad), Math.max(depth === 0 ? 60 : 48, Math.ceil(fontSize * 1.2) + 16)];
169
177
  }
170
178
  } catch (err) {
171
179
  _iterator2.e(err);
@@ -179,18 +187,12 @@ export var Mindmap = function Mindmap(options) {
179
187
  height: height,
180
188
  autoFit: 'view',
181
189
  autoResize: true,
182
- padding: title ? [46, 20, 20, 20] : 20,
190
+ padding: graphTitle.padding,
183
191
  zoomRange: [0.1, 5],
184
192
  zoom: 1,
185
- theme: getTheme(theme),
193
+ theme: rendererTheme,
186
194
  data: graphData,
187
- plugins: title ? [{
188
- key: 'title',
189
- type: 'title',
190
- title: title,
191
- titleFill: isDark ? '#e0e6ed' : '#000',
192
- titleFontFamily: 'sans-serif'
193
- }] : [],
195
+ plugins: graphTitle.plugins,
194
196
  node: {
195
197
  type: 'rect',
196
198
  animation: {
@@ -218,13 +220,15 @@ export var Mindmap = function Mindmap(options) {
218
220
 
219
221
  // Common style
220
222
  var base = {
223
+ radius: baseTheme === 'academy' ? 0 : 8,
224
+ labelFontSize: fontSize,
225
+ labelFontWeight: fontWeight
226
+ };
227
+ var structuralStyle = {
221
228
  size: [nodeWidth, nodeHeight],
222
229
  dx: dx,
223
- radius: theme === 'academy' ? 0 : 8,
224
230
  labelText: label,
225
231
  labelPlacement: 'center',
226
- labelFontSize: fontSize,
227
- labelFontWeight: fontWeight,
228
232
  ports: [{
229
233
  placement: 'left'
230
234
  }, {
@@ -234,27 +238,27 @@ export var Mindmap = function Mindmap(options) {
234
238
 
235
239
  // Depth 0: gray filled (root)
236
240
  if (depth === 0) {
237
- return _objectSpread(_objectSpread({}, base), {}, {
241
+ return _objectSpread(_objectSpread(_objectSpread({}, base), {}, {
238
242
  fill: isDark ? '#333' : '#f1f4f5',
239
243
  labelFill: isDark ? '#e0e0e0' : '#252525'
240
- });
244
+ }, nodeTheme), structuralStyle);
241
245
  }
242
246
 
243
247
  // Depth 1: filled with branch color
244
248
  if (depth === 1) {
245
- return _objectSpread(_objectSpread({}, base), {}, {
249
+ return _objectSpread(_objectSpread(_objectSpread({}, base), {}, {
246
250
  fill: color || '#99ADD1',
247
251
  labelFill: '#fff'
248
- });
252
+ }, nodeTheme), structuralStyle);
249
253
  }
250
254
 
251
255
  // Depth 2+: outlined with branch color border
252
- return _objectSpread(_objectSpread({}, base), {}, {
256
+ return _objectSpread(_objectSpread(_objectSpread({}, base), {}, {
253
257
  fill: backgroundColor,
254
258
  stroke: color || (isDark ? '#555' : '#99ADD1'),
255
259
  lineWidth: 3,
256
260
  labelFill: isDark ? color || '#ccc' : color || '#333'
257
- });
261
+ }, nodeTheme), structuralStyle);
258
262
  }
259
263
  },
260
264
  edge: {
@@ -263,14 +267,14 @@ export var Mindmap = function Mindmap(options) {
263
267
  translate: false,
264
268
  update: false
265
269
  },
266
- style: {
270
+ style: _objectSpread({
267
271
  lineWidth: 3,
268
272
  stroke: function stroke(edgeData) {
269
273
  var _sourceNode$style;
270
274
  var sourceNode = this.getNodeData(edgeData.source);
271
275
  return (sourceNode === null || sourceNode === void 0 || (_sourceNode$style = sourceNode.style) === null || _sourceNode$style === void 0 ? void 0 : _sourceNode$style.color) || (isDark ? '#555' : '#99ADD1');
272
276
  }
273
- }
277
+ }, edgeTheme)
274
278
  },
275
279
  layout: {
276
280
  type: 'mindmap',
@@ -1,4 +1,4 @@
1
- import type { GraphData, VisualizationOptions } from '../../types';
1
+ import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export type NetworkGraphNode = GraphData['nodes'][number];
3
3
  export type NetworkGraphEdge = GraphData['edges'][number];
4
4
  export type NetworkGraphData = GraphData;
@@ -9,12 +9,10 @@ export interface NetworkGraphConfig {
9
9
  type?: 'network-graph';
10
10
  data: NetworkGraphData;
11
11
  layout?: 'force' | 'circular' | 'grid' | 'radial' | 'concentric' | 'dagre';
12
- theme?: 'default' | 'academy' | 'dark';
12
+ theme?: VisualizationTheme;
13
13
  title?: string;
14
- style?: {
15
- backgroundColor?: string;
16
- palette?: string[];
17
- };
14
+ subtitle?: string;
15
+ style?: ThemeStyle;
18
16
  }
19
17
  /**
20
18
  * NetworkGraphInstance represents a network graph 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 { Graph } from '@antv/g6';
2
- import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
8
+ import { getThemeObject } from "../../theme/g6";
9
+ import { getGraphTitle } from "../../util/components";
3
10
 
4
11
  /**
5
12
  * NetworkGraphConfig defines the configuration for rendering the network graph.
@@ -52,6 +59,7 @@ export var NetworkGraph = function NetworkGraph(options) {
52
59
  * Render the network graph with the given configuration.
53
60
  */
54
61
  var render = function render(config) {
62
+ var _nodeTheme$type, _edgeTheme$type;
55
63
  var _config$data = config.data,
56
64
  data = _config$data === void 0 ? {
57
65
  nodes: [],
@@ -62,8 +70,9 @@ export var NetworkGraph = function NetworkGraph(options) {
62
70
  _config$theme = config.theme,
63
71
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
64
72
  title = config.title,
73
+ subtitle = config.subtitle,
65
74
  _config$style = config.style,
66
- style = _config$style === void 0 ? {} : _config$style;
75
+ localStyle = _config$style === void 0 ? {} : _config$style;
67
76
  var _data$nodes = data.nodes,
68
77
  nodes = _data$nodes === void 0 ? [] : _data$nodes,
69
78
  _data$edges = data.edges,
@@ -74,9 +83,15 @@ export var NetworkGraph = function NetworkGraph(options) {
74
83
  graph.destroy();
75
84
  graph = null;
76
85
  }
77
- var colors = normalizePalette(style.palette, theme);
78
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
79
- var isDark = theme === 'dark';
86
+ var appearance = getThemeObject('network-graph', theme, localStyle);
87
+ var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
88
+ var rendererTheme = appearance.theme;
89
+ var baseTheme = appearance.baseTheme;
90
+ var colors = appearance.colors;
91
+ var backgroundColor = appearance.backgroundColor;
92
+ var isDark = baseTheme === 'dark';
93
+ var nodeTheme = appearance.node;
94
+ var edgeTheme = appearance.edge;
80
95
  var containerEl = typeof container === 'string' ? document.querySelector(container) : container;
81
96
  if (!containerEl) {
82
97
  throw new Error('NetworkGraph: container element not found');
@@ -97,15 +112,16 @@ export var NetworkGraph = function NetworkGraph(options) {
97
112
  data: {
98
113
  label: node.name
99
114
  },
100
- style: {
115
+ style: _objectSpread(_objectSpread({
101
116
  fill: colors[index % colors.length],
102
117
  stroke: isDark ? '#444' : '#fff',
103
118
  lineWidth: 2,
104
- labelText: node.name,
105
119
  labelFill: isDark ? '#e0e0e0' : '#333',
106
- labelFontSize: 12,
107
- size: 28
108
- }
120
+ labelFontSize: 12
121
+ }, nodeTheme.style), {}, {
122
+ size: 28,
123
+ labelText: node.name
124
+ })
109
125
  };
110
126
  });
111
127
 
@@ -118,17 +134,18 @@ export var NetworkGraph = function NetworkGraph(options) {
118
134
  data: {
119
135
  label: (_edge$name = edge.name) !== null && _edge$name !== void 0 ? _edge$name : ''
120
136
  },
121
- style: {
137
+ style: _objectSpread(_objectSpread({
122
138
  stroke: isDark ? '#555' : '#ccc',
123
139
  lineWidth: 1.5,
124
140
  endArrow: true,
125
- labelText: (_edge$name2 = edge.name) !== null && _edge$name2 !== void 0 ? _edge$name2 : '',
126
141
  labelFill: isDark ? '#aaa' : '#666',
127
142
  labelFontSize: 11,
128
143
  labelBackground: !!edge.name,
129
144
  labelBackgroundFill: backgroundColor,
130
145
  labelBackgroundOpacity: 0.8
131
- }
146
+ }, edgeTheme.style), {}, {
147
+ labelText: (_edge$name2 = edge.name) !== null && _edge$name2 !== void 0 ? _edge$name2 : ''
148
+ })
132
149
  };
133
150
  });
134
151
 
@@ -180,27 +197,25 @@ export var NetworkGraph = function NetworkGraph(options) {
180
197
  height: height,
181
198
  autoFit: 'view',
182
199
  autoResize: true,
183
- theme: getTheme(theme),
184
- padding: title ? [46, 20, 20, 20] : 20,
200
+ theme: rendererTheme,
201
+ padding: graphTitle.padding,
185
202
  data: {
186
203
  nodes: nodeData,
187
204
  edges: edgeData
188
205
  },
189
206
  layout: layoutConfig[layout] || layoutConfig.force,
190
207
  node: {
208
+ type: (_nodeTheme$type = nodeTheme.type) !== null && _nodeTheme$type !== void 0 ? _nodeTheme$type : 'circle',
191
209
  style: {
192
210
  labelPlacement: 'bottom',
193
211
  labelMaxWidth: 100
194
212
  }
195
213
  },
214
+ edge: {
215
+ type: (_edgeTheme$type = edgeTheme.type) !== null && _edgeTheme$type !== void 0 ? _edgeTheme$type : 'line'
216
+ },
196
217
  behaviors: ['drag-canvas', 'drag-element', 'click-select'],
197
- plugins: title ? [{
198
- key: 'title',
199
- type: 'title',
200
- title: title,
201
- titleFill: isDark ? '#e0e6ed' : '#000',
202
- titleFontFamily: 'sans-serif'
203
- }] : []
218
+ plugins: graphTitle.plugins
204
219
  });
205
220
  graph.render();
206
221
  };
@@ -1,4 +1,4 @@
1
- import type { TreeGraphData, VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, TreeGraphData, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export type OrganizationChartData = TreeGraphData;
3
3
  /**
4
4
  * OrganizationChartConfig defines the configuration for rendering the organization chart.
@@ -6,12 +6,10 @@ export type OrganizationChartData = TreeGraphData;
6
6
  export interface OrganizationChartConfig {
7
7
  type?: 'organization-chart';
8
8
  data: OrganizationChartData;
9
- theme?: 'default' | 'academy' | 'dark';
9
+ theme?: VisualizationTheme;
10
10
  title?: string;
11
- style?: {
12
- backgroundColor?: string;
13
- palette?: string[];
14
- };
11
+ subtitle?: string;
12
+ style?: ThemeStyle;
15
13
  }
16
14
  /**
17
15
  * OrganizationChartInstance represents a chart instance with render and destroy methods.
@@ -1,3 +1,9 @@
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
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
8
  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
9
  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); }
@@ -5,7 +11,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
5
11
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
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; }
7
13
  import { Graph } from '@antv/g6';
8
- import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
14
+ import { getThemeObject } from "../../theme/g6";
15
+ import { getGraphTitle } from "../../util/components";
9
16
 
10
17
  /**
11
18
  * OrganizationChartConfig defines the configuration for rendering the organization chart.
@@ -102,8 +109,9 @@ export var OrganizationChart = function OrganizationChart(options) {
102
109
  _config$theme = config.theme,
103
110
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
104
111
  title = config.title,
112
+ subtitle = config.subtitle,
105
113
  _config$style = config.style,
106
- style = _config$style === void 0 ? {} : _config$style;
114
+ localStyle = _config$style === void 0 ? {} : _config$style;
107
115
  if (!data || !data.name) {
108
116
  throw new Error('OrganizationChart: data with a name field is required');
109
117
  }
@@ -116,9 +124,19 @@ export var OrganizationChart = function OrganizationChart(options) {
116
124
  throw new Error('OrganizationChart: container element not found');
117
125
  }
118
126
  containerEl.innerHTML = '';
119
- var colors = normalizePalette(style.palette, theme);
120
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
121
- var isDark = theme === 'dark';
127
+ var appearance = getThemeObject('organization-chart', theme, localStyle);
128
+ var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
129
+ var rendererTheme = appearance.theme;
130
+ var baseTheme = appearance.baseTheme;
131
+ var colors = appearance.colors;
132
+ var backgroundColor = appearance.backgroundColor;
133
+ var isDark = baseTheme === 'dark';
134
+ var nodeTheme = appearance.node.style;
135
+ var edgeTheme = appearance.edge.style;
136
+ var labelLineHeight = nodeTheme.labelFontSize === undefined ? 14 : Math.ceil(nodeTheme.labelFontSize * 1.2);
137
+ var getNodeSize = function getNodeSize(d) {
138
+ return [NODE_WIDTH, d.data.description ? Math.max(NODE_HEIGHT_WITH_DESC, labelLineHeight * 3 + 16) : Math.max(NODE_HEIGHT_NO_DESC, labelLineHeight + 16)];
139
+ };
122
140
  containerEl.style.background = backgroundColor;
123
141
  containerEl.style.borderRadius = '4px';
124
142
  containerEl.style.overflow = 'hidden';
@@ -153,8 +171,8 @@ export var OrganizationChart = function OrganizationChart(options) {
153
171
  height: height,
154
172
  autoFit: 'view',
155
173
  autoResize: true,
156
- theme: getTheme(theme),
157
- padding: title ? [46, 20, 20, 20] : 20,
174
+ theme: rendererTheme,
175
+ padding: graphTitle.padding,
158
176
  data: {
159
177
  nodes: nodeData,
160
178
  edges: edgeData
@@ -173,65 +191,60 @@ export var OrganizationChart = function OrganizationChart(options) {
173
191
  if (!biz) return '';
174
192
  var name = escapeHtml(String((_biz$name = biz.name) !== null && _biz$name !== void 0 ? _biz$name : ''));
175
193
  var desc = biz.description ? escapeHtml(String(biz.description)) : '';
176
- return "\n <div style=\"max-width:260px;font-family:".concat(FONT_FAMILY, ";\">\n <div style=\"font-weight:700;font-size:12px;line-height:1.2;margin-bottom:").concat(desc ? '4px' : '0', ";\">\n ").concat(name, "\n </div>\n ").concat(desc ? "<div style=\"font-size:12px;line-height:1.35;opacity:".concat(isDark ? '0.86' : '0.78', ";\">").concat(desc, "</div>") : '', "\n </div>\n ");
194
+ return "\n <div style=\"max-width:260px;\">\n <div style=\"font-weight:700;margin-bottom:".concat(desc ? '4px' : '0', ";\">\n ").concat(name, "\n </div>\n ").concat(desc ? "<div style=\"opacity:".concat(isDark ? '0.86' : '0.78', ";\">").concat(desc, "</div>") : '', "\n </div>\n ");
177
195
  },
178
196
  style: {
179
- '.tooltip': {
197
+ '.tooltip': _objectSpread({
180
198
  background: isDark ? 'rgba(20,20,20,0.92)' : 'rgba(255,255,255,0.96)',
181
199
  color: isDark ? '#f2f2f2' : '#1f1f1f',
182
200
  border: "1px solid ".concat(isDark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.10)'),
183
201
  borderRadius: 8,
184
202
  boxShadow: '0 12px 28px rgba(0,0,0,0.16)',
185
203
  padding: '8px 10px',
186
- pointerEvents: 'none'
187
- }
204
+ pointerEvents: 'none',
205
+ fontFamily: FONT_FAMILY,
206
+ fontSize: '12px',
207
+ lineHeight: 1.35
208
+ }, appearance.tooltipStyle)
188
209
  }
189
- }].concat(_toConsumableArray(title ? [{
190
- key: 'title',
191
- type: 'title',
192
- title: title,
193
- titleFill: isDark ? '#e0e6ed' : '#000',
194
- titleFontFamily: 'sans-serif'
195
- }] : [])),
210
+ }].concat(_toConsumableArray(graphTitle.plugins)),
196
211
  node: {
197
212
  type: 'rect',
198
- style: {
199
- // size: [width, height] is the correct API for rect nodes in G6 v5
200
- size: function size(d) {
201
- return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
202
- },
213
+ style: _objectSpread(_objectSpread({
203
214
  fill: function fill(d) {
204
215
  return colors[d.data.depth % colors.length];
205
216
  },
206
217
  stroke: isDark ? '#555' : '#e8ebf0',
207
218
  lineWidth: 1,
208
- radius: theme === 'academy' ? 0 : 8,
209
- // Use official label wrapping/ellipsis for BOTH name & description.
210
- // 1 line name + up to 2 lines description => total maxLines = 3.
219
+ radius: baseTheme === 'academy' ? 0 : 8,
220
+ labelFill: '#ffffff',
221
+ labelFontSize: 12,
222
+ labelFontWeight: 600
223
+ }, nodeTheme), {}, {
224
+ // Layout and data-derived content remain chart-owned. One line is
225
+ // reserved for the name and up to two lines for the description.
226
+ size: getNodeSize,
211
227
  labelText: function labelText(d) {
212
228
  return d.data.description ? "".concat(d.data.name, "\n").concat(d.data.description) : d.data.name;
213
229
  },
214
- labelFill: '#ffffff',
215
- labelFontSize: 12,
216
- labelFontWeight: 600,
217
230
  labelWordWrap: true,
218
231
  labelWordWrapWidth: LABEL_MAX_WIDTH,
219
232
  labelMaxLines: function labelMaxLines(d) {
220
233
  return d.data.description ? 3 : 1;
221
234
  },
222
- labelLineHeight: 14,
235
+ labelLineHeight: labelLineHeight,
223
236
  labelPlacement: 'center'
224
- }
237
+ })
225
238
  },
226
239
  edge: {
227
240
  // Use a tree-friendly edge type that does not depend on node ports.
228
241
  type: 'cubic-vertical',
229
- style: {
242
+ style: _objectSpread({
230
243
  stroke: isDark ? '#4a4a4a' : '#d0d7e0',
231
244
  lineWidth: 1.5,
232
245
  endArrow: false,
233
246
  startArrow: false
234
- }
247
+ }, edgeTheme)
235
248
  },
236
249
  layout: {
237
250
  type: 'dagre',
@@ -239,9 +252,7 @@ export var OrganizationChart = function OrganizationChart(options) {
239
252
  nodesep: 40,
240
253
  ranksep: 60,
241
254
  // Dynamic nodeSize lets dagre calculate accurate per-node spacing
242
- nodeSize: function nodeSize(d) {
243
- return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
244
- }
255
+ nodeSize: getNodeSize
245
256
  },
246
257
  behaviors: ['drag-canvas']
247
258
  });
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * PieDataItem is the type for each data item in the pie chart.
4
4
  */
@@ -15,10 +15,8 @@ export interface PieConfig {
15
15
  innerRadius?: number;
16
16
  theme?: VisualizationTheme;
17
17
  title?: string;
18
- style?: {
19
- backgroundColor?: string;
20
- palette?: string[];
21
- };
18
+ subtitle?: string;
19
+ style?: ThemeStyle;
22
20
  }
23
21
  /**
24
22
  * PieInstance represents a pie chart instance with render and destroy methods.
@@ -1,5 +1,15 @@
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 { getChartAnimation, getChartVisualTokens, getColorLegend, getThemeObject, normalizePalette } from "../../util";
8
+ 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";
3
13
 
4
14
  /**
5
15
  * PieDataItem is the type for each data item in the pie chart.
@@ -55,27 +65,29 @@ export var Pie = function Pie(options) {
55
65
  var render = function render(config) {
56
66
  var _config$data = config.data,
57
67
  data = _config$data === void 0 ? [] : _config$data,
58
- _config$innerRadius = config.innerRadius,
59
- innerRadius = _config$innerRadius === void 0 ? 0 : _config$innerRadius,
68
+ innerRadius = config.innerRadius,
60
69
  _config$theme = config.theme,
61
70
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
62
71
  title = config.title,
72
+ subtitle = config.subtitle,
63
73
  _config$style = config.style,
64
- style = _config$style === void 0 ? {} : _config$style;
74
+ localStyle = _config$style === void 0 ? {} : _config$style;
65
75
 
66
76
  // Clean up previous chart if exists
67
77
  if (chart) {
68
78
  chart.destroy();
69
79
  }
70
-
71
- // Get colors from style.palette or theme defaults
72
- var colors = normalizePalette(style.palette, theme);
73
- var tokens = getChartVisualTokens(theme);
74
-
75
- // Calculate sum for percentage labels
76
80
  var sumValue = data.reduce(function (sum, item) {
77
81
  return sum + item.value;
78
82
  }, 0);
83
+ var appearance = getThemeObject('pie', theme, localStyle);
84
+ var rendererTheme = appearance.theme;
85
+ var intervalMark = _objectSpread({
86
+ fillOpacity: 1,
87
+ stroke: getChartVisualTokens(rendererTheme.type).separator,
88
+ lineWidth: 2
89
+ }, appearance.mark.interval);
90
+ var colors = rendererTheme.category10;
79
91
 
80
92
  // Create chart
81
93
  chart = new Chart({
@@ -92,7 +104,10 @@ export var Pie = function Pie(options) {
92
104
  animate: getChartAnimation(hasRendered, 'waveIn'),
93
105
  type: 'interval',
94
106
  data: data,
95
- title: title || '',
107
+ title: title ? {
108
+ title: title,
109
+ subtitle: subtitle
110
+ } : '',
96
111
  encode: {
97
112
  y: 'value',
98
113
  color: 'category'
@@ -102,7 +117,7 @@ export var Pie = function Pie(options) {
102
117
  }],
103
118
  coordinate: {
104
119
  type: 'theta',
105
- innerRadius: Math.max(0, Math.min(1, innerRadius))
120
+ innerRadius: Math.max(0, Math.min(1, innerRadius !== null && innerRadius !== void 0 ? innerRadius : 0))
106
121
  },
107
122
  scale: {
108
123
  color: {
@@ -110,17 +125,23 @@ export var Pie = function Pie(options) {
110
125
  }
111
126
  },
112
127
  legend: getColorLegend(true),
113
- labels: data.length > 8 ? [] : [{
128
+ labels: getDataLabels(rendererTheme, {
129
+ defaultVisible: data.length <= 8,
114
130
  text: function text(d) {
115
131
  var percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
116
132
  var formattedPercentage = Number(percentage.toFixed(1)).toString();
117
133
  return "".concat(d.category, ": ").concat(formattedPercentage, "%");
118
134
  },
119
135
  position: 'outside',
136
+ contrast: 'outside',
120
137
  transform: [{
138
+ type: 'exceedAdjust',
139
+ offsetX: 4,
140
+ offsetY: 4
141
+ }, {
121
142
  type: 'overlapHide'
122
143
  }]
123
- }],
144
+ }),
124
145
  tooltip: {
125
146
  items: [function (d) {
126
147
  return {
@@ -131,10 +152,12 @@ export var Pie = function Pie(options) {
131
152
  },
132
153
  interaction: {
133
154
  tooltip: true,
134
- elementHighlight: true,
135
- elementHoverScale: {
136
- shadow: false
155
+ elementHighlight: {
156
+ delay: CHART_STYLE_DEFAULTS.interactionDelay
137
157
  },
158
+ elementHoverScale: _objectSpread(_objectSpread({}, getElementHoverScaleInteraction(rendererTheme.type)), {}, {
159
+ shadow: false
160
+ }),
138
161
  elementSelect: {
139
162
  single: true
140
163
  }
@@ -152,15 +175,8 @@ export var Pie = function Pie(options) {
152
175
  lineWidth: 3
153
176
  }
154
177
  },
155
- style: {
156
- fillOpacity: 1,
157
- stroke: tokens.separator,
158
- lineWidth: 2
159
- },
160
- viewStyle: style.backgroundColor ? {
161
- viewFill: style.backgroundColor
162
- } : undefined,
163
- theme: getThemeObject(theme)
178
+ style: intervalMark,
179
+ theme: rendererTheme
164
180
  };
165
181
  chart.options(chartOptions);
166
182
  chart.render();