@antv/gpt-vis 1.0.0-beta.1 → 1.0.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 (159) hide show
  1. package/README.md +223 -47
  2. package/README.zh-CN.md +227 -51
  3. package/dist/cjs/gpt-vis/index.d.ts +8 -1
  4. package/dist/cjs/gpt-vis/index.js +43 -20
  5. package/dist/cjs/index.d.ts +15 -2
  6. package/dist/cjs/index.js +22 -2
  7. package/dist/cjs/syntax/parser.d.ts +17 -2
  8. package/dist/cjs/syntax/parser.js +151 -38
  9. package/dist/cjs/util/container.d.ts +5 -0
  10. package/dist/cjs/util/container.js +43 -0
  11. package/dist/cjs/util/theme.d.ts +5 -0
  12. package/dist/cjs/util/theme.js +9 -2
  13. package/dist/cjs/vis/area/index.js +2 -1
  14. package/dist/cjs/vis/bar/index.js +5 -4
  15. package/dist/cjs/vis/boxplot/index.js +7 -2
  16. package/dist/cjs/vis/column/index.js +5 -4
  17. package/dist/cjs/vis/dual-axes/index.js +3 -3
  18. package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
  19. package/dist/cjs/vis/fishbone-diagram/index.js +191 -0
  20. package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
  21. package/dist/cjs/vis/flow-diagram/index.js +287 -0
  22. package/dist/cjs/vis/funnel/index.js +2 -1
  23. package/dist/cjs/vis/histogram/index.js +3 -7
  24. package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
  25. package/dist/cjs/vis/indented-tree/index.js +385 -0
  26. package/dist/cjs/vis/line/index.js +2 -1
  27. package/dist/cjs/vis/liquid/index.js +2 -1
  28. package/dist/cjs/vis/mindmap/index.d.ts +32 -0
  29. package/dist/cjs/vis/mindmap/index.js +222 -0
  30. package/dist/cjs/vis/network-graph/index.d.ts +59 -0
  31. package/dist/cjs/vis/network-graph/index.js +175 -0
  32. package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
  33. package/dist/cjs/vis/organization-chart/index.js +200 -0
  34. package/dist/cjs/vis/pie/index.js +3 -3
  35. package/dist/cjs/vis/radar/index.d.ts +1 -0
  36. package/dist/cjs/vis/radar/index.js +10 -9
  37. package/dist/cjs/vis/sankey/index.js +2 -1
  38. package/dist/cjs/vis/scatter/index.d.ts +2 -0
  39. package/dist/cjs/vis/scatter/index.js +9 -4
  40. package/dist/cjs/vis/summary/index.js +17 -3
  41. package/dist/cjs/vis/table/index.d.ts +1 -0
  42. package/dist/cjs/vis/table/index.js +37 -1
  43. package/dist/cjs/vis/treemap/index.js +2 -1
  44. package/dist/cjs/vis/venn/index.d.ts +2 -1
  45. package/dist/cjs/vis/venn/index.js +18 -3
  46. package/dist/cjs/vis/violin/index.js +2 -1
  47. package/dist/cjs/vis/waterfall/index.d.ts +6 -9
  48. package/dist/cjs/vis/waterfall/index.js +29 -6
  49. package/dist/cjs/vis/word-cloud/index.js +2 -1
  50. package/dist/cjs/vis-wrapper/icons.js +2 -2
  51. package/dist/cjs/vis-wrapper/index.d.ts +1 -0
  52. package/dist/cjs/vis-wrapper/index.js +27 -16
  53. package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
  54. package/dist/cjs/vis-wrapper/styles.js +8 -1
  55. package/dist/esm/gpt-vis/index.d.ts +8 -1
  56. package/dist/esm/gpt-vis/index.js +47 -26
  57. package/dist/esm/index.d.ts +15 -2
  58. package/dist/esm/index.js +7 -1
  59. package/dist/esm/syntax/parser.d.ts +17 -2
  60. package/dist/esm/syntax/parser.js +248 -90
  61. package/dist/esm/util/container.d.ts +5 -0
  62. package/dist/esm/util/container.js +20 -0
  63. package/dist/esm/util/theme.d.ts +5 -0
  64. package/dist/esm/util/theme.js +9 -0
  65. package/dist/esm/vis/area/index.js +3 -2
  66. package/dist/esm/vis/bar/index.js +7 -6
  67. package/dist/esm/vis/boxplot/index.js +17 -4
  68. package/dist/esm/vis/column/index.js +7 -6
  69. package/dist/esm/vis/dual-axes/index.js +13 -5
  70. package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
  71. package/dist/esm/vis/fishbone-diagram/index.js +219 -0
  72. package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
  73. package/dist/esm/vis/flow-diagram/index.js +349 -0
  74. package/dist/esm/vis/funnel/index.js +3 -2
  75. package/dist/esm/vis/histogram/index.js +6 -7
  76. package/dist/esm/vis/indented-tree/index.d.ts +40 -0
  77. package/dist/esm/vis/indented-tree/index.js +569 -0
  78. package/dist/esm/vis/line/index.js +3 -2
  79. package/dist/esm/vis/liquid/index.js +3 -2
  80. package/dist/esm/vis/mindmap/index.d.ts +32 -0
  81. package/dist/esm/vis/mindmap/index.js +316 -0
  82. package/dist/esm/vis/network-graph/index.d.ts +59 -0
  83. package/dist/esm/vis/network-graph/index.js +242 -0
  84. package/dist/esm/vis/organization-chart/index.d.ts +64 -0
  85. package/dist/esm/vis/organization-chart/index.js +271 -0
  86. package/dist/esm/vis/pie/index.js +4 -8
  87. package/dist/esm/vis/radar/index.d.ts +1 -0
  88. package/dist/esm/vis/radar/index.js +20 -4
  89. package/dist/esm/vis/sankey/index.js +3 -2
  90. package/dist/esm/vis/scatter/index.d.ts +2 -0
  91. package/dist/esm/vis/scatter/index.js +15 -4
  92. package/dist/esm/vis/summary/index.js +25 -4
  93. package/dist/esm/vis/table/index.d.ts +1 -0
  94. package/dist/esm/vis/table/index.js +9 -2
  95. package/dist/esm/vis/treemap/index.js +3 -2
  96. package/dist/esm/vis/venn/index.d.ts +2 -1
  97. package/dist/esm/vis/venn/index.js +29 -4
  98. package/dist/esm/vis/violin/index.js +3 -2
  99. package/dist/esm/vis/waterfall/index.d.ts +6 -9
  100. package/dist/esm/vis/waterfall/index.js +33 -13
  101. package/dist/esm/vis/word-cloud/index.js +3 -2
  102. package/dist/esm/vis-wrapper/icons.js +2 -2
  103. package/dist/esm/vis-wrapper/index.d.ts +1 -0
  104. package/dist/esm/vis-wrapper/index.js +15 -10
  105. package/dist/esm/vis-wrapper/styles.d.ts +1 -1
  106. package/dist/esm/vis-wrapper/styles.js +1 -1
  107. package/dist/umd/index.min.js +1 -1
  108. package/package.json +17 -21
  109. package/src/gpt-vis/index.ts +0 -283
  110. package/src/index.ts +0 -44
  111. package/src/readme.md +0 -37
  112. package/src/syntax/index.ts +0 -2
  113. package/src/syntax/parser.ts +0 -411
  114. package/src/types/index.ts +0 -29
  115. package/src/util/theme.ts +0 -167
  116. package/src/vis/area/README.md +0 -143
  117. package/src/vis/area/index.ts +0 -212
  118. package/src/vis/bar/README.md +0 -158
  119. package/src/vis/bar/index.ts +0 -186
  120. package/src/vis/boxplot/README.md +0 -168
  121. package/src/vis/boxplot/index.ts +0 -162
  122. package/src/vis/column/README.md +0 -158
  123. package/src/vis/column/index.ts +0 -185
  124. package/src/vis/dual-axes/README.md +0 -191
  125. package/src/vis/dual-axes/index.ts +0 -218
  126. package/src/vis/funnel/README.md +0 -143
  127. package/src/vis/funnel/index.ts +0 -238
  128. package/src/vis/histogram/README.md +0 -130
  129. package/src/vis/histogram/index.ts +0 -153
  130. package/src/vis/line/README.md +0 -138
  131. package/src/vis/line/index.ts +0 -159
  132. package/src/vis/liquid/README.md +0 -150
  133. package/src/vis/liquid/index.ts +0 -130
  134. package/src/vis/pie/README.md +0 -127
  135. package/src/vis/pie/index.ts +0 -163
  136. package/src/vis/radar/README.md +0 -184
  137. package/src/vis/radar/index.ts +0 -214
  138. package/src/vis/sankey/README.md +0 -144
  139. package/src/vis/sankey/index.ts +0 -144
  140. package/src/vis/scatter/README.md +0 -145
  141. package/src/vis/scatter/index.ts +0 -147
  142. package/src/vis/summary/README.md +0 -272
  143. package/src/vis/summary/index.ts +0 -91
  144. package/src/vis/table/README.md +0 -174
  145. package/src/vis/table/index.ts +0 -241
  146. package/src/vis/treemap/README.md +0 -199
  147. package/src/vis/treemap/index.ts +0 -167
  148. package/src/vis/venn/README.md +0 -153
  149. package/src/vis/venn/index.ts +0 -149
  150. package/src/vis/violin/README.md +0 -168
  151. package/src/vis/violin/index.ts +0 -216
  152. package/src/vis/waterfall/README.md +0 -178
  153. package/src/vis/waterfall/index.ts +0 -258
  154. package/src/vis/word-cloud/README.md +0 -137
  155. package/src/vis/word-cloud/index.ts +0 -137
  156. package/src/vis-wrapper/README.md +0 -159
  157. package/src/vis-wrapper/icons.ts +0 -35
  158. package/src/vis-wrapper/index.ts +0 -276
  159. package/src/vis-wrapper/styles.ts +0 -195
@@ -0,0 +1,59 @@
1
+ import type { GraphData, VisualizationOptions } from '../../types';
2
+ export type NetworkGraphNode = GraphData['nodes'][number];
3
+ export type NetworkGraphEdge = GraphData['edges'][number];
4
+ export type NetworkGraphData = GraphData;
5
+ /**
6
+ * NetworkGraphConfig defines the configuration for rendering the network graph.
7
+ */
8
+ export interface NetworkGraphConfig {
9
+ type?: 'network-graph';
10
+ data: NetworkGraphData;
11
+ layout?: 'force' | 'circular' | 'grid' | 'radial' | 'concentric' | 'dagre';
12
+ theme?: 'default' | 'academy' | 'dark';
13
+ title?: string;
14
+ style?: {
15
+ backgroundColor?: string;
16
+ palette?: string[];
17
+ };
18
+ }
19
+ /**
20
+ * NetworkGraphInstance represents a network graph instance with render and destroy methods.
21
+ */
22
+ export interface NetworkGraphInstance {
23
+ render: (config: NetworkGraphConfig) => void;
24
+ destroy: () => void;
25
+ zoomTo: (zoom: number) => void;
26
+ getZoom: () => number | undefined;
27
+ }
28
+ /**
29
+ * NetworkGraph component using G6 5.0.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const graph = NetworkGraph({
34
+ * container: '#container',
35
+ * width: 600,
36
+ * height: 400,
37
+ * });
38
+ *
39
+ * graph.render({
40
+ * type: 'network-graph',
41
+ * data: {
42
+ * nodes: [
43
+ * { name: '哈利·波特' },
44
+ * { name: '赫敏·格兰杰' },
45
+ * { name: '伏地魔' },
46
+ * ],
47
+ * edges: [
48
+ * { source: '哈利·波特', target: '赫敏·格兰杰', name: '朋友' },
49
+ * { source: '哈利·波特', target: '伏地魔', name: '敌人' },
50
+ * ],
51
+ * },
52
+ * layout: 'force',
53
+ * theme: 'academy',
54
+ * });
55
+ *
56
+ * graph.destroy();
57
+ * ```
58
+ */
59
+ export declare const NetworkGraph: (options: VisualizationOptions) => NetworkGraphInstance;
@@ -0,0 +1,175 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vis/network-graph/index.ts
20
+ var network_graph_exports = {};
21
+ __export(network_graph_exports, {
22
+ NetworkGraph: () => NetworkGraph
23
+ });
24
+ module.exports = __toCommonJS(network_graph_exports);
25
+ var import_g6 = require("@antv/g6");
26
+ var import_theme = require("../../util/theme");
27
+ var NetworkGraph = (options) => {
28
+ const { container, width, height, theme: chartTheme = "default" } = options;
29
+ let graph = null;
30
+ const render = (config) => {
31
+ const {
32
+ data = { nodes: [], edges: [] },
33
+ layout = "force",
34
+ theme = chartTheme,
35
+ title,
36
+ style = {}
37
+ } = config;
38
+ const { nodes = [], edges = [] } = data;
39
+ if (graph) {
40
+ graph.destroy();
41
+ graph = null;
42
+ }
43
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
44
+ const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
45
+ const isDark = theme === "dark";
46
+ const containerEl = typeof container === "string" ? document.querySelector(container) : container;
47
+ if (!containerEl) {
48
+ throw new Error("NetworkGraph: container element not found");
49
+ }
50
+ containerEl.innerHTML = "";
51
+ containerEl.style.background = backgroundColor;
52
+ containerEl.style.borderRadius = "4px";
53
+ containerEl.style.overflow = "hidden";
54
+ const nodeData = nodes.map((node, index) => ({
55
+ id: node.name,
56
+ data: { label: node.name },
57
+ style: {
58
+ fill: colors[index % colors.length],
59
+ stroke: isDark ? "#444" : "#fff",
60
+ lineWidth: 2,
61
+ labelText: node.name,
62
+ labelFill: isDark ? "#e0e0e0" : "#333",
63
+ labelFontSize: 12,
64
+ size: 28
65
+ }
66
+ }));
67
+ const edgeData = edges.map((edge) => ({
68
+ source: edge.source,
69
+ target: edge.target,
70
+ data: { label: edge.name ?? "" },
71
+ style: {
72
+ stroke: isDark ? "#555" : "#ccc",
73
+ lineWidth: 1.5,
74
+ endArrow: true,
75
+ labelText: edge.name ?? "",
76
+ labelFill: isDark ? "#aaa" : "#666",
77
+ labelFontSize: 11,
78
+ labelBackground: !!edge.name,
79
+ labelBackgroundFill: backgroundColor,
80
+ labelBackgroundOpacity: 0.8
81
+ }
82
+ }));
83
+ const layoutConfig = {
84
+ force: {
85
+ type: "force",
86
+ preventOverlap: true,
87
+ nodeSize: 32,
88
+ linkDistance: 150,
89
+ gravity: 10
90
+ },
91
+ circular: {
92
+ type: "circular"
93
+ },
94
+ grid: {
95
+ type: "grid",
96
+ rows: Math.max(1, Math.ceil(Math.sqrt(nodes.length)))
97
+ },
98
+ radial: {
99
+ type: "radial",
100
+ preventOverlap: true,
101
+ nodeSize: 32
102
+ },
103
+ concentric: {
104
+ type: "concentric",
105
+ preventOverlap: true,
106
+ nodeSize: 32
107
+ },
108
+ dagre: {
109
+ type: "dagre",
110
+ rankdir: "TB",
111
+ nodesep: 50,
112
+ ranksep: 80
113
+ }
114
+ };
115
+ graph = new import_g6.Graph({
116
+ animation: false,
117
+ container: containerEl,
118
+ width,
119
+ height,
120
+ autoFit: "view",
121
+ autoResize: true,
122
+ theme: (0, import_theme.getTheme)(theme),
123
+ padding: title ? [46, 20, 20, 20] : 20,
124
+ data: {
125
+ nodes: nodeData,
126
+ edges: edgeData
127
+ },
128
+ layout: layoutConfig[layout] || layoutConfig.force,
129
+ node: {
130
+ style: {
131
+ labelPlacement: "bottom",
132
+ labelMaxWidth: 100
133
+ }
134
+ },
135
+ behaviors: ["drag-canvas", "drag-element", "click-select"],
136
+ plugins: title ? [
137
+ {
138
+ key: "title",
139
+ type: "title",
140
+ title,
141
+ titleFill: isDark ? "#e0e6ed" : "#000",
142
+ titleFontFamily: "sans-serif"
143
+ }
144
+ ] : []
145
+ });
146
+ graph.render();
147
+ };
148
+ const destroy = () => {
149
+ if (graph) {
150
+ graph.destroy();
151
+ graph = null;
152
+ }
153
+ };
154
+ const zoomTo = (zoom) => {
155
+ if (graph) {
156
+ graph.zoomTo(zoom);
157
+ }
158
+ };
159
+ const getZoom = () => {
160
+ if (graph) {
161
+ return graph.getZoom();
162
+ }
163
+ return 1;
164
+ };
165
+ return {
166
+ render,
167
+ destroy,
168
+ zoomTo,
169
+ getZoom
170
+ };
171
+ };
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ NetworkGraph
175
+ });
@@ -0,0 +1,64 @@
1
+ import type { TreeGraphData, VisualizationOptions } from '../../types';
2
+ export type OrganizationChartData = TreeGraphData;
3
+ /**
4
+ * OrganizationChartConfig defines the configuration for rendering the organization chart.
5
+ */
6
+ export interface OrganizationChartConfig {
7
+ type?: 'organization-chart';
8
+ data: OrganizationChartData;
9
+ theme?: 'default' | 'academy' | 'dark';
10
+ title?: string;
11
+ style?: {
12
+ backgroundColor?: string;
13
+ palette?: string[];
14
+ };
15
+ }
16
+ /**
17
+ * OrganizationChartInstance represents a chart instance with render and destroy methods.
18
+ */
19
+ export interface OrganizationChartInstance {
20
+ render: (config: OrganizationChartConfig) => void;
21
+ destroy: () => void;
22
+ zoomTo: (zoom: number) => void;
23
+ getZoom: () => number | undefined;
24
+ }
25
+ /**
26
+ * OrganizationChart component using G6 5.0.
27
+ * - dagre (TB) layout for hierarchical structure
28
+ * - custom rect node with name + description labels
29
+ * - depth-based color cycling
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const chart = OrganizationChart({ container: '#container', width: 600, height: 400 });
34
+ *
35
+ * chart.render({
36
+ * type: 'organization-chart',
37
+ * data: {
38
+ * name: 'Alice Johnson',
39
+ * description: 'Chief Technology Officer',
40
+ * children: [
41
+ * {
42
+ * name: 'Bob Smith',
43
+ * description: 'Senior Software Engineer',
44
+ * children: [
45
+ * { name: 'Charlie Brown', description: 'Software Engineer' },
46
+ * { name: 'Diana White', description: 'Software Engineer' },
47
+ * ],
48
+ * },
49
+ * {
50
+ * name: 'Eve Black',
51
+ * description: 'IT Support Department Head',
52
+ * children: [
53
+ * { name: 'Frank Green', description: 'IT Support Specialist' },
54
+ * { name: 'Grace Blue', description: 'IT Support Specialist' },
55
+ * ],
56
+ * },
57
+ * ],
58
+ * },
59
+ * });
60
+ *
61
+ * chart.destroy();
62
+ * ```
63
+ */
64
+ export declare const OrganizationChart: (options: VisualizationOptions) => OrganizationChartInstance;
@@ -0,0 +1,200 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vis/organization-chart/index.ts
20
+ var organization_chart_exports = {};
21
+ __export(organization_chart_exports, {
22
+ OrganizationChart: () => OrganizationChart
23
+ });
24
+ module.exports = __toCommonJS(organization_chart_exports);
25
+ var import_g6 = require("@antv/g6");
26
+ var import_theme = require("../../util/theme");
27
+ var NODE_WIDTH = 160;
28
+ var NODE_HEIGHT_WITH_DESC = 72;
29
+ var NODE_HEIGHT_NO_DESC = 40;
30
+ var FONT_FAMILY = "system-ui,-apple-system,BlinkMacSystemFont,sans-serif";
31
+ var LABEL_MAX_WIDTH = NODE_WIDTH - 16;
32
+ function flattenTree(node, depth, pathId, nodes, edges) {
33
+ nodes.push({ id: pathId, name: node.name, description: node.description, depth });
34
+ (node.children ?? []).forEach((child, index) => {
35
+ const childId = `${pathId}_${index}`;
36
+ edges.push({ source: pathId, target: childId });
37
+ flattenTree(child, depth + 1, childId, nodes, edges);
38
+ });
39
+ }
40
+ var OrganizationChart = (options) => {
41
+ const { container, width, height, theme: chartTheme = "default" } = options;
42
+ let graph = null;
43
+ const render = (config) => {
44
+ const { data, theme = chartTheme, title, style = {} } = config;
45
+ if (!data || !data.name) {
46
+ throw new Error("OrganizationChart: data with a name field is required");
47
+ }
48
+ if (graph) {
49
+ graph.destroy();
50
+ graph = null;
51
+ }
52
+ const containerEl = typeof container === "string" ? document.querySelector(container) : container;
53
+ if (!containerEl) {
54
+ throw new Error("OrganizationChart: container element not found");
55
+ }
56
+ containerEl.innerHTML = "";
57
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
58
+ const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
59
+ const isDark = theme === "dark";
60
+ containerEl.style.background = backgroundColor;
61
+ containerEl.style.borderRadius = "4px";
62
+ containerEl.style.overflow = "hidden";
63
+ const flatNodes = [];
64
+ const flatEdges = [];
65
+ flattenTree(data, 0, "0", flatNodes, flatEdges);
66
+ const nodeData = flatNodes.map((node) => ({
67
+ id: node.id,
68
+ data: {
69
+ name: node.name,
70
+ description: node.description,
71
+ depth: node.depth
72
+ }
73
+ }));
74
+ const edgeData = flatEdges.map((edge) => ({
75
+ id: `e__${edge.source}__${edge.target}`,
76
+ source: edge.source,
77
+ target: edge.target
78
+ }));
79
+ graph = new import_g6.Graph({
80
+ animation: false,
81
+ container: containerEl,
82
+ width,
83
+ height,
84
+ autoFit: "view",
85
+ autoResize: true,
86
+ theme: (0, import_theme.getTheme)(theme),
87
+ padding: title ? [46, 20, 20, 20] : 20,
88
+ data: { nodes: nodeData, edges: edgeData },
89
+ plugins: [
90
+ {
91
+ type: "tooltip",
92
+ trigger: "hover",
93
+ enable: (e) => (e == null ? void 0 : e.targetType) === "node",
94
+ offset: [10, 10],
95
+ getContent: (e, items) => {
96
+ const item = items == null ? void 0 : items[0];
97
+ const biz = item == null ? void 0 : item.data;
98
+ if (!biz)
99
+ return "";
100
+ const name = escapeHtml(String(biz.name ?? ""));
101
+ const desc = biz.description ? escapeHtml(String(biz.description)) : "";
102
+ return `
103
+ <div style="max-width:260px;font-family:${FONT_FAMILY};">
104
+ <div style="font-weight:700;font-size:12px;line-height:1.2;margin-bottom:${desc ? "4px" : "0"};">
105
+ ${name}
106
+ </div>
107
+ ${desc ? `<div style="font-size:12px;line-height:1.35;opacity:${isDark ? "0.86" : "0.78"};">${desc}</div>` : ""}
108
+ </div>
109
+ `;
110
+ },
111
+ style: {
112
+ ".tooltip": {
113
+ background: isDark ? "rgba(20,20,20,0.92)" : "rgba(255,255,255,0.96)",
114
+ color: isDark ? "#f2f2f2" : "#1f1f1f",
115
+ border: `1px solid ${isDark ? "rgba(255,255,255,0.12)" : "rgba(0,0,0,0.10)"}`,
116
+ borderRadius: 8,
117
+ boxShadow: "0 12px 28px rgba(0,0,0,0.16)",
118
+ padding: "8px 10px",
119
+ pointerEvents: "none"
120
+ }
121
+ }
122
+ },
123
+ ...title ? [
124
+ {
125
+ key: "title",
126
+ type: "title",
127
+ title,
128
+ titleFill: isDark ? "#e0e6ed" : "#000",
129
+ titleFontFamily: "sans-serif"
130
+ }
131
+ ] : []
132
+ ],
133
+ node: {
134
+ type: "rect",
135
+ style: {
136
+ // size: [width, height] is the correct API for rect nodes in G6 v5
137
+ size: (d) => [
138
+ NODE_WIDTH,
139
+ d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC
140
+ ],
141
+ fill: (d) => colors[d.data.depth % colors.length],
142
+ stroke: isDark ? "#555" : "#e8ebf0",
143
+ lineWidth: 1,
144
+ radius: theme === "academy" ? 0 : 8,
145
+ // Use official label wrapping/ellipsis for BOTH name & description.
146
+ // 1 line name + up to 2 lines description => total maxLines = 3.
147
+ labelText: (d) => d.data.description ? `${d.data.name}
148
+ ${d.data.description}` : d.data.name,
149
+ labelFill: "#ffffff",
150
+ labelFontSize: 12,
151
+ labelFontWeight: 600,
152
+ labelWordWrap: true,
153
+ labelWordWrapWidth: LABEL_MAX_WIDTH,
154
+ labelMaxLines: (d) => d.data.description ? 3 : 1,
155
+ labelLineHeight: 14,
156
+ labelPlacement: "center"
157
+ }
158
+ },
159
+ edge: {
160
+ // Use a tree-friendly edge type that does not depend on node ports.
161
+ type: "cubic-vertical",
162
+ style: {
163
+ stroke: isDark ? "#4a4a4a" : "#d0d7e0",
164
+ lineWidth: 1.5,
165
+ endArrow: false,
166
+ startArrow: false
167
+ }
168
+ },
169
+ layout: {
170
+ type: "dagre",
171
+ rankdir: "TB",
172
+ nodesep: 40,
173
+ ranksep: 60,
174
+ // Dynamic nodeSize lets dagre calculate accurate per-node spacing
175
+ nodeSize: (d) => [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC]
176
+ },
177
+ behaviors: ["drag-canvas"]
178
+ });
179
+ graph.render();
180
+ };
181
+ const destroy = () => {
182
+ if (graph) {
183
+ graph.destroy();
184
+ graph = null;
185
+ }
186
+ };
187
+ return {
188
+ render,
189
+ destroy,
190
+ zoomTo: (zoom) => graph == null ? void 0 : graph.zoomTo(zoom),
191
+ getZoom: () => graph == null ? void 0 : graph.getZoom()
192
+ };
193
+ };
194
+ function escapeHtml(input) {
195
+ return String(input).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#039;");
196
+ }
197
+ // Annotate the CommonJS export names for ESM import in node:
198
+ 0 && (module.exports = {
199
+ OrganizationChart
200
+ });
@@ -33,7 +33,7 @@ var Pie = (options) => {
33
33
  if (chart) {
34
34
  chart.destroy();
35
35
  }
36
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
36
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
37
37
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
38
38
  const sumValue = data.reduce((sum, item) => sum + item.value, 0);
39
39
  chart = new import_g2.Chart({
@@ -43,6 +43,7 @@ var Pie = (options) => {
43
43
  autoFit: true
44
44
  });
45
45
  const chartOptions = {
46
+ animate: false,
46
47
  type: "interval",
47
48
  data,
48
49
  title: title ?? "",
@@ -85,8 +86,7 @@ var Pie = (options) => {
85
86
  viewStyle: {
86
87
  viewFill: backgroundColor
87
88
  },
88
- theme: (0, import_theme.getThemeObject)(theme),
89
- animate: { enter: { type: "waveIn" } }
89
+ theme: (0, import_theme.getThemeObject)(theme)
90
90
  };
91
91
  chart.options(chartOptions);
92
92
  chart.render();
@@ -14,6 +14,7 @@ export interface RadarConfig {
14
14
  type?: 'radar';
15
15
  data: RadarDataItem[];
16
16
  title?: string;
17
+ align?: boolean;
17
18
  theme?: 'default' | 'academy' | 'dark';
18
19
  style?: {
19
20
  backgroundColor?: string;
@@ -51,12 +51,12 @@ var Radar = (options) => {
51
51
  const { container, width, height, theme: chartTheme = "default" } = options;
52
52
  let chart = null;
53
53
  const render = (config) => {
54
- const { data = [], theme = chartTheme, title, style = {} } = config;
54
+ const { data = [], theme = chartTheme, title, align = false, style = {} } = config;
55
55
  if (chart) {
56
56
  chart.destroy();
57
57
  }
58
58
  const { lineWidth = 2 } = style;
59
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
59
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
60
60
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
61
61
  const parallelData = transformRadarToParallel(data);
62
62
  const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
@@ -67,6 +67,7 @@ var Radar = (options) => {
67
67
  autoFit: true
68
68
  });
69
69
  const chartOptions = {
70
+ animate: false,
70
71
  type: "line",
71
72
  data: parallelData,
72
73
  title: title ?? "",
@@ -77,15 +78,15 @@ var Radar = (options) => {
77
78
  color: "group"
78
79
  },
79
80
  scale: {
80
- // Configure scales for each position axis
81
81
  ...Object.fromEntries(
82
- Array.from({ length: position.length }, (_, i) => [
83
- `position${i === 0 ? "" : i}`,
84
- {
85
- domainMin: 0,
86
- nice: true
82
+ Array.from({ length: position.length }, (_, i) => {
83
+ const scaleConfig = { domainMin: 0, nice: true };
84
+ if (align) {
85
+ const allValues = data.map((d) => d.value).filter((v) => v != null);
86
+ scaleConfig.domainMax = Math.max(...allValues);
87
87
  }
88
- ])
88
+ return [`position${i === 0 ? "" : i}`, scaleConfig];
89
+ })
89
90
  ),
90
91
  color: {
91
92
  range: colors
@@ -32,7 +32,7 @@ var Sankey = (options) => {
32
32
  if (chart) {
33
33
  chart.destroy();
34
34
  }
35
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
35
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
36
36
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
37
37
  chart = new import_g2.Chart({
38
38
  container,
@@ -41,6 +41,7 @@ var Sankey = (options) => {
41
41
  autoFit: true
42
42
  });
43
43
  const chartOptions = {
44
+ animate: false,
44
45
  type: "sankey",
45
46
  data: {
46
47
  value: data,
@@ -14,6 +14,8 @@ export interface ScatterConfig {
14
14
  type?: 'scatter';
15
15
  data: ScatterDataItem[];
16
16
  title?: string;
17
+ axisXTitle?: string;
18
+ axisYTitle?: string;
17
19
  theme?: 'default' | 'academy' | 'dark';
18
20
  style?: {
19
21
  backgroundColor?: string;
@@ -29,11 +29,11 @@ var Scatter = (options) => {
29
29
  let chart = null;
30
30
  const render = (config) => {
31
31
  var _a;
32
- const { data = [], theme = chartTheme, title, style = {} } = config;
32
+ const { data = [], theme = chartTheme, title, axisXTitle, axisYTitle, style = {} } = config;
33
33
  if (chart) {
34
34
  chart.destroy();
35
35
  }
36
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
36
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
37
37
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
38
38
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
39
39
  chart = new import_g2.Chart({
@@ -53,20 +53,25 @@ var Scatter = (options) => {
53
53
  encode = { x: "x", y: "y", color: () => "all" };
54
54
  }
55
55
  const chartOptions = {
56
+ animate: false,
56
57
  type: "point",
57
58
  data,
58
59
  title: title ?? "",
59
60
  encode,
60
61
  legend: hasGroupField ? { color: { position: "top" } } : false,
61
62
  scale: scaleConfig,
63
+ axis: {
64
+ x: { title: axisXTitle ?? "x" },
65
+ y: { title: axisYTitle ?? "y" }
66
+ },
62
67
  style: {
63
68
  lineWidth: 1
64
69
  },
65
70
  tooltip: {
66
71
  title: (d) => (d == null ? void 0 : d.group) ? d.group : false,
67
72
  items: [
68
- { channel: "x", name: "x" },
69
- { channel: "y", name: "y" }
73
+ { channel: "x", name: axisXTitle ?? "x" },
74
+ { channel: "y", name: axisYTitle ?? "y" }
70
75
  ]
71
76
  },
72
77
  viewStyle: {