@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.
- package/README.md +53 -7
- package/README.zh-CN.md +32 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/presets.d.ts +5 -0
- package/dist/cjs/theme/presets.js +663 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +59 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +109 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/cjs/util/crosshair-axis-labels.js +17 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +9 -6
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +70 -52
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -5
- package/dist/cjs/vis/funnel/index.js +63 -42
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +46 -4
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/presets.d.ts +5 -0
- package/dist/esm/theme/presets.js +1070 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +31 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +109 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/esm/util/crosshair-axis-labels.js +18 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +9 -6
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +68 -58
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -5
- package/dist/esm/vis/funnel/index.js +63 -54
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +41 -4
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -23,20 +23,25 @@ __export(liquid_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(liquid_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
27
|
+
var import_tokens = require("../../util/tokens");
|
|
27
28
|
var DEFAULT_WIDTH = 640;
|
|
28
29
|
var DEFAULT_HEIGHT = 480;
|
|
29
30
|
var Liquid = (options) => {
|
|
30
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
31
32
|
let chart = null;
|
|
32
33
|
const render = (config) => {
|
|
33
|
-
const { percent, shape
|
|
34
|
+
const { percent, shape, theme = chartTheme, title, subtitle, style: localStyle = {} } = config;
|
|
34
35
|
if (chart) {
|
|
35
36
|
chart.destroy();
|
|
36
37
|
}
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const appearance = (0, import_g22.getThemeObject)("liquid", theme, localStyle);
|
|
39
|
+
const { theme: rendererTheme } = appearance;
|
|
40
|
+
const baseTheme = rendererTheme.type;
|
|
41
|
+
const liquidStyle = appearance.mark.liquid;
|
|
42
|
+
const resolvedShape = shape ?? liquidStyle.shape ?? "circle";
|
|
43
|
+
const colors = rendererTheme.category10;
|
|
44
|
+
const backgroundColor = rendererTheme.view.viewFill;
|
|
40
45
|
const normalizedPercent = Number.isFinite(percent) ? Math.max(0, Math.min(1, percent)) : 0;
|
|
41
46
|
const inferFontSize = Math.min(width ?? DEFAULT_WIDTH, height ?? DEFAULT_HEIGHT) / 10;
|
|
42
47
|
const fontSize = Math.min(Math.max(inferFontSize, 24), 64);
|
|
@@ -44,8 +49,8 @@ var Liquid = (options) => {
|
|
|
44
49
|
const waveLength = Math.min(Math.max(chartSize * 0.4, 96), 192);
|
|
45
50
|
const formattedPercent = `${Number((normalizedPercent * 100).toFixed(1))}%`;
|
|
46
51
|
const liquidColor = colors[0];
|
|
47
|
-
const isAcademy =
|
|
48
|
-
const outlineShadowColor =
|
|
52
|
+
const isAcademy = baseTheme === "academy";
|
|
53
|
+
const outlineShadowColor = baseTheme === "dark" ? "rgba(0, 0, 0, 0.32)" : "rgba(15, 23, 42, 0.10)";
|
|
49
54
|
chart = new import_g2.Chart({
|
|
50
55
|
container,
|
|
51
56
|
width,
|
|
@@ -56,25 +61,24 @@ var Liquid = (options) => {
|
|
|
56
61
|
animate: false,
|
|
57
62
|
type: "liquid",
|
|
58
63
|
data: normalizedPercent,
|
|
59
|
-
title: title
|
|
64
|
+
title: title ? { title, subtitle } : "",
|
|
60
65
|
inset: 20,
|
|
61
66
|
style: {
|
|
62
|
-
shape,
|
|
63
67
|
contentText: formattedPercent,
|
|
64
68
|
contentFontSize: fontSize,
|
|
65
|
-
contentFill:
|
|
69
|
+
contentFill: rendererTheme.label.fill,
|
|
66
70
|
contentStroke: backgroundColor,
|
|
67
71
|
contentStrokeOpacity: 0.92,
|
|
68
|
-
contentLineWidth:
|
|
69
|
-
contentFontFamily:
|
|
72
|
+
contentLineWidth: baseTheme === "dark" ? 3 : 2.5,
|
|
73
|
+
contentFontFamily: import_tokens.CHART_FONT_FAMILY,
|
|
70
74
|
contentFontWeight: 600,
|
|
71
75
|
contentLetterSpacing: -0.8,
|
|
72
76
|
contentFontVariantNumeric: "tabular-nums",
|
|
73
77
|
contentPaintOrder: "stroke",
|
|
74
78
|
backgroundFill: liquidColor,
|
|
75
|
-
backgroundFillOpacity:
|
|
79
|
+
backgroundFillOpacity: baseTheme === "dark" ? 0.14 : isAcademy ? 0.06 : 0.08,
|
|
76
80
|
backgroundStroke: liquidColor,
|
|
77
|
-
backgroundStrokeOpacity:
|
|
81
|
+
backgroundStrokeOpacity: baseTheme === "dark" ? 0.3 : 0.22,
|
|
78
82
|
backgroundLineWidth: 1,
|
|
79
83
|
outlineBorder: isAcademy ? 1.5 : 2,
|
|
80
84
|
outlineDistance: 0,
|
|
@@ -87,10 +91,11 @@ var Liquid = (options) => {
|
|
|
87
91
|
fillOpacity: isAcademy ? 0.9 : 0.88,
|
|
88
92
|
contentPointerEvents: "none",
|
|
89
93
|
// Use palette color if provided
|
|
90
|
-
...liquidColor ? { fill: liquidColor, outlineStroke: liquidColor } : {}
|
|
94
|
+
...liquidColor ? { fill: liquidColor, outlineStroke: liquidColor } : {},
|
|
95
|
+
...liquidStyle,
|
|
96
|
+
shape: resolvedShape
|
|
91
97
|
},
|
|
92
|
-
|
|
93
|
-
theme: (0, import_util.getThemeObject)(theme),
|
|
98
|
+
theme: rendererTheme,
|
|
94
99
|
tooltip: false
|
|
95
100
|
};
|
|
96
101
|
chart.options(chartOptions);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TreeGraphData, VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, TreeGraphData, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
export type MindmapData = TreeGraphData;
|
|
3
3
|
/**
|
|
4
4
|
* MindmapConfig defines the configuration for rendering the mindmap.
|
|
@@ -7,12 +7,10 @@ export interface MindmapConfig {
|
|
|
7
7
|
type?: 'mindmap';
|
|
8
8
|
data: MindmapData;
|
|
9
9
|
direction?: 'H' | 'LR' | 'RL';
|
|
10
|
-
theme?:
|
|
10
|
+
theme?: VisualizationTheme;
|
|
11
11
|
title?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
palette?: string[];
|
|
15
|
-
};
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
style?: ThemeStyle;
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
16
|
* MindmapInstance represents a mindmap instance with render and destroy methods.
|
|
@@ -23,7 +23,8 @@ __export(mindmap_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(mindmap_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
|
-
var
|
|
26
|
+
var import_g62 = require("../../theme/g6");
|
|
27
|
+
var import_components = require("../../util/components");
|
|
27
28
|
function toG6TreeData(node) {
|
|
28
29
|
return {
|
|
29
30
|
id: node.name,
|
|
@@ -78,7 +79,14 @@ var Mindmap = (options) => {
|
|
|
78
79
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
79
80
|
let graph = null;
|
|
80
81
|
const render = (config) => {
|
|
81
|
-
const {
|
|
82
|
+
const {
|
|
83
|
+
data,
|
|
84
|
+
direction = "H",
|
|
85
|
+
theme = chartTheme,
|
|
86
|
+
title,
|
|
87
|
+
subtitle,
|
|
88
|
+
style: localStyle = {}
|
|
89
|
+
} = config;
|
|
82
90
|
if (!data || !data.name) {
|
|
83
91
|
throw new Error("Mindmap: data with a name field is required");
|
|
84
92
|
}
|
|
@@ -91,18 +99,27 @@ var Mindmap = (options) => {
|
|
|
91
99
|
throw new Error("Mindmap: container element not found");
|
|
92
100
|
}
|
|
93
101
|
containerEl.innerHTML = "";
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
102
|
+
const appearance = (0, import_g62.getThemeObject)("mindmap", theme, localStyle);
|
|
103
|
+
const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
104
|
+
const { theme: rendererTheme } = appearance;
|
|
105
|
+
const baseTheme = appearance.baseTheme;
|
|
106
|
+
const colors = appearance.colors;
|
|
107
|
+
const backgroundColor = appearance.backgroundColor;
|
|
108
|
+
const isDark = baseTheme === "dark";
|
|
109
|
+
const nodeTheme = appearance.node.style;
|
|
110
|
+
const edgeTheme = appearance.edge.style;
|
|
97
111
|
containerEl.style.background = backgroundColor;
|
|
98
112
|
const graphData = convertTreeData(data);
|
|
99
113
|
assignBranchColors(graphData, colors);
|
|
100
114
|
for (const node of graphData.nodes || []) {
|
|
101
115
|
const label = String(node.id);
|
|
102
116
|
const depth = node.depth ?? 0;
|
|
103
|
-
const fontSize = depth === 0 ? 24 : 16;
|
|
117
|
+
const fontSize = nodeTheme.labelFontSize ?? (depth === 0 ? 24 : 16);
|
|
104
118
|
const pad = depth === 0 ? 64 : 36;
|
|
105
|
-
node.layoutSize = [
|
|
119
|
+
node.layoutSize = [
|
|
120
|
+
estimateNodeWidth(label, fontSize, pad),
|
|
121
|
+
Math.max(depth === 0 ? 60 : 48, Math.ceil(fontSize * 1.2) + 16)
|
|
122
|
+
];
|
|
106
123
|
}
|
|
107
124
|
graph = new import_g6.Graph({
|
|
108
125
|
animation: false,
|
|
@@ -111,20 +128,12 @@ var Mindmap = (options) => {
|
|
|
111
128
|
height,
|
|
112
129
|
autoFit: "view",
|
|
113
130
|
autoResize: true,
|
|
114
|
-
padding:
|
|
131
|
+
padding: graphTitle.padding,
|
|
115
132
|
zoomRange: [0.1, 5],
|
|
116
133
|
zoom: 1,
|
|
117
|
-
theme:
|
|
134
|
+
theme: rendererTheme,
|
|
118
135
|
data: graphData,
|
|
119
|
-
plugins:
|
|
120
|
-
{
|
|
121
|
-
key: "title",
|
|
122
|
-
type: "title",
|
|
123
|
-
title,
|
|
124
|
-
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
125
|
-
titleFontFamily: "sans-serif"
|
|
126
|
-
}
|
|
127
|
-
] : [],
|
|
136
|
+
plugins: graphTitle.plugins,
|
|
128
137
|
node: {
|
|
129
138
|
type: "rect",
|
|
130
139
|
animation: { translate: false, update: false },
|
|
@@ -140,27 +149,33 @@ var Mindmap = (options) => {
|
|
|
140
149
|
const fontWeight = depth <= 1 ? 600 : 400;
|
|
141
150
|
const dx = side === "left" ? -nodeWidth : side === "center" ? -nodeWidth / 2 : 0;
|
|
142
151
|
const base = {
|
|
152
|
+
radius: baseTheme === "academy" ? 0 : 8,
|
|
153
|
+
labelFontSize: fontSize,
|
|
154
|
+
labelFontWeight: fontWeight
|
|
155
|
+
};
|
|
156
|
+
const structuralStyle = {
|
|
143
157
|
size: [nodeWidth, nodeHeight],
|
|
144
158
|
dx,
|
|
145
|
-
radius: theme === "academy" ? 0 : 8,
|
|
146
159
|
labelText: label,
|
|
147
160
|
labelPlacement: "center",
|
|
148
|
-
labelFontSize: fontSize,
|
|
149
|
-
labelFontWeight: fontWeight,
|
|
150
161
|
ports: [{ placement: "left" }, { placement: "right" }]
|
|
151
162
|
};
|
|
152
163
|
if (depth === 0) {
|
|
153
164
|
return {
|
|
154
165
|
...base,
|
|
155
166
|
fill: isDark ? "#333" : "#f1f4f5",
|
|
156
|
-
labelFill: isDark ? "#e0e0e0" : "#252525"
|
|
167
|
+
labelFill: isDark ? "#e0e0e0" : "#252525",
|
|
168
|
+
...nodeTheme,
|
|
169
|
+
...structuralStyle
|
|
157
170
|
};
|
|
158
171
|
}
|
|
159
172
|
if (depth === 1) {
|
|
160
173
|
return {
|
|
161
174
|
...base,
|
|
162
175
|
fill: color || "#99ADD1",
|
|
163
|
-
labelFill: "#fff"
|
|
176
|
+
labelFill: "#fff",
|
|
177
|
+
...nodeTheme,
|
|
178
|
+
...structuralStyle
|
|
164
179
|
};
|
|
165
180
|
}
|
|
166
181
|
return {
|
|
@@ -168,7 +183,9 @@ var Mindmap = (options) => {
|
|
|
168
183
|
fill: backgroundColor,
|
|
169
184
|
stroke: color || (isDark ? "#555" : "#99ADD1"),
|
|
170
185
|
lineWidth: 3,
|
|
171
|
-
labelFill: isDark ? color || "#ccc" : color || "#333"
|
|
186
|
+
labelFill: isDark ? color || "#ccc" : color || "#333",
|
|
187
|
+
...nodeTheme,
|
|
188
|
+
...structuralStyle
|
|
172
189
|
};
|
|
173
190
|
}
|
|
174
191
|
},
|
|
@@ -181,7 +198,8 @@ var Mindmap = (options) => {
|
|
|
181
198
|
var _a;
|
|
182
199
|
const sourceNode = this.getNodeData(edgeData.source);
|
|
183
200
|
return ((_a = sourceNode == null ? void 0 : sourceNode.style) == null ? void 0 : _a.color) || (isDark ? "#555" : "#99ADD1");
|
|
184
|
-
}
|
|
201
|
+
},
|
|
202
|
+
...edgeTheme
|
|
185
203
|
}
|
|
186
204
|
},
|
|
187
205
|
layout: {
|
|
@@ -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?:
|
|
12
|
+
theme?: VisualizationTheme;
|
|
13
13
|
title?: string;
|
|
14
|
-
|
|
15
|
-
|
|
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.
|
|
@@ -23,7 +23,8 @@ __export(network_graph_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(network_graph_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
|
-
var
|
|
26
|
+
var import_g62 = require("../../theme/g6");
|
|
27
|
+
var import_components = require("../../util/components");
|
|
27
28
|
var NetworkGraph = (options) => {
|
|
28
29
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
30
|
let graph = null;
|
|
@@ -33,16 +34,23 @@ var NetworkGraph = (options) => {
|
|
|
33
34
|
layout = "force",
|
|
34
35
|
theme = chartTheme,
|
|
35
36
|
title,
|
|
36
|
-
|
|
37
|
+
subtitle,
|
|
38
|
+
style: localStyle = {}
|
|
37
39
|
} = config;
|
|
38
40
|
const { nodes = [], edges = [] } = data;
|
|
39
41
|
if (graph) {
|
|
40
42
|
graph.destroy();
|
|
41
43
|
graph = null;
|
|
42
44
|
}
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
45
|
+
const appearance = (0, import_g62.getThemeObject)("network-graph", theme, localStyle);
|
|
46
|
+
const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
47
|
+
const { theme: rendererTheme } = appearance;
|
|
48
|
+
const baseTheme = appearance.baseTheme;
|
|
49
|
+
const colors = appearance.colors;
|
|
50
|
+
const backgroundColor = appearance.backgroundColor;
|
|
51
|
+
const isDark = baseTheme === "dark";
|
|
52
|
+
const nodeTheme = appearance.node;
|
|
53
|
+
const edgeTheme = appearance.edge;
|
|
46
54
|
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
47
55
|
if (!containerEl) {
|
|
48
56
|
throw new Error("NetworkGraph: container element not found");
|
|
@@ -58,10 +66,11 @@ var NetworkGraph = (options) => {
|
|
|
58
66
|
fill: colors[index % colors.length],
|
|
59
67
|
stroke: isDark ? "#444" : "#fff",
|
|
60
68
|
lineWidth: 2,
|
|
61
|
-
labelText: node.name,
|
|
62
69
|
labelFill: isDark ? "#e0e0e0" : "#333",
|
|
63
70
|
labelFontSize: 12,
|
|
64
|
-
|
|
71
|
+
...nodeTheme.style,
|
|
72
|
+
size: 28,
|
|
73
|
+
labelText: node.name
|
|
65
74
|
}
|
|
66
75
|
}));
|
|
67
76
|
const edgeData = edges.map((edge) => ({
|
|
@@ -72,12 +81,13 @@ var NetworkGraph = (options) => {
|
|
|
72
81
|
stroke: isDark ? "#555" : "#ccc",
|
|
73
82
|
lineWidth: 1.5,
|
|
74
83
|
endArrow: true,
|
|
75
|
-
labelText: edge.name ?? "",
|
|
76
84
|
labelFill: isDark ? "#aaa" : "#666",
|
|
77
85
|
labelFontSize: 11,
|
|
78
86
|
labelBackground: !!edge.name,
|
|
79
87
|
labelBackgroundFill: backgroundColor,
|
|
80
|
-
labelBackgroundOpacity: 0.8
|
|
88
|
+
labelBackgroundOpacity: 0.8,
|
|
89
|
+
...edgeTheme.style,
|
|
90
|
+
labelText: edge.name ?? ""
|
|
81
91
|
}
|
|
82
92
|
}));
|
|
83
93
|
const layoutConfig = {
|
|
@@ -119,29 +129,25 @@ var NetworkGraph = (options) => {
|
|
|
119
129
|
height,
|
|
120
130
|
autoFit: "view",
|
|
121
131
|
autoResize: true,
|
|
122
|
-
theme:
|
|
123
|
-
padding:
|
|
132
|
+
theme: rendererTheme,
|
|
133
|
+
padding: graphTitle.padding,
|
|
124
134
|
data: {
|
|
125
135
|
nodes: nodeData,
|
|
126
136
|
edges: edgeData
|
|
127
137
|
},
|
|
128
138
|
layout: layoutConfig[layout] || layoutConfig.force,
|
|
129
139
|
node: {
|
|
140
|
+
type: nodeTheme.type ?? "circle",
|
|
130
141
|
style: {
|
|
131
142
|
labelPlacement: "bottom",
|
|
132
143
|
labelMaxWidth: 100
|
|
133
144
|
}
|
|
134
145
|
},
|
|
146
|
+
edge: {
|
|
147
|
+
type: edgeTheme.type ?? "line"
|
|
148
|
+
},
|
|
135
149
|
behaviors: ["drag-canvas", "drag-element", "click-select"],
|
|
136
|
-
plugins:
|
|
137
|
-
{
|
|
138
|
-
key: "title",
|
|
139
|
-
type: "title",
|
|
140
|
-
title,
|
|
141
|
-
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
142
|
-
titleFontFamily: "sans-serif"
|
|
143
|
-
}
|
|
144
|
-
] : []
|
|
150
|
+
plugins: graphTitle.plugins
|
|
145
151
|
});
|
|
146
152
|
graph.render();
|
|
147
153
|
};
|
|
@@ -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?:
|
|
9
|
+
theme?: VisualizationTheme;
|
|
10
10
|
title?: string;
|
|
11
|
-
|
|
12
|
-
|
|
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.
|
|
@@ -23,7 +23,8 @@ __export(organization_chart_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(organization_chart_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
|
-
var
|
|
26
|
+
var import_g62 = require("../../theme/g6");
|
|
27
|
+
var import_components = require("../../util/components");
|
|
27
28
|
var NODE_WIDTH = 160;
|
|
28
29
|
var NODE_HEIGHT_WITH_DESC = 72;
|
|
29
30
|
var NODE_HEIGHT_NO_DESC = 40;
|
|
@@ -41,7 +42,7 @@ var OrganizationChart = (options) => {
|
|
|
41
42
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
42
43
|
let graph = null;
|
|
43
44
|
const render = (config) => {
|
|
44
|
-
const { data, theme = chartTheme, title, style = {} } = config;
|
|
45
|
+
const { data, theme = chartTheme, title, subtitle, style: localStyle = {} } = config;
|
|
45
46
|
if (!data || !data.name) {
|
|
46
47
|
throw new Error("OrganizationChart: data with a name field is required");
|
|
47
48
|
}
|
|
@@ -54,9 +55,20 @@ var OrganizationChart = (options) => {
|
|
|
54
55
|
throw new Error("OrganizationChart: container element not found");
|
|
55
56
|
}
|
|
56
57
|
containerEl.innerHTML = "";
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
58
|
+
const appearance = (0, import_g62.getThemeObject)("organization-chart", theme, localStyle);
|
|
59
|
+
const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
60
|
+
const { theme: rendererTheme } = appearance;
|
|
61
|
+
const baseTheme = appearance.baseTheme;
|
|
62
|
+
const colors = appearance.colors;
|
|
63
|
+
const backgroundColor = appearance.backgroundColor;
|
|
64
|
+
const isDark = baseTheme === "dark";
|
|
65
|
+
const nodeTheme = appearance.node.style;
|
|
66
|
+
const edgeTheme = appearance.edge.style;
|
|
67
|
+
const labelLineHeight = nodeTheme.labelFontSize === void 0 ? 14 : Math.ceil(nodeTheme.labelFontSize * 1.2);
|
|
68
|
+
const getNodeSize = (d) => [
|
|
69
|
+
NODE_WIDTH,
|
|
70
|
+
d.data.description ? Math.max(NODE_HEIGHT_WITH_DESC, labelLineHeight * 3 + 16) : Math.max(NODE_HEIGHT_NO_DESC, labelLineHeight + 16)
|
|
71
|
+
];
|
|
60
72
|
containerEl.style.background = backgroundColor;
|
|
61
73
|
containerEl.style.borderRadius = "4px";
|
|
62
74
|
containerEl.style.overflow = "hidden";
|
|
@@ -83,8 +95,8 @@ var OrganizationChart = (options) => {
|
|
|
83
95
|
height,
|
|
84
96
|
autoFit: "view",
|
|
85
97
|
autoResize: true,
|
|
86
|
-
theme:
|
|
87
|
-
padding:
|
|
98
|
+
theme: rendererTheme,
|
|
99
|
+
padding: graphTitle.padding,
|
|
88
100
|
data: { nodes: nodeData, edges: edgeData },
|
|
89
101
|
plugins: [
|
|
90
102
|
{
|
|
@@ -100,11 +112,11 @@ var OrganizationChart = (options) => {
|
|
|
100
112
|
const name = escapeHtml(String(biz.name ?? ""));
|
|
101
113
|
const desc = biz.description ? escapeHtml(String(biz.description)) : "";
|
|
102
114
|
return `
|
|
103
|
-
<div style="max-width:260px;
|
|
104
|
-
<div style="font-weight:700;
|
|
115
|
+
<div style="max-width:260px;">
|
|
116
|
+
<div style="font-weight:700;margin-bottom:${desc ? "4px" : "0"};">
|
|
105
117
|
${name}
|
|
106
118
|
</div>
|
|
107
|
-
${desc ? `<div style="
|
|
119
|
+
${desc ? `<div style="opacity:${isDark ? "0.86" : "0.78"};">${desc}</div>` : ""}
|
|
108
120
|
</div>
|
|
109
121
|
`;
|
|
110
122
|
},
|
|
@@ -116,43 +128,36 @@ var OrganizationChart = (options) => {
|
|
|
116
128
|
borderRadius: 8,
|
|
117
129
|
boxShadow: "0 12px 28px rgba(0,0,0,0.16)",
|
|
118
130
|
padding: "8px 10px",
|
|
119
|
-
pointerEvents: "none"
|
|
131
|
+
pointerEvents: "none",
|
|
132
|
+
fontFamily: FONT_FAMILY,
|
|
133
|
+
fontSize: "12px",
|
|
134
|
+
lineHeight: 1.35,
|
|
135
|
+
...appearance.tooltipStyle
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
138
|
},
|
|
123
|
-
...
|
|
124
|
-
{
|
|
125
|
-
key: "title",
|
|
126
|
-
type: "title",
|
|
127
|
-
title,
|
|
128
|
-
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
129
|
-
titleFontFamily: "sans-serif"
|
|
130
|
-
}
|
|
131
|
-
] : []
|
|
139
|
+
...graphTitle.plugins
|
|
132
140
|
],
|
|
133
141
|
node: {
|
|
134
142
|
type: "rect",
|
|
135
143
|
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
144
|
fill: (d) => colors[d.data.depth % colors.length],
|
|
142
145
|
stroke: isDark ? "#555" : "#e8ebf0",
|
|
143
146
|
lineWidth: 1,
|
|
144
|
-
radius:
|
|
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,
|
|
147
|
+
radius: baseTheme === "academy" ? 0 : 8,
|
|
149
148
|
labelFill: "#ffffff",
|
|
150
149
|
labelFontSize: 12,
|
|
151
150
|
labelFontWeight: 600,
|
|
151
|
+
...nodeTheme,
|
|
152
|
+
// Layout and data-derived content remain chart-owned. One line is
|
|
153
|
+
// reserved for the name and up to two lines for the description.
|
|
154
|
+
size: getNodeSize,
|
|
155
|
+
labelText: (d) => d.data.description ? `${d.data.name}
|
|
156
|
+
${d.data.description}` : d.data.name,
|
|
152
157
|
labelWordWrap: true,
|
|
153
158
|
labelWordWrapWidth: LABEL_MAX_WIDTH,
|
|
154
159
|
labelMaxLines: (d) => d.data.description ? 3 : 1,
|
|
155
|
-
labelLineHeight
|
|
160
|
+
labelLineHeight,
|
|
156
161
|
labelPlacement: "center"
|
|
157
162
|
}
|
|
158
163
|
},
|
|
@@ -163,7 +168,8 @@ ${d.data.description}` : d.data.name,
|
|
|
163
168
|
stroke: isDark ? "#4a4a4a" : "#d0d7e0",
|
|
164
169
|
lineWidth: 1.5,
|
|
165
170
|
endArrow: false,
|
|
166
|
-
startArrow: false
|
|
171
|
+
startArrow: false,
|
|
172
|
+
...edgeTheme
|
|
167
173
|
}
|
|
168
174
|
},
|
|
169
175
|
layout: {
|
|
@@ -172,7 +178,7 @@ ${d.data.description}` : d.data.name,
|
|
|
172
178
|
nodesep: 40,
|
|
173
179
|
ranksep: 60,
|
|
174
180
|
// Dynamic nodeSize lets dagre calculate accurate per-node spacing
|
|
175
|
-
nodeSize:
|
|
181
|
+
nodeSize: getNodeSize
|
|
176
182
|
},
|
|
177
183
|
behaviors: ["drag-canvas"]
|
|
178
184
|
});
|
|
@@ -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
|
-
|
|
19
|
-
|
|
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.
|