@antv/gpt-vis 0.4.7 → 0.5.0-beta.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.
- package/dist/cjs/ssr/area.d.ts +6 -0
- package/dist/cjs/ssr/area.js +64 -0
- package/dist/cjs/ssr/bar.d.ts +6 -0
- package/dist/cjs/ssr/bar.js +79 -0
- package/dist/cjs/ssr/column.d.ts +6 -0
- package/dist/cjs/ssr/column.js +77 -0
- package/dist/cjs/ssr/dual-axes.d.ts +6 -0
- package/dist/cjs/ssr/dual-axes.js +98 -0
- package/dist/cjs/ssr/fishbone-diagram.d.ts +6 -0
- package/dist/cjs/ssr/fishbone-diagram.js +189 -0
- package/dist/cjs/ssr/flow-diagram.d.ts +6 -0
- package/dist/cjs/ssr/flow-diagram.js +82 -0
- package/dist/cjs/ssr/histogram.d.ts +6 -0
- package/dist/cjs/ssr/histogram.js +50 -0
- package/dist/cjs/ssr/index.d.ts +2 -0
- package/dist/cjs/ssr/index.js +79 -0
- package/dist/cjs/ssr/line.d.ts +6 -0
- package/dist/cjs/ssr/line.js +62 -0
- package/dist/cjs/ssr/mind-map.d.ts +6 -0
- package/dist/cjs/ssr/mind-map.js +326 -0
- package/dist/cjs/ssr/network-graph.d.ts +6 -0
- package/dist/cjs/ssr/network-graph.js +72 -0
- package/dist/cjs/ssr/pie.d.ts +6 -0
- package/dist/cjs/ssr/pie.js +64 -0
- package/dist/cjs/ssr/radar.d.ts +6 -0
- package/dist/cjs/ssr/radar.js +92 -0
- package/dist/cjs/ssr/scatter.d.ts +6 -0
- package/dist/cjs/ssr/scatter.js +56 -0
- package/dist/cjs/ssr/treemap.d.ts +6 -0
- package/dist/cjs/ssr/treemap.js +57 -0
- package/dist/cjs/ssr/type.d.ts +30 -0
- package/dist/cjs/ssr/type.js +17 -0
- package/dist/cjs/ssr/word-cloud.d.ts +6 -0
- package/dist/cjs/ssr/word-cloud.js +48 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/ssr/area.d.ts +6 -0
- package/dist/esm/ssr/area.js +67 -0
- package/dist/esm/ssr/bar.d.ts +6 -0
- package/dist/esm/ssr/bar.js +71 -0
- package/dist/esm/ssr/column.d.ts +6 -0
- package/dist/esm/ssr/column.js +65 -0
- package/dist/esm/ssr/dual-axes.d.ts +6 -0
- package/dist/esm/ssr/dual-axes.js +122 -0
- package/dist/esm/ssr/fishbone-diagram.d.ts +6 -0
- package/dist/esm/ssr/fishbone-diagram.js +195 -0
- package/dist/esm/ssr/flow-diagram.d.ts +6 -0
- package/dist/esm/ssr/flow-diagram.js +89 -0
- package/dist/esm/ssr/histogram.d.ts +6 -0
- package/dist/esm/ssr/histogram.js +56 -0
- package/dist/esm/ssr/index.d.ts +2 -0
- package/dist/esm/ssr/index.js +68 -0
- package/dist/esm/ssr/line.d.ts +6 -0
- package/dist/esm/ssr/line.js +61 -0
- package/dist/esm/ssr/mind-map.d.ts +6 -0
- package/dist/esm/ssr/mind-map.js +416 -0
- package/dist/esm/ssr/network-graph.d.ts +6 -0
- package/dist/esm/ssr/network-graph.js +79 -0
- package/dist/esm/ssr/pie.d.ts +6 -0
- package/dist/esm/ssr/pie.js +66 -0
- package/dist/esm/ssr/radar.d.ts +6 -0
- package/dist/esm/ssr/radar.js +88 -0
- package/dist/esm/ssr/scatter.d.ts +6 -0
- package/dist/esm/ssr/scatter.js +52 -0
- package/dist/esm/ssr/treemap.d.ts +6 -0
- package/dist/esm/ssr/treemap.js +51 -0
- package/dist/esm/ssr/type.d.ts +30 -0
- package/dist/esm/ssr/type.js +1 -0
- package/dist/esm/ssr/word-cloud.d.ts +6 -0
- package/dist/esm/ssr/word-cloud.js +40 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/424.async.js +1 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +58 -31
- package/dist/umd/100.async.js +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
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/ssr/area.ts
|
|
20
|
+
var area_exports = {};
|
|
21
|
+
__export(area_exports, {
|
|
22
|
+
Area: () => Area
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(area_exports);
|
|
25
|
+
var import_g2_ssr = require("@antv/g2-ssr");
|
|
26
|
+
async function Area(options) {
|
|
27
|
+
const { data, title, width, height, stack, axisYTitle, axisXTitle } = options;
|
|
28
|
+
let encode = {};
|
|
29
|
+
let transform = [];
|
|
30
|
+
if (stack) {
|
|
31
|
+
encode = { x: "time", y: "value", color: "group" };
|
|
32
|
+
transform = [{ type: "stackY" }];
|
|
33
|
+
} else {
|
|
34
|
+
encode = { x: "time", y: "value" };
|
|
35
|
+
}
|
|
36
|
+
return await (0, import_g2_ssr.createChart)({
|
|
37
|
+
type: "view",
|
|
38
|
+
title,
|
|
39
|
+
data,
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
encode,
|
|
43
|
+
transform,
|
|
44
|
+
style: { minHeight: 1 },
|
|
45
|
+
axis: {
|
|
46
|
+
y: {
|
|
47
|
+
title: axisYTitle || false
|
|
48
|
+
},
|
|
49
|
+
x: {
|
|
50
|
+
title: axisXTitle || false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
{
|
|
55
|
+
type: "area",
|
|
56
|
+
style: { opacity: 0.7 }
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
Area
|
|
64
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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/ssr/bar.ts
|
|
20
|
+
var bar_exports = {};
|
|
21
|
+
__export(bar_exports, {
|
|
22
|
+
Bar: () => Bar
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(bar_exports);
|
|
25
|
+
var import_g2_ssr = require("@antv/g2-ssr");
|
|
26
|
+
async function Bar(options) {
|
|
27
|
+
var _a;
|
|
28
|
+
const { data, title, width, height, stack, group, axisYTitle, axisXTitle } = options;
|
|
29
|
+
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
30
|
+
let transforms = [];
|
|
31
|
+
if (group) {
|
|
32
|
+
transforms = [
|
|
33
|
+
{
|
|
34
|
+
type: "dodgeX"
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (stack) {
|
|
39
|
+
transforms = [
|
|
40
|
+
{
|
|
41
|
+
type: "stackY"
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return await (0, import_g2_ssr.createChart)({
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
title,
|
|
49
|
+
type: "interval",
|
|
50
|
+
data,
|
|
51
|
+
encode: hasGroupField ? {
|
|
52
|
+
x: "category",
|
|
53
|
+
y: "value",
|
|
54
|
+
color: "group"
|
|
55
|
+
} : {
|
|
56
|
+
x: "category",
|
|
57
|
+
y: "value"
|
|
58
|
+
},
|
|
59
|
+
transform: transforms,
|
|
60
|
+
coordinate: { transform: [{ type: "transpose" }] },
|
|
61
|
+
style: {
|
|
62
|
+
// 圆角样式
|
|
63
|
+
radiusTopLeft: 10,
|
|
64
|
+
radiusTopRight: 10
|
|
65
|
+
},
|
|
66
|
+
axis: {
|
|
67
|
+
x: {
|
|
68
|
+
title: axisXTitle
|
|
69
|
+
},
|
|
70
|
+
y: {
|
|
71
|
+
title: axisYTitle
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
Bar
|
|
79
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ColumnProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type ColumnOptions = BaseChartConfig & {
|
|
4
|
+
type: 'column';
|
|
5
|
+
} & ColumnProps;
|
|
6
|
+
export declare function Column(options: ColumnOptions): Promise<import("@antv/g2-ssr").Chart>;
|
|
@@ -0,0 +1,77 @@
|
|
|
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/ssr/column.ts
|
|
20
|
+
var column_exports = {};
|
|
21
|
+
__export(column_exports, {
|
|
22
|
+
Column: () => Column
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(column_exports);
|
|
25
|
+
var import_g2_ssr = require("@antv/g2-ssr");
|
|
26
|
+
async function Column(options) {
|
|
27
|
+
var _a;
|
|
28
|
+
const { data, title, width, height, axisYTitle, axisXTitle, group, stack } = options;
|
|
29
|
+
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
30
|
+
let transforms = [];
|
|
31
|
+
if (group) {
|
|
32
|
+
transforms = [
|
|
33
|
+
{
|
|
34
|
+
type: "dodgeX"
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (stack) {
|
|
39
|
+
transforms = [
|
|
40
|
+
{
|
|
41
|
+
type: "stackY"
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return await (0, import_g2_ssr.createChart)({
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
title,
|
|
49
|
+
data,
|
|
50
|
+
type: "interval",
|
|
51
|
+
encode: hasGroupField ? {
|
|
52
|
+
x: "category",
|
|
53
|
+
y: "value",
|
|
54
|
+
color: "group"
|
|
55
|
+
} : {
|
|
56
|
+
x: "category",
|
|
57
|
+
y: "value"
|
|
58
|
+
},
|
|
59
|
+
transform: transforms,
|
|
60
|
+
style: {
|
|
61
|
+
radiusTopLeft: 10,
|
|
62
|
+
radiusTopRight: 10
|
|
63
|
+
},
|
|
64
|
+
axis: {
|
|
65
|
+
x: {
|
|
66
|
+
title: axisXTitle
|
|
67
|
+
},
|
|
68
|
+
y: {
|
|
69
|
+
title: axisYTitle
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
Column
|
|
77
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DualAxesProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type DualAxespOptions = BaseChartConfig & {
|
|
4
|
+
type: 'dual-axes';
|
|
5
|
+
} & DualAxesProps;
|
|
6
|
+
export declare function DualAxes(options: DualAxespOptions): Promise<import("@antv/g2-ssr").Chart>;
|
|
@@ -0,0 +1,98 @@
|
|
|
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/ssr/dual-axes.ts
|
|
20
|
+
var dual_axes_exports = {};
|
|
21
|
+
__export(dual_axes_exports, {
|
|
22
|
+
DualAxes: () => DualAxes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(dual_axes_exports);
|
|
25
|
+
var import_g2_ssr = require("@antv/g2-ssr");
|
|
26
|
+
async function DualAxes(options) {
|
|
27
|
+
const { series, categories, title, width, height } = options;
|
|
28
|
+
let ChartType;
|
|
29
|
+
((ChartType2) => {
|
|
30
|
+
ChartType2["Column"] = "column";
|
|
31
|
+
ChartType2["Line"] = "line";
|
|
32
|
+
})(ChartType || (ChartType = {}));
|
|
33
|
+
function transform(series2, categories2) {
|
|
34
|
+
const newChildren = series2.map((item) => {
|
|
35
|
+
const { type, axisYTitle, ...others } = item;
|
|
36
|
+
const baseConfig = {
|
|
37
|
+
...others,
|
|
38
|
+
axis: { y: { title: axisYTitle } },
|
|
39
|
+
encode: { x: "category", y: axisYTitle, color: () => axisYTitle },
|
|
40
|
+
legend: {
|
|
41
|
+
color: {
|
|
42
|
+
itemMarker: (v) => {
|
|
43
|
+
if (v === axisYTitle)
|
|
44
|
+
return "smooth";
|
|
45
|
+
return "rect";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
data: void 0
|
|
50
|
+
};
|
|
51
|
+
if (type === "column" /* Column */) {
|
|
52
|
+
return { ...baseConfig, type: "interval" };
|
|
53
|
+
}
|
|
54
|
+
if (type === "line" /* Line */) {
|
|
55
|
+
return {
|
|
56
|
+
...baseConfig,
|
|
57
|
+
type,
|
|
58
|
+
axis: { y: { position: "right", title: axisYTitle } },
|
|
59
|
+
encode: { x: "category", y: axisYTitle, shape: "smooth", color: () => axisYTitle },
|
|
60
|
+
style: { lineWidth: 2, stroke: "#5AD8A6" },
|
|
61
|
+
scale: { y: { independent: true } }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return baseConfig;
|
|
65
|
+
});
|
|
66
|
+
const newData = categories2.map((item, index) => {
|
|
67
|
+
const temp = {
|
|
68
|
+
category: item
|
|
69
|
+
};
|
|
70
|
+
series2.forEach((s, i) => {
|
|
71
|
+
const defaultYField = s.axisYTitle || `value_${i + 1}`;
|
|
72
|
+
temp[defaultYField] = s.data[index];
|
|
73
|
+
});
|
|
74
|
+
return temp;
|
|
75
|
+
});
|
|
76
|
+
const legendTypeList = series2.map((item) => {
|
|
77
|
+
return item.type === "line" /* Line */ ? "smooth" : "rect";
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
children: newChildren,
|
|
81
|
+
data: newData,
|
|
82
|
+
legendTypeList
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const config = transform(series, categories);
|
|
86
|
+
return await (0, import_g2_ssr.createChart)({
|
|
87
|
+
type: "view",
|
|
88
|
+
autoFit: true,
|
|
89
|
+
title,
|
|
90
|
+
width,
|
|
91
|
+
height,
|
|
92
|
+
...config
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
DualAxes
|
|
98
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FishboneDiagramProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type FishboneDiagramOptions = BaseChartConfig & {
|
|
4
|
+
type: 'fishbone-diagram';
|
|
5
|
+
} & FishboneDiagramProps;
|
|
6
|
+
export declare function FishboneDiagram(options: FishboneDiagramOptions): Promise<import("@antv/g6-ssr").Graph>;
|
|
@@ -0,0 +1,189 @@
|
|
|
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/ssr/fishbone-diagram.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_g6_ssr = require("@antv/g6-ssr");
|
|
27
|
+
var import_canvas = require("canvas");
|
|
28
|
+
var canvas = null;
|
|
29
|
+
var ctx = null;
|
|
30
|
+
var measureText = (style) => {
|
|
31
|
+
if (!canvas) {
|
|
32
|
+
canvas = (0, import_canvas.createCanvas)(0, 0);
|
|
33
|
+
ctx = canvas.getContext("2d");
|
|
34
|
+
}
|
|
35
|
+
const font = [
|
|
36
|
+
style.fontStyle || "normal",
|
|
37
|
+
style.fontWeight || "normal",
|
|
38
|
+
`${style.fontSize || 12}px`,
|
|
39
|
+
style.fontFamily || "sans-serif"
|
|
40
|
+
].join(" ");
|
|
41
|
+
ctx.font = font;
|
|
42
|
+
return ctx.measureText(style.text).width;
|
|
43
|
+
};
|
|
44
|
+
var _AssignColorByBranch = class extends import_g6.BaseTransform {
|
|
45
|
+
constructor(context, options) {
|
|
46
|
+
super(context, Object.assign({}, _AssignColorByBranch.defaultOptions, options));
|
|
47
|
+
}
|
|
48
|
+
beforeDraw(input) {
|
|
49
|
+
const nodes = this.context.model.getNodeData();
|
|
50
|
+
if (nodes.length === 0)
|
|
51
|
+
return input;
|
|
52
|
+
let colorIndex = 0;
|
|
53
|
+
const dfs = (nodeId, color) => {
|
|
54
|
+
var _a;
|
|
55
|
+
const node = nodes.find((datum) => datum.id == nodeId);
|
|
56
|
+
if (!node)
|
|
57
|
+
return;
|
|
58
|
+
node.style || (node.style = {});
|
|
59
|
+
node.style.color = color || this.options.colors[colorIndex++ % this.options.colors.length];
|
|
60
|
+
(_a = node.children) == null ? void 0 : _a.forEach((childId) => {
|
|
61
|
+
var _a2;
|
|
62
|
+
return dfs(childId, (_a2 = node.style) == null ? void 0 : _a2.color);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
nodes.filter((node) => node.depth === 1).forEach((rootNode) => dfs(rootNode.id));
|
|
66
|
+
return input;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var AssignColorByBranch = _AssignColorByBranch;
|
|
70
|
+
AssignColorByBranch.defaultOptions = {
|
|
71
|
+
colors: [
|
|
72
|
+
"#1783FF",
|
|
73
|
+
"#F08F56",
|
|
74
|
+
"#D580FF",
|
|
75
|
+
"#00C9C9",
|
|
76
|
+
"#7863FF",
|
|
77
|
+
"#DB9D0D",
|
|
78
|
+
"#60C42D",
|
|
79
|
+
"#FF80CA",
|
|
80
|
+
"#2491B3",
|
|
81
|
+
"#17C76F"
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
(0, import_g6_ssr.register)(import_g6.ExtensionCategory.TRANSFORM, "assign-color-by-branch", AssignColorByBranch);
|
|
85
|
+
var getNodeSize = (id, depth) => {
|
|
86
|
+
const FONT_FAMILY = "system-ui, sans-serif";
|
|
87
|
+
return depth === 0 ? [
|
|
88
|
+
measureText({ text: id, fontSize: 24, fontWeight: "bold", fontFamily: FONT_FAMILY }) + 80,
|
|
89
|
+
70
|
|
90
|
+
] : depth === 1 ? [measureText({ text: id, fontSize: 18, fontFamily: FONT_FAMILY }) + 50, 42] : [2, 30];
|
|
91
|
+
};
|
|
92
|
+
function visTreeData2GraphData(data) {
|
|
93
|
+
return (0, import_g6.treeToGraphData)(data, {
|
|
94
|
+
getNodeData: (datum, depth) => {
|
|
95
|
+
datum.id = datum.name;
|
|
96
|
+
datum.depth = depth;
|
|
97
|
+
if (!datum.children)
|
|
98
|
+
return datum;
|
|
99
|
+
const { children, ...restDatum } = datum;
|
|
100
|
+
return {
|
|
101
|
+
...restDatum,
|
|
102
|
+
children: children.map((child) => child.name)
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
getEdgeData: (source, target) => ({
|
|
106
|
+
source: source.name,
|
|
107
|
+
target: target.name
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function FishboneDiagram(options) {
|
|
112
|
+
const { data, width = 600, height = 400 } = options;
|
|
113
|
+
const dataParse = visTreeData2GraphData(data);
|
|
114
|
+
return await (0, import_g6_ssr.createGraph)({
|
|
115
|
+
autoFit: {
|
|
116
|
+
type: "view",
|
|
117
|
+
options: {
|
|
118
|
+
when: "overflow",
|
|
119
|
+
direction: "x"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
width,
|
|
123
|
+
height,
|
|
124
|
+
data: dataParse,
|
|
125
|
+
padding: 20,
|
|
126
|
+
node: {
|
|
127
|
+
type: "rect",
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
style: (d) => {
|
|
130
|
+
var _a;
|
|
131
|
+
const style = {
|
|
132
|
+
radius: 8,
|
|
133
|
+
size: getNodeSize(d.id, d.depth),
|
|
134
|
+
labelText: d.id,
|
|
135
|
+
labelPlacement: "left",
|
|
136
|
+
labelFontFamily: "Gill Sans"
|
|
137
|
+
};
|
|
138
|
+
if (d.depth === 0) {
|
|
139
|
+
Object.assign(style, {
|
|
140
|
+
fill: "#EFF0F0",
|
|
141
|
+
labelFill: "#262626",
|
|
142
|
+
labelFontWeight: "bold",
|
|
143
|
+
labelFontSize: 24,
|
|
144
|
+
labelOffsetY: 4,
|
|
145
|
+
labelPlacement: "center",
|
|
146
|
+
labelLineHeight: 24
|
|
147
|
+
});
|
|
148
|
+
} else if (d.depth === 1) {
|
|
149
|
+
Object.assign(style, {
|
|
150
|
+
labelFontSize: 18,
|
|
151
|
+
labelFill: "#fff",
|
|
152
|
+
labelFillOpacity: 0.9,
|
|
153
|
+
labelOffsetY: 5,
|
|
154
|
+
labelPlacement: "center",
|
|
155
|
+
fill: (_a = d.style) == null ? void 0 : _a.color
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
Object.assign(style, {
|
|
159
|
+
fill: "transparent",
|
|
160
|
+
labelFontSize: 16,
|
|
161
|
+
labeFill: "#262626"
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return style;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
edge: {
|
|
168
|
+
type: "polyline",
|
|
169
|
+
style: {
|
|
170
|
+
lineWidth: 3,
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
stroke: function(data2) {
|
|
173
|
+
return this.getNodeData(data2.target).style.color || "#99ADD1";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
transforms: ["assign-color-by-branch"],
|
|
178
|
+
layout: {
|
|
179
|
+
type: "fishbone",
|
|
180
|
+
direction: "RL",
|
|
181
|
+
hGap: 40,
|
|
182
|
+
vGap: 60
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
FishboneDiagram
|
|
189
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FlowDiagramProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type FlowDiagramOptions = BaseChartConfig & {
|
|
4
|
+
type: 'flow-diagram';
|
|
5
|
+
} & FlowDiagramProps;
|
|
6
|
+
export declare function FlowDiagram(options: FlowDiagramOptions): Promise<import("@antv/g6-ssr").Graph>;
|
|
@@ -0,0 +1,82 @@
|
|
|
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/ssr/flow-diagram.ts
|
|
20
|
+
var flow_diagram_exports = {};
|
|
21
|
+
__export(flow_diagram_exports, {
|
|
22
|
+
FlowDiagram: () => FlowDiagram
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(flow_diagram_exports);
|
|
25
|
+
var import_g6_ssr = require("@antv/g6-ssr");
|
|
26
|
+
async function FlowDiagram(options) {
|
|
27
|
+
const { data, width = 600, height = 400 } = options;
|
|
28
|
+
const graphData = {
|
|
29
|
+
nodes: data.nodes.map((node) => ({ ...node, id: node.name })),
|
|
30
|
+
edges: data.edges.map((edge) => ({ ...edge, id: `${edge.source}-${edge.target}` }))
|
|
31
|
+
};
|
|
32
|
+
return await (0, import_g6_ssr.createGraph)({
|
|
33
|
+
data: graphData,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
devicePixelRatio: 3,
|
|
37
|
+
autoFit: "view",
|
|
38
|
+
padding: 20,
|
|
39
|
+
animation: false,
|
|
40
|
+
node: {
|
|
41
|
+
type: "rect",
|
|
42
|
+
style: {
|
|
43
|
+
size: (d) => [d.name.length * 15 + 30, 35],
|
|
44
|
+
radius: 6,
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
iconText: (d) => d.name,
|
|
47
|
+
iconFontSize: 12,
|
|
48
|
+
iconFontWeight: 800
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
edge: {
|
|
52
|
+
type: "polyline",
|
|
53
|
+
style: {
|
|
54
|
+
lineWidth: 2,
|
|
55
|
+
radius: 10,
|
|
56
|
+
stroke: "#99ADD1",
|
|
57
|
+
endArrow: true,
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
labelText: (d) => d.name,
|
|
60
|
+
labelFill: "#555555",
|
|
61
|
+
labelFontWeight: 800,
|
|
62
|
+
labelBackground: true,
|
|
63
|
+
labelBackgroundFill: "rgba(255,255,255,0.6)",
|
|
64
|
+
labelBackgroundOpacity: 1,
|
|
65
|
+
labelBackgroundLineWidth: 2,
|
|
66
|
+
labelPadding: [2, 5],
|
|
67
|
+
labelBackgroundRadius: 2,
|
|
68
|
+
router: {
|
|
69
|
+
type: "orth"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
layout: {
|
|
74
|
+
type: "dagre",
|
|
75
|
+
rankdir: "LR"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
FlowDiagram
|
|
82
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HistogramProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type HistogramOptions = BaseChartConfig & {
|
|
4
|
+
type: 'histogram';
|
|
5
|
+
} & HistogramProps;
|
|
6
|
+
export declare function Histogram(options: HistogramOptions): Promise<import("@antv/g2-ssr").Chart>;
|
|
@@ -0,0 +1,50 @@
|
|
|
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/ssr/histogram.ts
|
|
20
|
+
var histogram_exports = {};
|
|
21
|
+
__export(histogram_exports, {
|
|
22
|
+
Histogram: () => Histogram
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(histogram_exports);
|
|
25
|
+
var import_g2_ssr = require("@antv/g2-ssr");
|
|
26
|
+
async function Histogram(options) {
|
|
27
|
+
const { data, title, width, height, axisYTitle, axisXTitle, binNumber } = options;
|
|
28
|
+
return await (0, import_g2_ssr.createChart)({
|
|
29
|
+
type: "interval",
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
data,
|
|
33
|
+
title,
|
|
34
|
+
encode: {
|
|
35
|
+
x: (d) => d,
|
|
36
|
+
y: "count"
|
|
37
|
+
},
|
|
38
|
+
transform: [{ type: "binX", y: "count", thresholds: binNumber }],
|
|
39
|
+
style: { minHeight: 1, columnWidthRatio: 1, inset: 0.5 },
|
|
40
|
+
axis: {
|
|
41
|
+
x: { title: axisXTitle },
|
|
42
|
+
y: { title: axisYTitle }
|
|
43
|
+
},
|
|
44
|
+
animate: false
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
Histogram
|
|
50
|
+
});
|