@antv/gpt-vis 1.0.0-beta.1 → 1.0.0-beta.2
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 +6 -4
- package/README.zh-CN.md +6 -4
- package/dist/cjs/gpt-vis/index.d.ts +8 -1
- package/dist/cjs/gpt-vis/index.js +43 -20
- package/dist/cjs/index.d.ts +15 -2
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/syntax/parser.d.ts +17 -2
- package/dist/cjs/syntax/parser.js +151 -38
- package/dist/cjs/util/container.d.ts +5 -0
- package/dist/cjs/util/container.js +43 -0
- package/dist/cjs/util/theme.d.ts +5 -0
- package/dist/cjs/util/theme.js +9 -2
- package/dist/cjs/vis/area/index.js +2 -1
- package/dist/cjs/vis/bar/index.js +5 -4
- package/dist/cjs/vis/boxplot/index.js +7 -2
- package/dist/cjs/vis/column/index.js +5 -4
- package/dist/cjs/vis/dual-axes/index.js +2 -1
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/cjs/vis/fishbone-diagram/index.js +183 -0
- package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
- package/dist/cjs/vis/flow-diagram/index.js +271 -0
- package/dist/cjs/vis/funnel/index.js +2 -1
- package/dist/cjs/vis/histogram/index.js +3 -7
- package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
- package/dist/cjs/vis/indented-tree/index.js +375 -0
- package/dist/cjs/vis/line/index.js +2 -1
- package/dist/cjs/vis/liquid/index.js +2 -1
- package/dist/cjs/vis/mindmap/index.d.ts +32 -0
- package/dist/cjs/vis/mindmap/index.js +214 -0
- package/dist/cjs/vis/network-graph/index.d.ts +59 -0
- package/dist/cjs/vis/network-graph/index.js +166 -0
- package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
- package/dist/cjs/vis/organization-chart/index.js +191 -0
- package/dist/cjs/vis/pie/index.js +3 -3
- package/dist/cjs/vis/radar/index.d.ts +1 -0
- package/dist/cjs/vis/radar/index.js +10 -9
- package/dist/cjs/vis/sankey/index.js +2 -1
- package/dist/cjs/vis/scatter/index.js +2 -1
- package/dist/cjs/vis/summary/index.js +17 -3
- package/dist/cjs/vis/table/index.d.ts +1 -0
- package/dist/cjs/vis/table/index.js +37 -1
- package/dist/cjs/vis/treemap/index.js +2 -1
- package/dist/cjs/vis/venn/index.d.ts +2 -1
- package/dist/cjs/vis/venn/index.js +18 -3
- package/dist/cjs/vis/violin/index.js +2 -1
- package/dist/cjs/vis/waterfall/index.d.ts +6 -9
- package/dist/cjs/vis/waterfall/index.js +28 -5
- package/dist/cjs/vis/word-cloud/index.js +2 -1
- package/dist/cjs/vis-wrapper/icons.js +2 -2
- package/dist/cjs/vis-wrapper/index.d.ts +1 -0
- package/dist/cjs/vis-wrapper/index.js +27 -16
- package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
- package/dist/cjs/vis-wrapper/styles.js +8 -1
- package/dist/esm/gpt-vis/index.d.ts +8 -1
- package/dist/esm/gpt-vis/index.js +47 -26
- package/dist/esm/index.d.ts +15 -2
- package/dist/esm/index.js +7 -1
- package/dist/esm/syntax/parser.d.ts +17 -2
- package/dist/esm/syntax/parser.js +248 -90
- package/dist/esm/util/container.d.ts +5 -0
- package/dist/esm/util/container.js +20 -0
- package/dist/esm/util/theme.d.ts +5 -0
- package/dist/esm/util/theme.js +9 -0
- package/dist/esm/vis/area/index.js +3 -2
- package/dist/esm/vis/bar/index.js +7 -6
- package/dist/esm/vis/boxplot/index.js +17 -4
- package/dist/esm/vis/column/index.js +7 -6
- package/dist/esm/vis/dual-axes/index.js +3 -2
- package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/esm/vis/fishbone-diagram/index.js +218 -0
- package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
- package/dist/esm/vis/flow-diagram/index.js +342 -0
- package/dist/esm/vis/funnel/index.js +3 -2
- package/dist/esm/vis/histogram/index.js +6 -7
- package/dist/esm/vis/indented-tree/index.d.ts +40 -0
- package/dist/esm/vis/indented-tree/index.js +564 -0
- package/dist/esm/vis/line/index.js +3 -2
- package/dist/esm/vis/liquid/index.js +3 -2
- package/dist/esm/vis/mindmap/index.d.ts +32 -0
- package/dist/esm/vis/mindmap/index.js +315 -0
- package/dist/esm/vis/network-graph/index.d.ts +59 -0
- package/dist/esm/vis/network-graph/index.js +240 -0
- package/dist/esm/vis/organization-chart/index.d.ts +64 -0
- package/dist/esm/vis/organization-chart/index.js +269 -0
- package/dist/esm/vis/pie/index.js +4 -8
- package/dist/esm/vis/radar/index.d.ts +1 -0
- package/dist/esm/vis/radar/index.js +20 -4
- package/dist/esm/vis/sankey/index.js +3 -2
- package/dist/esm/vis/scatter/index.js +3 -2
- package/dist/esm/vis/summary/index.js +25 -4
- package/dist/esm/vis/table/index.d.ts +1 -0
- package/dist/esm/vis/table/index.js +9 -2
- package/dist/esm/vis/treemap/index.js +3 -2
- package/dist/esm/vis/venn/index.d.ts +2 -1
- package/dist/esm/vis/venn/index.js +29 -4
- package/dist/esm/vis/violin/index.js +3 -2
- package/dist/esm/vis/waterfall/index.d.ts +6 -9
- package/dist/esm/vis/waterfall/index.js +27 -9
- package/dist/esm/vis/word-cloud/index.js +3 -2
- package/dist/esm/vis-wrapper/icons.js +2 -2
- package/dist/esm/vis-wrapper/index.d.ts +1 -0
- package/dist/esm/vis-wrapper/index.js +15 -10
- package/dist/esm/vis-wrapper/styles.d.ts +1 -1
- package/dist/esm/vis-wrapper/styles.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +19 -19
- package/src/gpt-vis/index.ts +0 -283
- package/src/index.ts +0 -44
- package/src/readme.md +0 -37
- package/src/syntax/index.ts +0 -2
- package/src/syntax/parser.ts +0 -411
- package/src/types/index.ts +0 -29
- package/src/util/theme.ts +0 -167
- package/src/vis/area/README.md +0 -143
- package/src/vis/area/index.ts +0 -212
- package/src/vis/bar/README.md +0 -158
- package/src/vis/bar/index.ts +0 -186
- package/src/vis/boxplot/README.md +0 -168
- package/src/vis/boxplot/index.ts +0 -162
- package/src/vis/column/README.md +0 -158
- package/src/vis/column/index.ts +0 -185
- package/src/vis/dual-axes/README.md +0 -191
- package/src/vis/dual-axes/index.ts +0 -218
- package/src/vis/funnel/README.md +0 -143
- package/src/vis/funnel/index.ts +0 -238
- package/src/vis/histogram/README.md +0 -130
- package/src/vis/histogram/index.ts +0 -153
- package/src/vis/line/README.md +0 -138
- package/src/vis/line/index.ts +0 -159
- package/src/vis/liquid/README.md +0 -150
- package/src/vis/liquid/index.ts +0 -130
- package/src/vis/pie/README.md +0 -127
- package/src/vis/pie/index.ts +0 -163
- package/src/vis/radar/README.md +0 -184
- package/src/vis/radar/index.ts +0 -214
- package/src/vis/sankey/README.md +0 -144
- package/src/vis/sankey/index.ts +0 -144
- package/src/vis/scatter/README.md +0 -145
- package/src/vis/scatter/index.ts +0 -147
- package/src/vis/summary/README.md +0 -272
- package/src/vis/summary/index.ts +0 -91
- package/src/vis/table/README.md +0 -174
- package/src/vis/table/index.ts +0 -241
- package/src/vis/treemap/README.md +0 -199
- package/src/vis/treemap/index.ts +0 -167
- package/src/vis/venn/README.md +0 -153
- package/src/vis/venn/index.ts +0 -149
- package/src/vis/violin/README.md +0 -168
- package/src/vis/violin/index.ts +0 -216
- package/src/vis/waterfall/README.md +0 -178
- package/src/vis/waterfall/index.ts +0 -258
- package/src/vis/word-cloud/README.md +0 -137
- package/src/vis/word-cloud/index.ts +0 -137
- package/src/vis-wrapper/README.md +0 -159
- package/src/vis-wrapper/icons.ts +0 -35
- package/src/vis-wrapper/index.ts +0 -276
- package/src/vis-wrapper/styles.ts +0 -195
|
@@ -0,0 +1,43 @@
|
|
|
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/util/container.ts
|
|
20
|
+
var container_exports = {};
|
|
21
|
+
__export(container_exports, {
|
|
22
|
+
resolveContainer: () => resolveContainer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(container_exports);
|
|
25
|
+
function resolveContainer(container) {
|
|
26
|
+
if (typeof container === "string") {
|
|
27
|
+
if (typeof document === "undefined") {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Container element "${container}" cannot be resolved in a non-browser environment.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const el = document.querySelector(container);
|
|
33
|
+
if (!el) {
|
|
34
|
+
throw new Error(`Container element "${container}" not found`);
|
|
35
|
+
}
|
|
36
|
+
return el;
|
|
37
|
+
}
|
|
38
|
+
return container;
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
resolveContainer
|
|
43
|
+
});
|
package/dist/cjs/util/theme.d.ts
CHANGED
|
@@ -19,3 +19,8 @@ export declare const getThemeColors: (theme: string) => string[];
|
|
|
19
19
|
* Get background color based on theme.
|
|
20
20
|
*/
|
|
21
21
|
export declare const getBackgroundColor: (theme: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize palette to always return an array.
|
|
24
|
+
* Handles the case where a single color is parsed as a string instead of an array.
|
|
25
|
+
*/
|
|
26
|
+
export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
|
package/dist/cjs/util/theme.js
CHANGED
|
@@ -25,7 +25,8 @@ __export(theme_exports, {
|
|
|
25
25
|
getBackgroundColor: () => getBackgroundColor,
|
|
26
26
|
getTheme: () => getTheme,
|
|
27
27
|
getThemeColors: () => getThemeColors,
|
|
28
|
-
getThemeObject: () => getThemeObject
|
|
28
|
+
getThemeObject: () => getThemeObject,
|
|
29
|
+
normalizePalette: () => normalizePalette
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(theme_exports);
|
|
31
32
|
var DEFAULT_COLOR_PALETTE = [
|
|
@@ -170,6 +171,11 @@ var getBackgroundColor = (theme) => {
|
|
|
170
171
|
return "#FFF";
|
|
171
172
|
}
|
|
172
173
|
};
|
|
174
|
+
var normalizePalette = (palette, theme) => {
|
|
175
|
+
if (!palette || Array.isArray(palette) && palette.length === 0)
|
|
176
|
+
return getThemeColors(theme);
|
|
177
|
+
return Array.isArray(palette) ? palette : [palette];
|
|
178
|
+
};
|
|
173
179
|
// Annotate the CommonJS export names for ESM import in node:
|
|
174
180
|
0 && (module.exports = {
|
|
175
181
|
ACADEMY_COLOR_PALETTE,
|
|
@@ -178,5 +184,6 @@ var getBackgroundColor = (theme) => {
|
|
|
178
184
|
getBackgroundColor,
|
|
179
185
|
getTheme,
|
|
180
186
|
getThemeColors,
|
|
181
|
-
getThemeObject
|
|
187
|
+
getThemeObject,
|
|
188
|
+
normalizePalette
|
|
182
189
|
});
|
|
@@ -45,7 +45,7 @@ var Area = (options) => {
|
|
|
45
45
|
}
|
|
46
46
|
const { lineWidth = 2 } = style;
|
|
47
47
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
48
|
-
const colors =
|
|
48
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
49
49
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
50
50
|
const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR);
|
|
51
51
|
chart = new import_g2.Chart({
|
|
@@ -106,6 +106,7 @@ var Area = (options) => {
|
|
|
106
106
|
];
|
|
107
107
|
}
|
|
108
108
|
const chartOptions = {
|
|
109
|
+
animate: false,
|
|
109
110
|
type: "view",
|
|
110
111
|
data,
|
|
111
112
|
title: title ?? "",
|
|
@@ -28,7 +28,7 @@ var Bar = (options) => {
|
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
30
|
const render = (config) => {
|
|
31
|
-
var _a
|
|
31
|
+
var _a;
|
|
32
32
|
const {
|
|
33
33
|
data = [],
|
|
34
34
|
theme = chartTheme,
|
|
@@ -43,7 +43,7 @@ var Bar = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
chart = new import_g2.Chart({
|
|
49
49
|
container,
|
|
@@ -54,7 +54,7 @@ var Bar = (options) => {
|
|
|
54
54
|
let encode = {};
|
|
55
55
|
let transform = [];
|
|
56
56
|
let radiusStyle = {};
|
|
57
|
-
if (theme
|
|
57
|
+
if (theme !== "academy") {
|
|
58
58
|
radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
|
|
59
59
|
}
|
|
60
60
|
if (hasGroupField && group) {
|
|
@@ -70,9 +70,10 @@ var Bar = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
const scaleConfig = {
|
|
72
72
|
y: { nice: true },
|
|
73
|
-
...
|
|
73
|
+
...style.palette ? { color: { range: colors } } : {}
|
|
74
74
|
};
|
|
75
75
|
const chartOptions = {
|
|
76
|
+
animate: false,
|
|
76
77
|
type: "interval",
|
|
77
78
|
data,
|
|
78
79
|
title: title ?? "",
|
|
@@ -33,7 +33,7 @@ var Boxplot = (options) => {
|
|
|
33
33
|
if (chart) {
|
|
34
34
|
chart.destroy();
|
|
35
35
|
}
|
|
36
|
-
const colors =
|
|
36
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
37
37
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
38
38
|
const startAtZero = style.startAtZero || false;
|
|
39
39
|
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
@@ -59,6 +59,7 @@ var Boxplot = (options) => {
|
|
|
59
59
|
autoFit: true
|
|
60
60
|
});
|
|
61
61
|
const chartOptions = {
|
|
62
|
+
animate: false,
|
|
62
63
|
type: "boxplot",
|
|
63
64
|
data,
|
|
64
65
|
title: title ?? "",
|
|
@@ -77,7 +78,11 @@ var Boxplot = (options) => {
|
|
|
77
78
|
y: { nice: true, zero: startAtZero },
|
|
78
79
|
color: { range: colors }
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
+
// When hasGroupField is true, set point to false to prevent G2's Boxplot composite mark
|
|
82
|
+
// from splitting into box + point child marks. The point child mark does not inherit
|
|
83
|
+
// the `scale` config, causing legendFilter interaction to throw
|
|
84
|
+
// "Cannot read properties of undefined (reading 'color')" when clicking legend items.
|
|
85
|
+
style: { stroke: "black", ...hasGroupField ? { point: false } : {} },
|
|
81
86
|
legend: {
|
|
82
87
|
color: hasGroupField ? { position: "top" } : false
|
|
83
88
|
},
|
|
@@ -28,7 +28,7 @@ var Column = (options) => {
|
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
30
|
const render = (config) => {
|
|
31
|
-
var _a
|
|
31
|
+
var _a;
|
|
32
32
|
const {
|
|
33
33
|
data = [],
|
|
34
34
|
theme = chartTheme,
|
|
@@ -43,7 +43,7 @@ var Column = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
chart = new import_g2.Chart({
|
|
49
49
|
container,
|
|
@@ -54,7 +54,7 @@ var Column = (options) => {
|
|
|
54
54
|
let encode = {};
|
|
55
55
|
let transform = [];
|
|
56
56
|
let radiusStyle = {};
|
|
57
|
-
if (theme
|
|
57
|
+
if (theme !== "academy") {
|
|
58
58
|
radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
|
|
59
59
|
}
|
|
60
60
|
if (hasGroupField && group) {
|
|
@@ -70,9 +70,10 @@ var Column = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
const scaleConfig = {
|
|
72
72
|
y: { nice: true },
|
|
73
|
-
...
|
|
73
|
+
...style.palette ? { color: { range: colors } } : {}
|
|
74
74
|
};
|
|
75
75
|
const chartOptions = {
|
|
76
|
+
animate: false,
|
|
76
77
|
type: "interval",
|
|
77
78
|
data,
|
|
78
79
|
title: title ?? "",
|
|
@@ -43,7 +43,7 @@ var DualAxes = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const { startAtZero = false } = style;
|
|
46
|
-
const colors =
|
|
46
|
+
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
47
47
|
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
48
48
|
const data = transformData(series, categories);
|
|
49
49
|
chart = new import_g2.Chart({
|
|
@@ -103,6 +103,7 @@ var DualAxes = (options) => {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
const chartOptions = {
|
|
106
|
+
animate: false,
|
|
106
107
|
type: "view",
|
|
107
108
|
data,
|
|
108
109
|
title: title ?? "",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { VisualizationOptions } from '../../types';
|
|
2
|
+
export interface FishboneNode {
|
|
3
|
+
name: string;
|
|
4
|
+
children?: FishboneNode[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
|
|
8
|
+
*/
|
|
9
|
+
export interface FishboneDiagramConfig {
|
|
10
|
+
type?: 'fishbone-diagram';
|
|
11
|
+
data: FishboneNode;
|
|
12
|
+
theme?: 'default' | 'academy' | 'dark';
|
|
13
|
+
title?: string;
|
|
14
|
+
style?: {
|
|
15
|
+
/** Custom color palette for branch nodes, overrides theme default */
|
|
16
|
+
palette?: string[];
|
|
17
|
+
/** Canvas background color, overrides theme default */
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
/** Node rendering style: 'rough' for hand-drawn look, 'default' for smooth */
|
|
20
|
+
texture?: 'rough' | 'default';
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* FishboneDiagramInstance represents a fishbone diagram instance.
|
|
25
|
+
*/
|
|
26
|
+
export interface FishboneDiagramInstance {
|
|
27
|
+
render: (config: FishboneDiagramConfig) => void;
|
|
28
|
+
destroy: () => void;
|
|
29
|
+
zoomTo: (zoom: number) => void;
|
|
30
|
+
getZoom: () => number | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* FishboneDiagram chart component using G6 with fishbone layout.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FishboneDiagram: (options: VisualizationOptions) => FishboneDiagramInstance;
|
|
@@ -0,0 +1,183 @@
|
|
|
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/fishbone-diagram/index.ts
|
|
20
|
+
var fishbone_diagram_exports = {};
|
|
21
|
+
__export(fishbone_diagram_exports, {
|
|
22
|
+
FishboneDiagram: () => FishboneDiagram
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(fishbone_diagram_exports);
|
|
25
|
+
var import_g6 = require("@antv/g6");
|
|
26
|
+
var import_theme = require("../../util/theme");
|
|
27
|
+
var FONT_FAMILY = "system-ui, sans-serif";
|
|
28
|
+
function getNodeSize(id, depth) {
|
|
29
|
+
return depth === 0 ? [measureText(id, 24, "bold") + 80, 70] : depth === 1 ? [measureText(id, 18) + 50, 42] : [2, 30];
|
|
30
|
+
}
|
|
31
|
+
var measureText = function() {
|
|
32
|
+
let canvas = null;
|
|
33
|
+
return (text, fontSize = 12, fontWeight = "normal") => {
|
|
34
|
+
if (typeof document === "undefined")
|
|
35
|
+
return text.length * fontSize * 0.6;
|
|
36
|
+
if (!canvas)
|
|
37
|
+
canvas = document.createElement("canvas");
|
|
38
|
+
const ctx = canvas.getContext("2d");
|
|
39
|
+
if (!ctx)
|
|
40
|
+
return 0;
|
|
41
|
+
ctx.font = `${fontWeight} ${fontSize}px ${FONT_FAMILY}`;
|
|
42
|
+
return ctx.measureText(text).width;
|
|
43
|
+
};
|
|
44
|
+
}();
|
|
45
|
+
function toG6TreeData(node) {
|
|
46
|
+
return {
|
|
47
|
+
id: node.name,
|
|
48
|
+
children: (node.children || []).map(toG6TreeData)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function convertData(data) {
|
|
52
|
+
return (0, import_g6.treeToGraphData)(toG6TreeData(data), {
|
|
53
|
+
getNodeData: (datum, depth) => {
|
|
54
|
+
datum.depth = depth;
|
|
55
|
+
if (!datum.children)
|
|
56
|
+
return datum;
|
|
57
|
+
const { children, ...rest } = datum;
|
|
58
|
+
return { ...rest, children: children.map((c) => c.id) };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function assignBranchColors(graphData, palette) {
|
|
63
|
+
const nodes = graphData.nodes || [];
|
|
64
|
+
let colorIndex = 0;
|
|
65
|
+
nodes.filter((n) => n.depth === 1).forEach((n) => {
|
|
66
|
+
n.style = n.style || {};
|
|
67
|
+
n.style.branchColor = palette[colorIndex++ % palette.length];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
var FishboneDiagram = (options) => {
|
|
71
|
+
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
72
|
+
let graph = null;
|
|
73
|
+
const render = (config) => {
|
|
74
|
+
const { data, theme = chartTheme, title, style = {} } = config;
|
|
75
|
+
if (!(data == null ? void 0 : data.name)) {
|
|
76
|
+
throw new Error("FishboneDiagram: data with a name field is required");
|
|
77
|
+
}
|
|
78
|
+
if (graph) {
|
|
79
|
+
graph.destroy();
|
|
80
|
+
graph = null;
|
|
81
|
+
}
|
|
82
|
+
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
83
|
+
if (!containerEl)
|
|
84
|
+
throw new Error("FishboneDiagram: container element not found");
|
|
85
|
+
containerEl.innerHTML = "";
|
|
86
|
+
const isDark = theme === "dark";
|
|
87
|
+
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
88
|
+
const palette = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
89
|
+
const rootFill = isDark ? "#2a2a2a" : "#EFF0F0";
|
|
90
|
+
const rootLabelFill = isDark ? "#e0e0e0" : "#262626";
|
|
91
|
+
const leafLabelFill = isDark ? "#c0c0c0" : "#262626";
|
|
92
|
+
const edgeStroke = isDark ? "#555" : "#99ADD1";
|
|
93
|
+
containerEl.style.backgroundColor = backgroundColor;
|
|
94
|
+
const graphData = convertData(data);
|
|
95
|
+
assignBranchColors(graphData, palette);
|
|
96
|
+
graph = new import_g6.Graph({
|
|
97
|
+
animation: false,
|
|
98
|
+
container: containerEl,
|
|
99
|
+
width,
|
|
100
|
+
height,
|
|
101
|
+
autoFit: "view",
|
|
102
|
+
autoResize: true,
|
|
103
|
+
padding: 20,
|
|
104
|
+
theme: chartTheme,
|
|
105
|
+
plugins: title ? [{ key: "title", type: "title", title, titleFill: isDark ? "#e0e6ed" : "#1a1a2e" }] : [],
|
|
106
|
+
data: graphData,
|
|
107
|
+
node: {
|
|
108
|
+
type: "rect",
|
|
109
|
+
style: (d) => {
|
|
110
|
+
var _a;
|
|
111
|
+
const depth = d.depth ?? 0;
|
|
112
|
+
const nodeStyle = {
|
|
113
|
+
radius: 8,
|
|
114
|
+
size: getNodeSize(String(d.id), depth),
|
|
115
|
+
labelText: String(d.id),
|
|
116
|
+
labelPlacement: "left",
|
|
117
|
+
labelFontFamily: FONT_FAMILY
|
|
118
|
+
};
|
|
119
|
+
if (depth === 0) {
|
|
120
|
+
Object.assign(nodeStyle, {
|
|
121
|
+
fill: rootFill,
|
|
122
|
+
labelFill: rootLabelFill,
|
|
123
|
+
labelFontWeight: "bold",
|
|
124
|
+
labelFontSize: 24,
|
|
125
|
+
labelOffsetY: 4,
|
|
126
|
+
labelPlacement: "center"
|
|
127
|
+
});
|
|
128
|
+
} else if (depth === 1) {
|
|
129
|
+
const color = ((_a = d.style) == null ? void 0 : _a.branchColor) || palette[0];
|
|
130
|
+
Object.assign(nodeStyle, {
|
|
131
|
+
fill: color,
|
|
132
|
+
labelFill: "#fff",
|
|
133
|
+
labelFontSize: 18,
|
|
134
|
+
labelPlacement: "center"
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
Object.assign(nodeStyle, {
|
|
138
|
+
fill: "transparent",
|
|
139
|
+
labelFill: leafLabelFill,
|
|
140
|
+
labelFontSize: 16
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (style.texture === "rough") {
|
|
144
|
+
nodeStyle.lineWidth = 0.5;
|
|
145
|
+
}
|
|
146
|
+
return nodeStyle;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
edge: {
|
|
150
|
+
type: "polyline",
|
|
151
|
+
style: {
|
|
152
|
+
lineWidth: 3,
|
|
153
|
+
stroke: edgeStroke,
|
|
154
|
+
...style.texture === "rough" ? { labelFontFamily: "Comic Sans MS" } : {}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
layout: {
|
|
158
|
+
type: "fishbone",
|
|
159
|
+
direction: "RL",
|
|
160
|
+
hGap: 40,
|
|
161
|
+
vGap: 60
|
|
162
|
+
},
|
|
163
|
+
behaviors: ["drag-canvas"]
|
|
164
|
+
});
|
|
165
|
+
graph.render();
|
|
166
|
+
};
|
|
167
|
+
const destroy = () => {
|
|
168
|
+
if (graph) {
|
|
169
|
+
graph.destroy();
|
|
170
|
+
graph = null;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
render,
|
|
175
|
+
destroy,
|
|
176
|
+
zoomTo: (zoom) => graph == null ? void 0 : graph.zoomTo(zoom),
|
|
177
|
+
getZoom: () => (graph == null ? void 0 : graph.getZoom()) ?? 1
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
FishboneDiagram
|
|
183
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GraphData, VisualizationOptions } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* FlowDiagramConfig defines the configuration for rendering the flow diagram.
|
|
4
|
+
*/
|
|
5
|
+
export interface FlowDiagramConfig {
|
|
6
|
+
type?: 'flow-diagram';
|
|
7
|
+
data: GraphData;
|
|
8
|
+
title?: string;
|
|
9
|
+
theme?: 'default' | 'academy' | 'dark';
|
|
10
|
+
style?: {
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
palette?: string[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* FlowDiagramInstance represents a flow diagram instance with render and destroy methods.
|
|
17
|
+
*/
|
|
18
|
+
export interface FlowDiagramInstance {
|
|
19
|
+
render: (config: FlowDiagramConfig) => void;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
zoomTo: (zoom: number) => void;
|
|
22
|
+
getZoom: () => number | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* FlowDiagram chart component using G6 5.0 with dagre layout.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FlowDiagram: (options: VisualizationOptions) => FlowDiagramInstance;
|