@antv/gpt-vis 1.0.0-beta.2 → 1.0.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 +282 -43
- package/README.zh-CN.md +286 -47
- package/dist/cjs/gpt-vis/index.js +1 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/util/animation.d.ts +2 -0
- package/dist/cjs/util/animation.js +38 -0
- package/dist/cjs/util/components.d.ts +15 -0
- package/dist/cjs/util/components.js +94 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +9 -0
- package/dist/cjs/util/crosshair-axis-labels.js +304 -0
- package/dist/cjs/util/index.d.ts +6 -0
- package/dist/cjs/util/index.js +33 -0
- package/dist/cjs/util/interaction.d.ts +14 -0
- package/dist/cjs/util/interaction.js +89 -0
- package/dist/cjs/util/theme.d.ts +18 -24
- package/dist/cjs/util/theme.js +303 -120
- package/dist/cjs/util/tokens.d.ts +31 -0
- package/dist/cjs/util/tokens.js +98 -0
- package/dist/cjs/vis/area/index.d.ts +2 -2
- package/dist/cjs/vis/area/index.js +76 -31
- package/dist/cjs/vis/bar/index.d.ts +2 -2
- package/dist/cjs/vis/bar/index.js +22 -19
- package/dist/cjs/vis/boxplot/index.js +1 -4
- package/dist/cjs/vis/column/index.d.ts +2 -2
- package/dist/cjs/vis/column/index.js +28 -18
- package/dist/cjs/vis/dual-axes/index.d.ts +2 -2
- package/dist/cjs/vis/dual-axes/index.js +90 -36
- package/dist/cjs/vis/fishbone-diagram/index.js +12 -4
- package/dist/cjs/vis/flow-diagram/index.js +27 -11
- package/dist/cjs/vis/funnel/index.d.ts +4 -2
- package/dist/cjs/vis/funnel/index.js +171 -92
- package/dist/cjs/vis/histogram/index.js +1 -4
- package/dist/cjs/vis/indented-tree/index.js +13 -3
- package/dist/cjs/vis/line/index.d.ts +2 -2
- package/dist/cjs/vis/line/index.js +71 -31
- package/dist/cjs/vis/liquid/index.d.ts +2 -2
- package/dist/cjs/vis/liquid/index.js +41 -16
- package/dist/cjs/vis/mindmap/index.js +12 -4
- package/dist/cjs/vis/network-graph/index.js +11 -2
- package/dist/cjs/vis/organization-chart/index.js +12 -3
- package/dist/cjs/vis/pie/index.d.ts +2 -2
- package/dist/cjs/vis/pie/index.js +26 -16
- package/dist/cjs/vis/radar/index.d.ts +2 -2
- package/dist/cjs/vis/radar/index.js +21 -29
- package/dist/cjs/vis/sankey/index.js +1 -4
- package/dist/cjs/vis/scatter/index.d.ts +4 -2
- package/dist/cjs/vis/scatter/index.js +43 -16
- package/dist/cjs/vis/treemap/index.js +1 -4
- package/dist/cjs/vis/venn/index.js +1 -4
- package/dist/cjs/vis/violin/index.js +1 -1
- package/dist/cjs/vis/waterfall/index.js +2 -2
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -2
- package/dist/cjs/vis/word-cloud/index.js +125 -10
- package/dist/esm/gpt-vis/index.js +1 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/util/animation.d.ts +2 -0
- package/dist/esm/util/animation.js +17 -0
- package/dist/esm/util/components.d.ts +15 -0
- package/dist/esm/util/components.js +67 -0
- package/dist/esm/util/crosshair-axis-labels.d.ts +9 -0
- package/dist/esm/util/crosshair-axis-labels.js +328 -0
- package/dist/esm/util/index.d.ts +6 -0
- package/dist/esm/util/index.js +6 -0
- package/dist/esm/util/interaction.d.ts +14 -0
- package/dist/esm/util/interaction.js +73 -0
- package/dist/esm/util/theme.d.ts +18 -24
- package/dist/esm/util/theme.js +302 -126
- package/dist/esm/util/tokens.d.ts +31 -0
- package/dist/esm/util/tokens.js +64 -0
- package/dist/esm/vis/area/index.d.ts +2 -2
- package/dist/esm/vis/area/index.js +91 -41
- package/dist/esm/vis/bar/index.d.ts +2 -2
- package/dist/esm/vis/bar/index.js +28 -29
- package/dist/esm/vis/boxplot/index.js +4 -5
- package/dist/esm/vis/column/index.d.ts +2 -2
- package/dist/esm/vis/column/index.js +36 -29
- package/dist/esm/vis/dual-axes/index.d.ts +2 -2
- package/dist/esm/vis/dual-axes/index.js +123 -43
- package/dist/esm/vis/fishbone-diagram/index.js +6 -5
- package/dist/esm/vis/flow-diagram/index.js +17 -10
- package/dist/esm/vis/funnel/index.d.ts +4 -2
- package/dist/esm/vis/funnel/index.js +156 -83
- package/dist/esm/vis/histogram/index.js +4 -5
- package/dist/esm/vis/indented-tree/index.js +9 -4
- package/dist/esm/vis/line/index.d.ts +2 -2
- package/dist/esm/vis/line/index.js +80 -37
- package/dist/esm/vis/liquid/index.d.ts +2 -2
- package/dist/esm/vis/liquid/index.js +41 -14
- package/dist/esm/vis/mindmap/index.js +6 -5
- package/dist/esm/vis/network-graph/index.js +5 -3
- package/dist/esm/vis/organization-chart/index.js +6 -4
- package/dist/esm/vis/pie/index.d.ts +2 -2
- package/dist/esm/vis/pie/index.js +36 -16
- package/dist/esm/vis/radar/index.d.ts +2 -2
- package/dist/esm/vis/radar/index.js +21 -34
- package/dist/esm/vis/sankey/index.js +4 -5
- package/dist/esm/vis/scatter/index.d.ts +4 -2
- package/dist/esm/vis/scatter/index.js +45 -19
- package/dist/esm/vis/treemap/index.js +4 -5
- package/dist/esm/vis/venn/index.js +4 -5
- package/dist/esm/vis/violin/index.js +5 -13
- package/dist/esm/vis/waterfall/index.js +11 -11
- package/dist/esm/vis/word-cloud/index.d.ts +3 -2
- package/dist/esm/vis/word-cloud/index.js +158 -10
- package/dist/umd/index.min.js +1 -1
- package/package.json +18 -19
|
@@ -23,7 +23,7 @@ __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_util = require("../../util");
|
|
27
27
|
var DEFAULT_WIDTH = 640;
|
|
28
28
|
var DEFAULT_HEIGHT = 480;
|
|
29
29
|
var Liquid = (options) => {
|
|
@@ -34,10 +34,18 @@ var Liquid = (options) => {
|
|
|
34
34
|
if (chart) {
|
|
35
35
|
chart.destroy();
|
|
36
36
|
}
|
|
37
|
-
const colors = (0,
|
|
38
|
-
const backgroundColor = style.backgroundColor || (0,
|
|
37
|
+
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
38
|
+
const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
|
|
39
|
+
const tokens = (0, import_util.getChartVisualTokens)(theme);
|
|
40
|
+
const normalizedPercent = Number.isFinite(percent) ? Math.max(0, Math.min(1, percent)) : 0;
|
|
39
41
|
const inferFontSize = Math.min(width ?? DEFAULT_WIDTH, height ?? DEFAULT_HEIGHT) / 10;
|
|
40
42
|
const fontSize = Math.min(Math.max(inferFontSize, 24), 64);
|
|
43
|
+
const chartSize = Math.min(width ?? DEFAULT_WIDTH, height ?? DEFAULT_HEIGHT);
|
|
44
|
+
const waveLength = Math.min(Math.max(chartSize * 0.4, 96), 192);
|
|
45
|
+
const formattedPercent = `${Number((normalizedPercent * 100).toFixed(1))}%`;
|
|
46
|
+
const liquidColor = colors[0];
|
|
47
|
+
const isAcademy = theme === "academy";
|
|
48
|
+
const outlineShadowColor = theme === "dark" ? "rgba(0, 0, 0, 0.32)" : "rgba(15, 23, 42, 0.10)";
|
|
41
49
|
chart = new import_g2.Chart({
|
|
42
50
|
container,
|
|
43
51
|
width,
|
|
@@ -47,25 +55,42 @@ var Liquid = (options) => {
|
|
|
47
55
|
const chartOptions = {
|
|
48
56
|
animate: false,
|
|
49
57
|
type: "liquid",
|
|
50
|
-
data:
|
|
51
|
-
title: title
|
|
58
|
+
data: normalizedPercent,
|
|
59
|
+
title: title || "",
|
|
60
|
+
inset: 20,
|
|
52
61
|
style: {
|
|
53
62
|
shape,
|
|
63
|
+
contentText: formattedPercent,
|
|
54
64
|
contentFontSize: fontSize,
|
|
55
|
-
contentFill:
|
|
56
|
-
contentStroke:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
contentFill: tokens.textPrimary,
|
|
66
|
+
contentStroke: backgroundColor,
|
|
67
|
+
contentStrokeOpacity: 0.92,
|
|
68
|
+
contentLineWidth: theme === "dark" ? 3 : 2.5,
|
|
69
|
+
contentFontFamily: import_util.CHART_FONT_FAMILY,
|
|
70
|
+
contentFontWeight: 600,
|
|
71
|
+
contentLetterSpacing: -0.8,
|
|
72
|
+
contentFontVariantNumeric: "tabular-nums",
|
|
73
|
+
contentPaintOrder: "stroke",
|
|
74
|
+
backgroundFill: liquidColor,
|
|
75
|
+
backgroundFillOpacity: theme === "dark" ? 0.14 : isAcademy ? 0.06 : 0.08,
|
|
76
|
+
backgroundStroke: liquidColor,
|
|
77
|
+
backgroundStrokeOpacity: theme === "dark" ? 0.3 : 0.22,
|
|
78
|
+
backgroundLineWidth: 1,
|
|
79
|
+
outlineBorder: isAcademy ? 1.5 : 2,
|
|
80
|
+
outlineDistance: 0,
|
|
81
|
+
outlineStrokeOpacity: isAcademy ? 0.9 : 0.72,
|
|
82
|
+
outlineShadowColor: isAcademy ? "transparent" : outlineShadowColor,
|
|
83
|
+
outlineShadowBlur: isAcademy ? 0 : 6,
|
|
84
|
+
outlineShadowOffsetY: isAcademy ? 0 : 2,
|
|
85
|
+
waveLength,
|
|
86
|
+
waveCount: 2,
|
|
87
|
+
fillOpacity: isAcademy ? 0.9 : 0.88,
|
|
61
88
|
contentPointerEvents: "none",
|
|
62
89
|
// Use palette color if provided
|
|
63
|
-
...
|
|
90
|
+
...liquidColor ? { fill: liquidColor, outlineStroke: liquidColor } : {}
|
|
64
91
|
},
|
|
65
|
-
viewStyle: {
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
theme: (0, import_theme.getThemeObject)(theme),
|
|
92
|
+
viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
|
|
93
|
+
theme: (0, import_util.getThemeObject)(theme),
|
|
69
94
|
tooltip: false
|
|
70
95
|
};
|
|
71
96
|
chart.options(chartOptions);
|
|
@@ -111,12 +111,20 @@ var Mindmap = (options) => {
|
|
|
111
111
|
height,
|
|
112
112
|
autoFit: "view",
|
|
113
113
|
autoResize: true,
|
|
114
|
-
padding: 20,
|
|
114
|
+
padding: title ? [46, 20, 20, 20] : 20,
|
|
115
115
|
zoomRange: [0.1, 5],
|
|
116
116
|
zoom: 1,
|
|
117
|
-
theme:
|
|
117
|
+
theme: (0, import_theme.getTheme)(theme),
|
|
118
118
|
data: graphData,
|
|
119
|
-
plugins: title ? [
|
|
119
|
+
plugins: title ? [
|
|
120
|
+
{
|
|
121
|
+
key: "title",
|
|
122
|
+
type: "title",
|
|
123
|
+
title,
|
|
124
|
+
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
125
|
+
titleFontFamily: "sans-serif"
|
|
126
|
+
}
|
|
127
|
+
] : [],
|
|
120
128
|
node: {
|
|
121
129
|
type: "rect",
|
|
122
130
|
animation: { translate: false, update: false },
|
|
@@ -134,7 +142,7 @@ var Mindmap = (options) => {
|
|
|
134
142
|
const base = {
|
|
135
143
|
size: [nodeWidth, nodeHeight],
|
|
136
144
|
dx,
|
|
137
|
-
radius: 8,
|
|
145
|
+
radius: theme === "academy" ? 0 : 8,
|
|
138
146
|
labelText: label,
|
|
139
147
|
labelPlacement: "center",
|
|
140
148
|
labelFontSize: fontSize,
|
|
@@ -119,7 +119,8 @@ var NetworkGraph = (options) => {
|
|
|
119
119
|
height,
|
|
120
120
|
autoFit: "view",
|
|
121
121
|
autoResize: true,
|
|
122
|
-
|
|
122
|
+
theme: (0, import_theme.getTheme)(theme),
|
|
123
|
+
padding: title ? [46, 20, 20, 20] : 20,
|
|
123
124
|
data: {
|
|
124
125
|
nodes: nodeData,
|
|
125
126
|
edges: edgeData
|
|
@@ -132,7 +133,15 @@ var NetworkGraph = (options) => {
|
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
135
|
behaviors: ["drag-canvas", "drag-element", "click-select"],
|
|
135
|
-
plugins: title ? [
|
|
136
|
+
plugins: title ? [
|
|
137
|
+
{
|
|
138
|
+
key: "title",
|
|
139
|
+
type: "title",
|
|
140
|
+
title,
|
|
141
|
+
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
142
|
+
titleFontFamily: "sans-serif"
|
|
143
|
+
}
|
|
144
|
+
] : []
|
|
136
145
|
});
|
|
137
146
|
graph.render();
|
|
138
147
|
};
|
|
@@ -83,7 +83,8 @@ var OrganizationChart = (options) => {
|
|
|
83
83
|
height,
|
|
84
84
|
autoFit: "view",
|
|
85
85
|
autoResize: true,
|
|
86
|
-
|
|
86
|
+
theme: (0, import_theme.getTheme)(theme),
|
|
87
|
+
padding: title ? [46, 20, 20, 20] : 20,
|
|
87
88
|
data: { nodes: nodeData, edges: edgeData },
|
|
88
89
|
plugins: [
|
|
89
90
|
{
|
|
@@ -119,7 +120,15 @@ var OrganizationChart = (options) => {
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
},
|
|
122
|
-
...title ? [
|
|
123
|
+
...title ? [
|
|
124
|
+
{
|
|
125
|
+
key: "title",
|
|
126
|
+
type: "title",
|
|
127
|
+
title,
|
|
128
|
+
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
129
|
+
titleFontFamily: "sans-serif"
|
|
130
|
+
}
|
|
131
|
+
] : []
|
|
123
132
|
],
|
|
124
133
|
node: {
|
|
125
134
|
type: "rect",
|
|
@@ -132,7 +141,7 @@ var OrganizationChart = (options) => {
|
|
|
132
141
|
fill: (d) => colors[d.data.depth % colors.length],
|
|
133
142
|
stroke: isDark ? "#555" : "#e8ebf0",
|
|
134
143
|
lineWidth: 1,
|
|
135
|
-
radius: 8,
|
|
144
|
+
radius: theme === "academy" ? 0 : 8,
|
|
136
145
|
// Use official label wrapping/ellipsis for BOTH name & description.
|
|
137
146
|
// 1 line name + up to 2 lines description => total maxLines = 3.
|
|
138
147
|
labelText: (d) => d.data.description ? `${d.data.name}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* PieDataItem is the type for each data item in the pie chart.
|
|
4
4
|
*/
|
|
@@ -13,7 +13,7 @@ export interface PieConfig {
|
|
|
13
13
|
type?: 'pie';
|
|
14
14
|
data: PieDataItem[];
|
|
15
15
|
innerRadius?: number;
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
18
|
style?: {
|
|
19
19
|
backgroundColor?: string;
|
|
@@ -23,18 +23,19 @@ __export(pie_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(pie_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_util = require("../../util");
|
|
27
27
|
var Pie = (options) => {
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
|
+
let hasRendered = false;
|
|
30
31
|
const PERCENTAGE_PRECISION_MULTIPLIER = 1e4;
|
|
31
32
|
const render = (config) => {
|
|
32
33
|
const { data = [], innerRadius = 0, theme = chartTheme, title, style = {} } = config;
|
|
33
34
|
if (chart) {
|
|
34
35
|
chart.destroy();
|
|
35
36
|
}
|
|
36
|
-
const colors = (0,
|
|
37
|
-
const
|
|
37
|
+
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
38
|
+
const tokens = (0, import_util.getChartVisualTokens)(theme);
|
|
38
39
|
const sumValue = data.reduce((sum, item) => sum + item.value, 0);
|
|
39
40
|
chart = new import_g2.Chart({
|
|
40
41
|
container,
|
|
@@ -43,10 +44,10 @@ var Pie = (options) => {
|
|
|
43
44
|
autoFit: true
|
|
44
45
|
});
|
|
45
46
|
const chartOptions = {
|
|
46
|
-
animate:
|
|
47
|
+
animate: (0, import_util.getChartAnimation)(hasRendered, "waveIn"),
|
|
47
48
|
type: "interval",
|
|
48
49
|
data,
|
|
49
|
-
title: title
|
|
50
|
+
title: title || "",
|
|
50
51
|
encode: {
|
|
51
52
|
y: "value",
|
|
52
53
|
color: "category"
|
|
@@ -56,14 +57,13 @@ var Pie = (options) => {
|
|
|
56
57
|
scale: {
|
|
57
58
|
color: { range: colors }
|
|
58
59
|
},
|
|
59
|
-
legend:
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
labels: [
|
|
60
|
+
legend: (0, import_util.getColorLegend)(true),
|
|
61
|
+
labels: data.length > 8 ? [] : [
|
|
63
62
|
{
|
|
64
63
|
text: (d) => {
|
|
65
|
-
const percentage = Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER;
|
|
66
|
-
|
|
64
|
+
const percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
|
|
65
|
+
const formattedPercentage = Number(percentage.toFixed(1)).toString();
|
|
66
|
+
return `${d.category}: ${formattedPercentage}%`;
|
|
67
67
|
},
|
|
68
68
|
position: "outside",
|
|
69
69
|
transform: [{ type: "overlapHide" }]
|
|
@@ -78,24 +78,34 @@ var Pie = (options) => {
|
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
80
|
interaction: {
|
|
81
|
+
tooltip: true,
|
|
82
|
+
elementHighlight: true,
|
|
83
|
+
elementHoverScale: { shadow: false },
|
|
81
84
|
elementSelect: { single: true }
|
|
82
85
|
},
|
|
83
|
-
|
|
84
|
-
fillOpacity:
|
|
86
|
+
state: {
|
|
87
|
+
active: { fillOpacity: 1, lineWidth: 3 },
|
|
88
|
+
inactive: { fillOpacity: 0.3 },
|
|
89
|
+
selected: { fillOpacity: 1, lineWidth: 3 }
|
|
85
90
|
},
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
style: {
|
|
92
|
+
fillOpacity: 1,
|
|
93
|
+
stroke: tokens.separator,
|
|
94
|
+
lineWidth: 2
|
|
88
95
|
},
|
|
89
|
-
|
|
96
|
+
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
97
|
+
theme: (0, import_util.getThemeObject)(theme)
|
|
90
98
|
};
|
|
91
99
|
chart.options(chartOptions);
|
|
92
100
|
chart.render();
|
|
101
|
+
hasRendered = true;
|
|
93
102
|
};
|
|
94
103
|
const destroy = () => {
|
|
95
104
|
if (chart) {
|
|
96
105
|
chart.destroy();
|
|
97
106
|
chart = null;
|
|
98
107
|
}
|
|
108
|
+
hasRendered = false;
|
|
99
109
|
};
|
|
100
110
|
return {
|
|
101
111
|
render,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* RadarDataItem is the type for each data item in the radar chart.
|
|
4
4
|
*/
|
|
@@ -15,7 +15,7 @@ export interface RadarConfig {
|
|
|
15
15
|
data: RadarDataItem[];
|
|
16
16
|
title?: string;
|
|
17
17
|
align?: boolean;
|
|
18
|
-
theme?:
|
|
18
|
+
theme?: VisualizationTheme;
|
|
19
19
|
style?: {
|
|
20
20
|
backgroundColor?: string;
|
|
21
21
|
palette?: string[];
|
|
@@ -23,7 +23,7 @@ __export(radar_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(radar_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_util = require("../../util");
|
|
27
27
|
function transformRadarToParallel(data) {
|
|
28
28
|
if (!data || data.length === 0) {
|
|
29
29
|
return [];
|
|
@@ -55,11 +55,12 @@ var Radar = (options) => {
|
|
|
55
55
|
if (chart) {
|
|
56
56
|
chart.destroy();
|
|
57
57
|
}
|
|
58
|
-
const { lineWidth =
|
|
59
|
-
const colors = (0,
|
|
60
|
-
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
58
|
+
const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
|
|
59
|
+
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
61
60
|
const parallelData = transformRadarToParallel(data);
|
|
62
61
|
const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
|
|
62
|
+
const hasMultipleSeries = parallelData.length > 1;
|
|
63
|
+
const legend = (0, import_util.getColorLegend)(hasMultipleSeries);
|
|
63
64
|
chart = new import_g2.Chart({
|
|
64
65
|
container,
|
|
65
66
|
width,
|
|
@@ -70,9 +71,9 @@ var Radar = (options) => {
|
|
|
70
71
|
animate: false,
|
|
71
72
|
type: "line",
|
|
72
73
|
data: parallelData,
|
|
73
|
-
title: title
|
|
74
|
+
title: title || "",
|
|
74
75
|
coordinate: { type: "radar" },
|
|
75
|
-
inset:
|
|
76
|
+
inset: 24,
|
|
76
77
|
encode: {
|
|
77
78
|
position,
|
|
78
79
|
color: "group"
|
|
@@ -96,42 +97,33 @@ var Radar = (options) => {
|
|
|
96
97
|
Array.from({ length: position.length }, (_, i) => [
|
|
97
98
|
`position${i === 0 ? "" : i}`,
|
|
98
99
|
{
|
|
99
|
-
|
|
100
|
-
titleFontSize: 10,
|
|
101
|
-
titleSpacing: 8,
|
|
102
|
-
label: true,
|
|
103
|
-
labelFill: theme === "dark" ? "#fff" : "#000",
|
|
104
|
-
labelOpacity: 0.45,
|
|
105
|
-
labelFontSize: 10,
|
|
106
|
-
line: true,
|
|
107
|
-
lineFill: "#000",
|
|
108
|
-
lineStrokeOpacity: 0.25,
|
|
100
|
+
label: align ? i === 0 : true,
|
|
109
101
|
tickFilter: (_2, idx) => {
|
|
110
102
|
return !(i !== 0 && idx === 0);
|
|
111
103
|
},
|
|
112
|
-
|
|
113
|
-
gridStrokeOpacity: 0.45,
|
|
114
|
-
gridStroke: theme === "dark" ? "#fff" : "#000",
|
|
115
|
-
gridLineWidth: 1,
|
|
116
|
-
gridLineDash: [4, 4]
|
|
104
|
+
grid: i === 0
|
|
117
105
|
}
|
|
118
106
|
])
|
|
119
107
|
),
|
|
120
108
|
style: {
|
|
121
109
|
lineWidth,
|
|
122
110
|
lineCap: "round",
|
|
123
|
-
lineJoin: "round"
|
|
111
|
+
lineJoin: "round",
|
|
112
|
+
strokeOpacity: import_util.CHART_STYLE_DEFAULTS.lineOpacity
|
|
124
113
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
114
|
+
state: hasMultipleSeries ? (0, import_util.getLineHighlightState)(lineWidth) : void 0,
|
|
115
|
+
legend: legend === false ? false : {
|
|
116
|
+
color: {
|
|
117
|
+
...legend.color,
|
|
118
|
+
itemMarker: "smooth"
|
|
129
119
|
}
|
|
130
120
|
},
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
interaction: {
|
|
122
|
+
tooltip: true,
|
|
123
|
+
...hasMultipleSeries ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
|
|
133
124
|
},
|
|
134
|
-
|
|
125
|
+
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
126
|
+
theme: (0, import_util.getThemeObject)(theme)
|
|
135
127
|
};
|
|
136
128
|
chart.options(chartOptions);
|
|
137
129
|
chart.render();
|
|
@@ -33,7 +33,6 @@ var Sankey = (options) => {
|
|
|
33
33
|
chart.destroy();
|
|
34
34
|
}
|
|
35
35
|
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
36
|
-
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
37
36
|
chart = new import_g2.Chart({
|
|
38
37
|
container,
|
|
39
38
|
width,
|
|
@@ -67,9 +66,7 @@ var Sankey = (options) => {
|
|
|
67
66
|
nodeLineWidth: 1,
|
|
68
67
|
linkFillOpacity: 0.3
|
|
69
68
|
},
|
|
70
|
-
viewStyle: {
|
|
71
|
-
viewFill: backgroundColor
|
|
72
|
-
},
|
|
69
|
+
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
73
70
|
theme: (0, import_theme.getThemeObject)(theme),
|
|
74
71
|
legend: false,
|
|
75
72
|
tooltip: false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
4
4
|
*/
|
|
@@ -14,7 +14,9 @@ export interface ScatterConfig {
|
|
|
14
14
|
type?: 'scatter';
|
|
15
15
|
data: ScatterDataItem[];
|
|
16
16
|
title?: string;
|
|
17
|
-
|
|
17
|
+
axisXTitle?: string;
|
|
18
|
+
axisYTitle?: string;
|
|
19
|
+
theme?: VisualizationTheme;
|
|
18
20
|
style?: {
|
|
19
21
|
backgroundColor?: string;
|
|
20
22
|
palette?: string[];
|
|
@@ -23,18 +23,19 @@ __export(scatter_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(scatter_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_util = require("../../util");
|
|
27
27
|
var Scatter = (options) => {
|
|
28
28
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
29
|
let chart = null;
|
|
30
|
+
let hasRendered = false;
|
|
30
31
|
const render = (config) => {
|
|
31
32
|
var _a;
|
|
32
|
-
const { data = [], theme = chartTheme, title, style = {} } = config;
|
|
33
|
+
const { data = [], theme = chartTheme, title, axisXTitle, axisYTitle, style = {} } = config;
|
|
33
34
|
if (chart) {
|
|
34
35
|
chart.destroy();
|
|
35
36
|
}
|
|
36
|
-
const colors = (0,
|
|
37
|
-
const backgroundColor = style.backgroundColor || (0,
|
|
37
|
+
const colors = (0, import_util.normalizePalette)(style.palette, theme);
|
|
38
|
+
const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
|
|
38
39
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
39
40
|
chart = new import_g2.Chart({
|
|
40
41
|
container,
|
|
@@ -44,45 +45,71 @@ var Scatter = (options) => {
|
|
|
44
45
|
});
|
|
45
46
|
let encode = {};
|
|
46
47
|
const scaleConfig = {
|
|
47
|
-
y: { nice: true }
|
|
48
|
+
y: { nice: true },
|
|
49
|
+
x: { nice: true }
|
|
48
50
|
};
|
|
49
51
|
if (hasGroupField) {
|
|
50
|
-
encode = {
|
|
52
|
+
encode = {
|
|
53
|
+
x: "x",
|
|
54
|
+
y: "y",
|
|
55
|
+
color: "group",
|
|
56
|
+
shape: "point",
|
|
57
|
+
size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
|
|
58
|
+
};
|
|
51
59
|
scaleConfig.color = { range: colors };
|
|
52
60
|
} else {
|
|
53
|
-
encode = {
|
|
61
|
+
encode = {
|
|
62
|
+
x: "x",
|
|
63
|
+
y: "y",
|
|
64
|
+
shape: "point",
|
|
65
|
+
size: import_util.CHART_STYLE_DEFAULTS.scatterPointSize
|
|
66
|
+
};
|
|
54
67
|
}
|
|
55
68
|
const chartOptions = {
|
|
56
|
-
animate:
|
|
69
|
+
animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
|
|
57
70
|
type: "point",
|
|
58
71
|
data,
|
|
59
|
-
title: title
|
|
72
|
+
title: title || "",
|
|
60
73
|
encode,
|
|
61
|
-
legend: hasGroupField
|
|
74
|
+
legend: (0, import_util.getColorLegend)(hasGroupField),
|
|
62
75
|
scale: scaleConfig,
|
|
76
|
+
axis: (0, import_util.getCartesianAxis)({
|
|
77
|
+
axisXTitle,
|
|
78
|
+
axisYTitle
|
|
79
|
+
}),
|
|
63
80
|
style: {
|
|
64
|
-
lineWidth:
|
|
81
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
82
|
+
fillOpacity: 0.88,
|
|
83
|
+
stroke: backgroundColor,
|
|
84
|
+
...!hasGroupField ? { fill: colors[0] } : {}
|
|
65
85
|
},
|
|
86
|
+
// A same-color stroke enlarges the rendered path without changing its transform or
|
|
87
|
+
// hit area, so repeated pointer events cannot accumulate scale.
|
|
88
|
+
state: (0, import_util.getPointHighlightState)(),
|
|
66
89
|
tooltip: {
|
|
67
90
|
title: (d) => (d == null ? void 0 : d.group) ? d.group : false,
|
|
68
91
|
items: [
|
|
69
|
-
{ channel: "x", name: "x" },
|
|
70
|
-
{ channel: "y", name: "y" }
|
|
92
|
+
{ channel: "x", name: axisXTitle ?? "x" },
|
|
93
|
+
{ channel: "y", name: axisYTitle ?? "y" }
|
|
71
94
|
]
|
|
72
95
|
},
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
interaction: {
|
|
97
|
+
tooltip: true,
|
|
98
|
+
elementHighlight: true
|
|
75
99
|
},
|
|
76
|
-
|
|
100
|
+
viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
|
|
101
|
+
theme: (0, import_util.getThemeObject)(theme)
|
|
77
102
|
};
|
|
78
103
|
chart.options(chartOptions);
|
|
79
104
|
chart.render();
|
|
105
|
+
hasRendered = true;
|
|
80
106
|
};
|
|
81
107
|
const destroy = () => {
|
|
82
108
|
if (chart) {
|
|
83
109
|
chart.destroy();
|
|
84
110
|
chart = null;
|
|
85
111
|
}
|
|
112
|
+
hasRendered = false;
|
|
86
113
|
};
|
|
87
114
|
return {
|
|
88
115
|
render,
|
|
@@ -33,7 +33,6 @@ var Treemap = (options) => {
|
|
|
33
33
|
chart.destroy();
|
|
34
34
|
}
|
|
35
35
|
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
36
|
-
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
37
36
|
chart = new import_g2.Chart({
|
|
38
37
|
container,
|
|
39
38
|
width,
|
|
@@ -74,9 +73,7 @@ var Treemap = (options) => {
|
|
|
74
73
|
}
|
|
75
74
|
]
|
|
76
75
|
},
|
|
77
|
-
viewStyle: {
|
|
78
|
-
viewFill: backgroundColor
|
|
79
|
-
},
|
|
76
|
+
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
80
77
|
theme: (0, import_theme.getThemeObject)(theme),
|
|
81
78
|
scale: {
|
|
82
79
|
...colors.length > 0 ? {
|
|
@@ -43,7 +43,6 @@ var Venn = (options) => {
|
|
|
43
43
|
chart.destroy();
|
|
44
44
|
}
|
|
45
45
|
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
46
|
-
const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
|
|
47
46
|
const normalizedData = data.map((d) => ({
|
|
48
47
|
...d,
|
|
49
48
|
sets: normalizeVennSets(d.sets)
|
|
@@ -87,9 +86,7 @@ var Venn = (options) => {
|
|
|
87
86
|
fontSize: 10
|
|
88
87
|
}
|
|
89
88
|
],
|
|
90
|
-
viewStyle: {
|
|
91
|
-
viewFill: backgroundColor
|
|
92
|
-
},
|
|
89
|
+
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
93
90
|
theme: (0, import_theme.getThemeObject)(theme),
|
|
94
91
|
legend: false,
|
|
95
92
|
axis: false,
|
|
@@ -133,7 +133,7 @@ var Violin = (options) => {
|
|
|
133
133
|
legend: {
|
|
134
134
|
color: hasGroupField ? { position: "top" } : false
|
|
135
135
|
},
|
|
136
|
-
|
|
136
|
+
viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
|
|
137
137
|
theme: (0, import_theme.getThemeObject)(theme)
|
|
138
138
|
};
|
|
139
139
|
chart.options(chartOptions);
|
|
@@ -116,7 +116,7 @@ var Waterfall = (options) => {
|
|
|
116
116
|
style: {
|
|
117
117
|
maxWidth: 60,
|
|
118
118
|
stroke: "#666",
|
|
119
|
-
radius: 4,
|
|
119
|
+
...theme !== "academy" ? { radius: 4 } : {},
|
|
120
120
|
fill: (d) => {
|
|
121
121
|
return d.isTotal || d.isIntermediateTotal ? totalColor : d.__value__ > 0 ? positiveColor : negativeColor;
|
|
122
122
|
}
|
|
@@ -172,7 +172,7 @@ var Waterfall = (options) => {
|
|
|
172
172
|
}
|
|
173
173
|
],
|
|
174
174
|
legend: false,
|
|
175
|
-
|
|
175
|
+
viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
|
|
176
176
|
theme: (0, import_theme.getThemeObject)(theme)
|
|
177
177
|
};
|
|
178
178
|
chart.options(chartOptions);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* WordCloudDataItem is the type for each data item in the word cloud chart.
|
|
4
4
|
*/
|
|
@@ -12,8 +12,9 @@ export type WordCloudDataItem = {
|
|
|
12
12
|
export interface WordCloudConfig {
|
|
13
13
|
type?: 'word-cloud';
|
|
14
14
|
data: WordCloudDataItem[];
|
|
15
|
-
theme?:
|
|
15
|
+
theme?: VisualizationTheme;
|
|
16
16
|
title?: string;
|
|
17
|
+
locale?: string;
|
|
17
18
|
style?: {
|
|
18
19
|
backgroundColor?: string;
|
|
19
20
|
palette?: string[];
|