@antv/gpt-vis 1.0.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -6
- 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/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +58 -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 +107 -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 +44 -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/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +27 -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 +107 -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,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.
|
|
@@ -23,20 +23,38 @@ __export(pie_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(pie_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_components = require("../../util/components");
|
|
29
|
+
var import_interaction = require("../../util/interaction");
|
|
30
|
+
var import_tokens = require("../../util/tokens");
|
|
27
31
|
var Pie = (options) => {
|
|
28
32
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
33
|
let chart = null;
|
|
30
34
|
let hasRendered = false;
|
|
31
35
|
const PERCENTAGE_PRECISION_MULTIPLIER = 1e4;
|
|
32
36
|
const render = (config) => {
|
|
33
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
data = [],
|
|
39
|
+
innerRadius,
|
|
40
|
+
theme = chartTheme,
|
|
41
|
+
title,
|
|
42
|
+
subtitle,
|
|
43
|
+
style: localStyle = {}
|
|
44
|
+
} = config;
|
|
34
45
|
if (chart) {
|
|
35
46
|
chart.destroy();
|
|
36
47
|
}
|
|
37
|
-
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
38
|
-
const tokens = (0, import_util.getChartVisualTokens)(theme);
|
|
39
48
|
const sumValue = data.reduce((sum, item) => sum + item.value, 0);
|
|
49
|
+
const appearance = (0, import_g22.getThemeObject)("pie", theme, localStyle);
|
|
50
|
+
const { theme: rendererTheme } = appearance;
|
|
51
|
+
const intervalMark = {
|
|
52
|
+
fillOpacity: 1,
|
|
53
|
+
stroke: (0, import_tokens.getChartVisualTokens)(rendererTheme.type).separator,
|
|
54
|
+
lineWidth: 2,
|
|
55
|
+
...appearance.mark.interval
|
|
56
|
+
};
|
|
57
|
+
const colors = rendererTheme.category10;
|
|
40
58
|
chart = new import_g2.Chart({
|
|
41
59
|
container,
|
|
42
60
|
width,
|
|
@@ -47,28 +65,31 @@ var Pie = (options) => {
|
|
|
47
65
|
animate: (0, import_util.getChartAnimation)(hasRendered, "waveIn"),
|
|
48
66
|
type: "interval",
|
|
49
67
|
data,
|
|
50
|
-
title: title
|
|
68
|
+
title: title ? { title, subtitle } : "",
|
|
51
69
|
encode: {
|
|
52
70
|
y: "value",
|
|
53
71
|
color: "category"
|
|
54
72
|
},
|
|
55
73
|
transform: [{ type: "stackY" }],
|
|
56
|
-
coordinate: {
|
|
74
|
+
coordinate: {
|
|
75
|
+
type: "theta",
|
|
76
|
+
innerRadius: Math.max(0, Math.min(1, innerRadius ?? 0))
|
|
77
|
+
},
|
|
57
78
|
scale: {
|
|
58
79
|
color: { range: colors }
|
|
59
80
|
},
|
|
60
|
-
legend: (0,
|
|
61
|
-
labels:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
81
|
+
legend: (0, import_components.getColorLegend)(true),
|
|
82
|
+
labels: (0, import_components.getDataLabels)(rendererTheme, {
|
|
83
|
+
defaultVisible: data.length <= 8,
|
|
84
|
+
text: (d) => {
|
|
85
|
+
const percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
|
|
86
|
+
const formattedPercentage = Number(percentage.toFixed(1)).toString();
|
|
87
|
+
return `${d.category}: ${formattedPercentage}%`;
|
|
88
|
+
},
|
|
89
|
+
position: "outside",
|
|
90
|
+
contrast: "outside",
|
|
91
|
+
transform: [{ type: "exceedAdjust", offsetX: 4, offsetY: 4 }, { type: "overlapHide" }]
|
|
92
|
+
}),
|
|
72
93
|
tooltip: {
|
|
73
94
|
items: [
|
|
74
95
|
(d) => ({
|
|
@@ -79,8 +100,11 @@ var Pie = (options) => {
|
|
|
79
100
|
},
|
|
80
101
|
interaction: {
|
|
81
102
|
tooltip: true,
|
|
82
|
-
elementHighlight:
|
|
83
|
-
elementHoverScale: {
|
|
103
|
+
elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay },
|
|
104
|
+
elementHoverScale: {
|
|
105
|
+
...(0, import_interaction.getElementHoverScaleInteraction)(rendererTheme.type),
|
|
106
|
+
shadow: false
|
|
107
|
+
},
|
|
84
108
|
elementSelect: { single: true }
|
|
85
109
|
},
|
|
86
110
|
state: {
|
|
@@ -88,13 +112,8 @@ var Pie = (options) => {
|
|
|
88
112
|
inactive: { fillOpacity: 0.3 },
|
|
89
113
|
selected: { fillOpacity: 1, lineWidth: 3 }
|
|
90
114
|
},
|
|
91
|
-
style:
|
|
92
|
-
|
|
93
|
-
stroke: tokens.separator,
|
|
94
|
-
lineWidth: 2
|
|
95
|
-
},
|
|
96
|
-
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
97
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
115
|
+
style: intervalMark,
|
|
116
|
+
theme: rendererTheme
|
|
98
117
|
};
|
|
99
118
|
chart.options(chartOptions);
|
|
100
119
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* RadarDataItem is the type for each data item in the radar chart.
|
|
4
4
|
*/
|
|
@@ -14,13 +14,10 @@ export interface RadarConfig {
|
|
|
14
14
|
type?: 'radar';
|
|
15
15
|
data: RadarDataItem[];
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
align?: boolean;
|
|
18
19
|
theme?: VisualizationTheme;
|
|
19
|
-
style?:
|
|
20
|
-
backgroundColor?: string;
|
|
21
|
-
palette?: string[];
|
|
22
|
-
lineWidth?: number;
|
|
23
|
-
};
|
|
20
|
+
style?: ThemeStyle;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* RadarInstance represents a radar chart instance with render and destroy methods.
|
|
@@ -23,7 +23,10 @@ __export(radar_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(radar_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_components = require("../../util/components");
|
|
29
|
+
var import_tokens = require("../../util/tokens");
|
|
27
30
|
function transformRadarToParallel(data) {
|
|
28
31
|
if (!data || data.length === 0) {
|
|
29
32
|
return [];
|
|
@@ -51,16 +54,32 @@ var Radar = (options) => {
|
|
|
51
54
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
52
55
|
let chart = null;
|
|
53
56
|
const render = (config) => {
|
|
54
|
-
const {
|
|
57
|
+
const {
|
|
58
|
+
data = [],
|
|
59
|
+
theme = chartTheme,
|
|
60
|
+
title,
|
|
61
|
+
subtitle,
|
|
62
|
+
align = false,
|
|
63
|
+
style: localStyle = {}
|
|
64
|
+
} = config;
|
|
55
65
|
if (chart) {
|
|
56
66
|
chart.destroy();
|
|
57
67
|
}
|
|
58
|
-
const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
|
|
59
|
-
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
60
68
|
const parallelData = transformRadarToParallel(data);
|
|
69
|
+
const appearance = (0, import_g22.getThemeObject)("radar", theme, localStyle);
|
|
70
|
+
const { theme: rendererTheme } = appearance;
|
|
71
|
+
const lineMark = {
|
|
72
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
|
|
73
|
+
lineCap: "round",
|
|
74
|
+
lineJoin: "round",
|
|
75
|
+
strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.lineOpacity,
|
|
76
|
+
...appearance.mark.line
|
|
77
|
+
};
|
|
78
|
+
const lineWidth = lineMark.lineWidth ?? import_tokens.CHART_STYLE_DEFAULTS.lineWidth;
|
|
79
|
+
const colors = rendererTheme.category10;
|
|
61
80
|
const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
|
|
62
81
|
const hasMultipleSeries = parallelData.length > 1;
|
|
63
|
-
const legend = (0,
|
|
82
|
+
const legend = (0, import_components.getColorLegend)(parallelData.length > 1);
|
|
64
83
|
chart = new import_g2.Chart({
|
|
65
84
|
container,
|
|
66
85
|
width,
|
|
@@ -71,7 +90,7 @@ var Radar = (options) => {
|
|
|
71
90
|
animate: false,
|
|
72
91
|
type: "line",
|
|
73
92
|
data: parallelData,
|
|
74
|
-
title: title
|
|
93
|
+
title: title ? { title, subtitle } : "",
|
|
75
94
|
coordinate: { type: "radar" },
|
|
76
95
|
inset: 24,
|
|
77
96
|
encode: {
|
|
@@ -94,36 +113,25 @@ var Radar = (options) => {
|
|
|
94
113
|
}
|
|
95
114
|
},
|
|
96
115
|
axis: Object.fromEntries(
|
|
97
|
-
Array.from({ length: position.length }, (_, i) =>
|
|
98
|
-
|
|
99
|
-
{
|
|
116
|
+
Array.from({ length: position.length }, (_, i) => {
|
|
117
|
+
const defaults = {
|
|
100
118
|
label: align ? i === 0 : true,
|
|
101
119
|
tickFilter: (_2, idx) => {
|
|
102
120
|
return !(i !== 0 && idx === 0);
|
|
103
121
|
},
|
|
104
122
|
grid: i === 0
|
|
105
|
-
}
|
|
106
|
-
|
|
123
|
+
};
|
|
124
|
+
return [`position${i === 0 ? "" : i}`, { ...defaults, ...rendererTheme.axis }];
|
|
125
|
+
})
|
|
107
126
|
),
|
|
108
|
-
style:
|
|
109
|
-
lineWidth,
|
|
110
|
-
lineCap: "round",
|
|
111
|
-
lineJoin: "round",
|
|
112
|
-
strokeOpacity: import_util.CHART_STYLE_DEFAULTS.lineOpacity
|
|
113
|
-
},
|
|
127
|
+
style: lineMark,
|
|
114
128
|
state: hasMultipleSeries ? (0, import_util.getLineHighlightState)(lineWidth) : void 0,
|
|
115
|
-
legend: legend === false ? false : {
|
|
116
|
-
color: {
|
|
117
|
-
...legend.color,
|
|
118
|
-
itemMarker: "smooth"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
129
|
+
legend: legend === false ? false : { color: { ...legend.color, itemMarker: "smooth" } },
|
|
121
130
|
interaction: {
|
|
122
131
|
tooltip: true,
|
|
123
132
|
...hasMultipleSeries ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
|
|
124
133
|
},
|
|
125
|
-
|
|
126
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
134
|
+
theme: rendererTheme
|
|
127
135
|
};
|
|
128
136
|
chart.options(chartOptions);
|
|
129
137
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* SankeyDataItem is the type for each data item in the sankey chart.
|
|
4
4
|
*/
|
|
@@ -14,12 +14,10 @@ export interface SankeyConfig {
|
|
|
14
14
|
type?: 'sankey';
|
|
15
15
|
data: SankeyDataItem[];
|
|
16
16
|
nodeAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
17
|
-
theme?:
|
|
17
|
+
theme?: VisualizationTheme;
|
|
18
18
|
title?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
palette?: string[];
|
|
22
|
-
};
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
style?: ThemeStyle;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* SankeyInstance represents a sankey chart instance with render and destroy methods.
|
|
@@ -23,16 +23,26 @@ __export(sankey_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(sankey_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
27
27
|
var Sankey = (options) => {
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
30
|
const render = (config) => {
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
data = [],
|
|
33
|
+
nodeAlign = "center",
|
|
34
|
+
theme = chartTheme,
|
|
35
|
+
title,
|
|
36
|
+
subtitle,
|
|
37
|
+
style: localStyle = {}
|
|
38
|
+
} = config;
|
|
32
39
|
if (chart) {
|
|
33
40
|
chart.destroy();
|
|
34
41
|
}
|
|
35
|
-
const
|
|
42
|
+
const appearance = (0, import_g22.getThemeObject)("sankey", theme, localStyle);
|
|
43
|
+
const { theme: rendererTheme } = appearance;
|
|
44
|
+
const colors = rendererTheme.category10;
|
|
45
|
+
const sankeyStyle = appearance.mark.sankey;
|
|
36
46
|
chart = new import_g2.Chart({
|
|
37
47
|
container,
|
|
38
48
|
width,
|
|
@@ -57,17 +67,17 @@ var Sankey = (options) => {
|
|
|
57
67
|
nodeAlign,
|
|
58
68
|
nodePadding: 0.01
|
|
59
69
|
},
|
|
60
|
-
title: title
|
|
70
|
+
title: title ? { title, subtitle } : "",
|
|
61
71
|
scale: {
|
|
62
72
|
color: { range: colors }
|
|
63
73
|
},
|
|
64
74
|
style: {
|
|
65
75
|
labelSpacing: 2,
|
|
66
76
|
nodeLineWidth: 1,
|
|
67
|
-
linkFillOpacity: 0.3
|
|
77
|
+
linkFillOpacity: 0.3,
|
|
78
|
+
...sankeyStyle
|
|
68
79
|
},
|
|
69
|
-
|
|
70
|
-
theme: (0, import_theme.getThemeObject)(theme),
|
|
80
|
+
theme: rendererTheme,
|
|
71
81
|
legend: false,
|
|
72
82
|
tooltip: false
|
|
73
83
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
4
4
|
*/
|
|
@@ -14,13 +14,11 @@ export interface ScatterConfig {
|
|
|
14
14
|
type?: 'scatter';
|
|
15
15
|
data: ScatterDataItem[];
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
axisXTitle?: string;
|
|
18
19
|
axisYTitle?: string;
|
|
19
20
|
theme?: VisualizationTheme;
|
|
20
|
-
style?:
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
23
|
-
};
|
|
21
|
+
style?: ThemeStyle;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* ScatterInstance represents a scatter chart instance with render and destroy methods.
|
|
@@ -23,20 +23,41 @@ __export(scatter_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(scatter_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_util = require("../../util");
|
|
28
|
+
var import_components = require("../../util/components");
|
|
29
|
+
var import_tokens = require("../../util/tokens");
|
|
27
30
|
var Scatter = (options) => {
|
|
28
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
32
|
let chart = null;
|
|
30
33
|
let hasRendered = false;
|
|
31
34
|
const render = (config) => {
|
|
32
35
|
var _a;
|
|
33
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
data = [],
|
|
38
|
+
theme = chartTheme,
|
|
39
|
+
title,
|
|
40
|
+
subtitle,
|
|
41
|
+
axisXTitle,
|
|
42
|
+
axisYTitle,
|
|
43
|
+
style: localStyle = {}
|
|
44
|
+
} = config;
|
|
34
45
|
if (chart) {
|
|
35
46
|
chart.destroy();
|
|
36
47
|
}
|
|
37
|
-
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
38
|
-
const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
|
|
39
48
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
49
|
+
const appearance = (0, import_g22.getThemeObject)("scatter", theme, localStyle);
|
|
50
|
+
const { theme: rendererTheme } = appearance;
|
|
51
|
+
const pointStyle = {
|
|
52
|
+
shape: "point",
|
|
53
|
+
size: import_tokens.CHART_STYLE_DEFAULTS.scatterPointSize,
|
|
54
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
55
|
+
fillOpacity: 0.88,
|
|
56
|
+
stroke: rendererTheme.view.viewFill,
|
|
57
|
+
...appearance.mark.point
|
|
58
|
+
};
|
|
59
|
+
const colors = rendererTheme.category10;
|
|
60
|
+
const { size: pointSize, ...pointMark } = pointStyle;
|
|
40
61
|
chart = new import_g2.Chart({
|
|
41
62
|
container,
|
|
42
63
|
width,
|
|
@@ -53,34 +74,27 @@ var Scatter = (options) => {
|
|
|
53
74
|
x: "x",
|
|
54
75
|
y: "y",
|
|
55
76
|
color: "group",
|
|
56
|
-
|
|
57
|
-
size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
|
|
77
|
+
size: pointSize
|
|
58
78
|
};
|
|
59
79
|
scaleConfig.color = { range: colors };
|
|
60
80
|
} else {
|
|
61
81
|
encode = {
|
|
62
82
|
x: "x",
|
|
63
83
|
y: "y",
|
|
64
|
-
|
|
65
|
-
size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
|
|
84
|
+
size: pointSize
|
|
66
85
|
};
|
|
67
86
|
}
|
|
68
87
|
const chartOptions = {
|
|
69
88
|
animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
|
|
70
89
|
type: "point",
|
|
71
90
|
data,
|
|
72
|
-
title: title
|
|
91
|
+
title: title ? { title, subtitle } : "",
|
|
73
92
|
encode,
|
|
74
|
-
legend: (0,
|
|
93
|
+
legend: (0, import_components.getColorLegend)(hasGroupField),
|
|
75
94
|
scale: scaleConfig,
|
|
76
|
-
axis: (0, import_util.getCartesianAxis)({
|
|
77
|
-
axisXTitle,
|
|
78
|
-
axisYTitle
|
|
79
|
-
}),
|
|
95
|
+
axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
80
96
|
style: {
|
|
81
|
-
|
|
82
|
-
fillOpacity: 0.88,
|
|
83
|
-
stroke: backgroundColor,
|
|
97
|
+
...pointMark,
|
|
84
98
|
...!hasGroupField ? { fill: colors[0] } : {}
|
|
85
99
|
},
|
|
86
100
|
// A same-color stroke enlarges the rendered path without changing its transform or
|
|
@@ -95,10 +109,9 @@ var Scatter = (options) => {
|
|
|
95
109
|
},
|
|
96
110
|
interaction: {
|
|
97
111
|
tooltip: true,
|
|
98
|
-
elementHighlight:
|
|
112
|
+
elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay }
|
|
99
113
|
},
|
|
100
|
-
|
|
101
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
114
|
+
theme: rendererTheme
|
|
102
115
|
};
|
|
103
116
|
chart.options(chartOptions);
|
|
104
117
|
chart.render();
|
|
@@ -23,11 +23,10 @@ __export(summary_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(summary_exports);
|
|
25
25
|
var import_t8 = require("@antv/t8");
|
|
26
|
-
var
|
|
26
|
+
var import_summary = require("../../theme/summary");
|
|
27
27
|
var Summary = (options) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
theme = "light";
|
|
28
|
+
const appearance = (0, import_summary.getThemeObject)("summary", options.theme);
|
|
29
|
+
const { theme } = appearance;
|
|
31
30
|
const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
32
31
|
if (!container) {
|
|
33
32
|
throw new Error("Container not found");
|
|
@@ -46,9 +45,9 @@ var Summary = (options) => {
|
|
|
46
45
|
return "";
|
|
47
46
|
});
|
|
48
47
|
text = new import_t8.Text(wrapper);
|
|
49
|
-
wrapper.style.backgroundColor = activeTheme
|
|
48
|
+
wrapper.style.backgroundColor = appearance.backgrounds[activeTheme];
|
|
50
49
|
wrapper.style.padding = "16px";
|
|
51
|
-
text.theme(activeTheme);
|
|
50
|
+
text.theme(activeTheme, appearance.summary);
|
|
52
51
|
text.render(cleanedSyntax.trim());
|
|
53
52
|
};
|
|
54
53
|
const destroy = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* TableConfig defines the configuration for rendering the table.
|
|
4
4
|
*/
|
|
@@ -6,7 +6,9 @@ export interface TableConfig {
|
|
|
6
6
|
type?: 'table';
|
|
7
7
|
data: Record<string, any>[];
|
|
8
8
|
title?: string;
|
|
9
|
-
|
|
9
|
+
subtitle?: string;
|
|
10
|
+
theme?: VisualizationTheme;
|
|
11
|
+
style?: ThemeStyle;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* TableInstance represents a table instance with render and destroy methods.
|