@antv/gpt-vis 1.0.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -7
- package/README.zh-CN.md +32 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/presets.d.ts +5 -0
- package/dist/cjs/theme/presets.js +663 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +59 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +109 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/cjs/util/crosshair-axis-labels.js +17 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +9 -6
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +70 -52
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -5
- package/dist/cjs/vis/funnel/index.js +63 -42
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +46 -4
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/presets.d.ts +5 -0
- package/dist/esm/theme/presets.js +1070 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +31 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +109 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/esm/util/crosshair-axis-labels.js +18 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +9 -6
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +68 -58
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -5
- package/dist/esm/vis/funnel/index.js +63 -54
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +41 -4
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -23,7 +23,10 @@ __export(funnel_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(funnel_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 FUNNEL_LABELS = {
|
|
28
31
|
"en-US": {
|
|
29
32
|
baseline: "Baseline",
|
|
@@ -52,7 +55,14 @@ var Funnel = (options) => {
|
|
|
52
55
|
const { container, width, height, locale, theme: chartTheme = "default" } = options;
|
|
53
56
|
let chart = null;
|
|
54
57
|
const render = (config) => {
|
|
55
|
-
const {
|
|
58
|
+
const {
|
|
59
|
+
data = [],
|
|
60
|
+
theme = chartTheme,
|
|
61
|
+
title,
|
|
62
|
+
subtitle,
|
|
63
|
+
conversionRateLabel,
|
|
64
|
+
style: localStyle = {}
|
|
65
|
+
} = config;
|
|
56
66
|
const chartLocale = (0, import_util.resolveChartLocale)(locale);
|
|
57
67
|
const labels = FUNNEL_LABELS[chartLocale];
|
|
58
68
|
const numberFormatter = new Intl.NumberFormat(chartLocale);
|
|
@@ -61,9 +71,27 @@ var Funnel = (options) => {
|
|
|
61
71
|
if (chart) {
|
|
62
72
|
chart.destroy();
|
|
63
73
|
}
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
74
|
+
const appearance = (0, import_g22.getThemeObject)("funnel", theme, localStyle);
|
|
75
|
+
const { theme: rendererTheme } = appearance;
|
|
76
|
+
const intervalMark = {
|
|
77
|
+
shape: "funnel",
|
|
78
|
+
fillOpacity: 0.94,
|
|
79
|
+
stroke: (0, import_tokens.getChartVisualTokens)(rendererTheme.type).separator,
|
|
80
|
+
lineWidth: 2,
|
|
81
|
+
...rendererTheme.type === "academy" ? {} : { radius: 4 },
|
|
82
|
+
...appearance.mark.interval
|
|
83
|
+
};
|
|
84
|
+
const connectorStyle = {
|
|
85
|
+
stroke: (0, import_tokens.getChartVisualTokens)(rendererTheme.type).axisLine,
|
|
86
|
+
strokeOpacity: rendererTheme.type === "academy" ? 1 : 0.82,
|
|
87
|
+
lineWidth: rendererTheme.type === "academy" ? 1 : 0.75,
|
|
88
|
+
endMarker: false,
|
|
89
|
+
connectLength1: -12,
|
|
90
|
+
...appearance.mark.connector
|
|
91
|
+
};
|
|
92
|
+
const colors = rendererTheme.category10;
|
|
93
|
+
const tokens = (0, import_tokens.getChartVisualTokens)(rendererTheme.type);
|
|
94
|
+
const connectorMark = connectorStyle;
|
|
67
95
|
const formatValue = (value) => Number.isFinite(value) ? numberFormatter.format(value) : "—";
|
|
68
96
|
const isInverted = data.length > 1 && data[0].value < data[data.length - 1].value;
|
|
69
97
|
const metricsByCategory = new Map(
|
|
@@ -101,6 +129,20 @@ var Funnel = (options) => {
|
|
|
101
129
|
}
|
|
102
130
|
]
|
|
103
131
|
};
|
|
132
|
+
const primaryLabels = (0, import_components.getDataLabels)(rendererTheme, {
|
|
133
|
+
style: {
|
|
134
|
+
fontFamily: import_tokens.CHART_FONT_FAMILY,
|
|
135
|
+
fontSize: 12,
|
|
136
|
+
fontWeight: 500,
|
|
137
|
+
lineHeight: 17
|
|
138
|
+
},
|
|
139
|
+
defaultVisible: true,
|
|
140
|
+
text: (d) => `${d.category}
|
|
141
|
+
${formatValue(d.value)}`,
|
|
142
|
+
position: "inside",
|
|
143
|
+
contrast: "inside",
|
|
144
|
+
transform: [{ type: "overflowStroke" }]
|
|
145
|
+
}) ?? [];
|
|
104
146
|
chart = new import_g2.Chart({
|
|
105
147
|
container,
|
|
106
148
|
width,
|
|
@@ -113,7 +155,7 @@ var Funnel = (options) => {
|
|
|
113
155
|
animate: false,
|
|
114
156
|
type: "view",
|
|
115
157
|
data,
|
|
116
|
-
title: title
|
|
158
|
+
title: title ? { title, subtitle } : "",
|
|
117
159
|
children: [
|
|
118
160
|
{
|
|
119
161
|
type: "interval",
|
|
@@ -121,9 +163,7 @@ var Funnel = (options) => {
|
|
|
121
163
|
encode: {
|
|
122
164
|
x: "category",
|
|
123
165
|
y: "value",
|
|
124
|
-
color: "category"
|
|
125
|
-
shape: "funnel"
|
|
126
|
-
// Use funnel shape for proper funnel visualization
|
|
166
|
+
color: "category"
|
|
127
167
|
},
|
|
128
168
|
transform: [{ type: "symmetryY" }],
|
|
129
169
|
coordinate: { transform: [{ type: "transpose" }] },
|
|
@@ -134,18 +174,7 @@ var Funnel = (options) => {
|
|
|
134
174
|
legend: false,
|
|
135
175
|
tooltip: funnelTooltip,
|
|
136
176
|
labels: [
|
|
137
|
-
|
|
138
|
-
text: (d) => `${d.category}
|
|
139
|
-
${formatValue(d.value)}`,
|
|
140
|
-
position: "inside",
|
|
141
|
-
transform: [{ type: "contrastReverse" }, { type: "overflowStroke" }],
|
|
142
|
-
style: {
|
|
143
|
-
fontFamily: import_util.CHART_FONT_FAMILY,
|
|
144
|
-
fontSize: 12,
|
|
145
|
-
fontWeight: 500,
|
|
146
|
-
lineHeight: 17
|
|
147
|
-
}
|
|
148
|
-
},
|
|
177
|
+
...primaryLabels,
|
|
149
178
|
{
|
|
150
179
|
text: (_d, index, items) => (isInverted ? index < items.length - 1 : index > 0) ? "———" : "",
|
|
151
180
|
position: isInverted ? "bottom-right" : "top-right",
|
|
@@ -154,7 +183,7 @@ ${formatValue(d.value)}`,
|
|
|
154
183
|
dx: 8,
|
|
155
184
|
dy: isInverted ? 6 : -6,
|
|
156
185
|
style: {
|
|
157
|
-
fontFamily:
|
|
186
|
+
fontFamily: import_tokens.CHART_FONT_FAMILY,
|
|
158
187
|
fontSize: 8,
|
|
159
188
|
fontWeight: 400,
|
|
160
189
|
letterSpacing: -2
|
|
@@ -176,26 +205,20 @@ ${formatValue(d.value)}`,
|
|
|
176
205
|
fill: tokens.textPrimary,
|
|
177
206
|
dx: 26,
|
|
178
207
|
style: {
|
|
179
|
-
fontFamily:
|
|
208
|
+
fontFamily: import_tokens.CHART_FONT_FAMILY,
|
|
180
209
|
fontSize: 11,
|
|
181
210
|
fontWeight: 500
|
|
182
211
|
}
|
|
183
212
|
}
|
|
184
213
|
],
|
|
185
|
-
style:
|
|
186
|
-
fillOpacity: 0.94,
|
|
187
|
-
stroke: tokens.separator,
|
|
188
|
-
lineWidth: 2,
|
|
189
|
-
...theme === "academy" ? {} : { radius: 4 }
|
|
190
|
-
},
|
|
214
|
+
style: intervalMark,
|
|
191
215
|
state: {
|
|
192
216
|
active: {
|
|
193
217
|
fillOpacity: 1,
|
|
194
218
|
stroke: tokens.separator,
|
|
195
219
|
lineWidth: 3
|
|
196
220
|
}
|
|
197
|
-
}
|
|
198
|
-
viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0
|
|
221
|
+
}
|
|
199
222
|
},
|
|
200
223
|
...data.length > 1 ? [
|
|
201
224
|
{
|
|
@@ -208,15 +231,14 @@ ${formatValue(d.value)}`,
|
|
|
208
231
|
endY: Math.abs(data[0].value - data[data.length - 1].value) / 2
|
|
209
232
|
}
|
|
210
233
|
],
|
|
211
|
-
encode: {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
lineWidth: theme === "academy" ? 1 : 0.75,
|
|
217
|
-
markerEnd: false,
|
|
218
|
-
connectLength1: -12
|
|
234
|
+
encode: {
|
|
235
|
+
x: "startX",
|
|
236
|
+
x1: "startY",
|
|
237
|
+
y: "endX",
|
|
238
|
+
y1: "endY"
|
|
219
239
|
},
|
|
240
|
+
tooltip: false,
|
|
241
|
+
style: connectorMark,
|
|
220
242
|
labels: [
|
|
221
243
|
{
|
|
222
244
|
text: formatMetricLabel(
|
|
@@ -230,7 +252,7 @@ ${formatValue(d.value)}`,
|
|
|
230
252
|
fill: tokens.textPrimary,
|
|
231
253
|
dx: 8,
|
|
232
254
|
style: {
|
|
233
|
-
fontFamily:
|
|
255
|
+
fontFamily: import_tokens.CHART_FONT_FAMILY,
|
|
234
256
|
fontSize: 11,
|
|
235
257
|
fontWeight: 500
|
|
236
258
|
}
|
|
@@ -242,10 +264,9 @@ ${formatValue(d.value)}`,
|
|
|
242
264
|
axis: false,
|
|
243
265
|
interaction: {
|
|
244
266
|
tooltip: true,
|
|
245
|
-
elementHighlight:
|
|
267
|
+
elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay }
|
|
246
268
|
},
|
|
247
|
-
|
|
248
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
269
|
+
theme: rendererTheme
|
|
249
270
|
};
|
|
250
271
|
chart.options(chartOptions);
|
|
251
272
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* HistogramConfig defines the configuration for rendering the histogram chart.
|
|
4
4
|
*/
|
|
@@ -7,13 +7,11 @@ export interface HistogramConfig {
|
|
|
7
7
|
data: number[];
|
|
8
8
|
binNumber?: number;
|
|
9
9
|
title?: string;
|
|
10
|
+
subtitle?: string;
|
|
10
11
|
axisXTitle?: string;
|
|
11
12
|
axisYTitle?: string;
|
|
12
|
-
theme?:
|
|
13
|
-
style?:
|
|
14
|
-
backgroundColor?: string;
|
|
15
|
-
palette?: string[];
|
|
16
|
-
};
|
|
13
|
+
theme?: VisualizationTheme;
|
|
14
|
+
style?: ThemeStyle;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* HistogramInstance represents a histogram chart instance with render and destroy methods.
|
|
@@ -23,7 +23,8 @@ __export(histogram_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(histogram_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
-
var
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
27
|
+
var import_components = require("../../util/components");
|
|
27
28
|
var Histogram = (options) => {
|
|
28
29
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
30
|
let chart = null;
|
|
@@ -32,15 +33,24 @@ var Histogram = (options) => {
|
|
|
32
33
|
data = [],
|
|
33
34
|
theme = chartTheme,
|
|
34
35
|
title,
|
|
36
|
+
subtitle,
|
|
35
37
|
axisXTitle,
|
|
36
38
|
axisYTitle,
|
|
37
39
|
binNumber,
|
|
38
|
-
style = {}
|
|
40
|
+
style: localStyle = {}
|
|
39
41
|
} = config;
|
|
40
42
|
if (chart) {
|
|
41
43
|
chart.destroy();
|
|
42
44
|
}
|
|
43
|
-
const
|
|
45
|
+
const appearance = (0, import_g22.getThemeObject)("histogram", theme, localStyle);
|
|
46
|
+
const { theme: rendererTheme } = appearance;
|
|
47
|
+
const intervalMark = {
|
|
48
|
+
minHeight: 1,
|
|
49
|
+
columnWidthRatio: 1,
|
|
50
|
+
inset: 0.5,
|
|
51
|
+
...appearance.mark.interval
|
|
52
|
+
};
|
|
53
|
+
const colors = rendererTheme.category10;
|
|
44
54
|
chart = new import_g2.Chart({
|
|
45
55
|
container,
|
|
46
56
|
width,
|
|
@@ -51,7 +61,7 @@ var Histogram = (options) => {
|
|
|
51
61
|
animate: false,
|
|
52
62
|
type: "interval",
|
|
53
63
|
data,
|
|
54
|
-
title: title
|
|
64
|
+
title: title ? { title, subtitle } : "",
|
|
55
65
|
encode: {
|
|
56
66
|
x: (d) => d,
|
|
57
67
|
y: "count",
|
|
@@ -59,19 +69,8 @@ var Histogram = (options) => {
|
|
|
59
69
|
},
|
|
60
70
|
// binX transform groups continuous data into bins and counts frequency
|
|
61
71
|
transform: [{ type: "binX", y: "count", thresholds: binNumber }],
|
|
62
|
-
style:
|
|
63
|
-
|
|
64
|
-
columnWidthRatio: 1,
|
|
65
|
-
inset: 0.5
|
|
66
|
-
},
|
|
67
|
-
axis: {
|
|
68
|
-
x: {
|
|
69
|
-
title: axisXTitle
|
|
70
|
-
},
|
|
71
|
-
y: {
|
|
72
|
-
title: axisYTitle
|
|
73
|
-
}
|
|
74
|
-
},
|
|
72
|
+
style: intervalMark,
|
|
73
|
+
axis: (0, import_components.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
75
74
|
scale: {
|
|
76
75
|
y: {
|
|
77
76
|
nice: true
|
|
@@ -82,8 +81,7 @@ var Histogram = (options) => {
|
|
|
82
81
|
tooltip: {
|
|
83
82
|
items: [{ channel: "y", name: "频数" }]
|
|
84
83
|
},
|
|
85
|
-
|
|
86
|
-
theme: (0, import_theme.getThemeObject)(theme)
|
|
84
|
+
theme: rendererTheme
|
|
87
85
|
};
|
|
88
86
|
chart.options(chartOptions);
|
|
89
87
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Indented tree node data — only name + optional children, no description.
|
|
4
4
|
* Aligns with the official G6 indented tree example data structure.
|
|
@@ -13,14 +13,12 @@ export interface IndentedTreeData {
|
|
|
13
13
|
export interface IndentedTreeConfig {
|
|
14
14
|
type?: 'indented-tree';
|
|
15
15
|
data: IndentedTreeData;
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
/** Layout direction: 'LR' = root left (default), 'RL' = root right, 'H' = root center */
|
|
19
20
|
direction?: 'LR' | 'RL' | 'H';
|
|
20
|
-
style?:
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
23
|
-
};
|
|
21
|
+
style?: ThemeStyle;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* IndentedTreeInstance represents a chart instance with render and destroy methods.
|
|
@@ -23,7 +23,8 @@ __export(indented_tree_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(indented_tree_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 TreeEvent = {
|
|
28
29
|
COLLAPSE_EXPAND: "collapse-expand",
|
|
29
30
|
ADD_CHILD: "add-child"
|
|
@@ -41,7 +42,7 @@ function ensureIconfontInjected() {
|
|
|
41
42
|
}
|
|
42
43
|
var _measureCanvas = null;
|
|
43
44
|
var _measureCtx = null;
|
|
44
|
-
function measureTextWidth(text, fontSize = 12) {
|
|
45
|
+
function measureTextWidth(text, fontSize = 12, fontFamily = "system-ui,-apple-system,BlinkMacSystemFont,sans-serif", fontWeight = 400) {
|
|
45
46
|
if (!text)
|
|
46
47
|
return 0;
|
|
47
48
|
if (typeof document === "undefined" || typeof HTMLCanvasElement === "undefined") {
|
|
@@ -56,7 +57,7 @@ function measureTextWidth(text, fontSize = 12) {
|
|
|
56
57
|
}
|
|
57
58
|
if (!_measureCtx)
|
|
58
59
|
return text.length * fontSize * 0.6;
|
|
59
|
-
_measureCtx.font = `${fontSize}px
|
|
60
|
+
_measureCtx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
60
61
|
return _measureCtx.measureText(text).width;
|
|
61
62
|
}
|
|
62
63
|
var _IndentedNode = class extends import_g6.BaseNode {
|
|
@@ -70,7 +71,7 @@ var _IndentedNode = class extends import_g6.BaseNode {
|
|
|
70
71
|
getKeyStyle(attributes) {
|
|
71
72
|
const [width, height] = this.getSize(attributes);
|
|
72
73
|
const keyStyle = super.getKeyStyle(attributes);
|
|
73
|
-
return { width, height, ...keyStyle
|
|
74
|
+
return { width, height, ...keyStyle };
|
|
74
75
|
}
|
|
75
76
|
drawKeyShape(attributes, container) {
|
|
76
77
|
const keyStyle = this.getKeyStyle(attributes);
|
|
@@ -251,7 +252,14 @@ var IndentedTree = (options) => {
|
|
|
251
252
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
252
253
|
let graph = null;
|
|
253
254
|
const render = (config) => {
|
|
254
|
-
const {
|
|
255
|
+
const {
|
|
256
|
+
data,
|
|
257
|
+
theme = chartTheme,
|
|
258
|
+
title,
|
|
259
|
+
subtitle,
|
|
260
|
+
style: localStyle = {},
|
|
261
|
+
direction = "LR"
|
|
262
|
+
} = config;
|
|
255
263
|
if (!(data == null ? void 0 : data.name)) {
|
|
256
264
|
throw new Error("IndentedTree: data with a name field is required");
|
|
257
265
|
}
|
|
@@ -263,9 +271,17 @@ var IndentedTree = (options) => {
|
|
|
263
271
|
if (!containerEl)
|
|
264
272
|
throw new Error("IndentedTree: container element not found");
|
|
265
273
|
containerEl.innerHTML = "";
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
274
|
+
const appearance = (0, import_g62.getThemeObject)("indented-tree", theme, localStyle);
|
|
275
|
+
const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
276
|
+
const { theme: rendererTheme } = appearance;
|
|
277
|
+
const baseTheme = appearance.baseTheme;
|
|
278
|
+
const backgroundColor = appearance.backgroundColor;
|
|
279
|
+
const isDark = baseTheme === "dark";
|
|
280
|
+
const palette = appearance.colors;
|
|
281
|
+
const nodeTheme = appearance.node.style;
|
|
282
|
+
const edgeTheme = appearance.edge.style;
|
|
283
|
+
const nodeFontSize = nodeTheme.labelFontSize ?? 12;
|
|
284
|
+
const nodeHeight = Math.max(NODE_HEIGHT, Math.ceil(nodeFontSize * 1.2) + 4);
|
|
269
285
|
containerEl.style.background = backgroundColor;
|
|
270
286
|
containerEl.style.borderRadius = "4px";
|
|
271
287
|
containerEl.style.overflow = "hidden";
|
|
@@ -281,24 +297,22 @@ var IndentedTree = (options) => {
|
|
|
281
297
|
height,
|
|
282
298
|
autoFit: "view",
|
|
283
299
|
autoResize: true,
|
|
284
|
-
theme:
|
|
285
|
-
padding:
|
|
300
|
+
theme: rendererTheme,
|
|
301
|
+
padding: graphTitle.padding,
|
|
286
302
|
data: graphData,
|
|
287
303
|
node: {
|
|
288
304
|
type: GPT_VIS_INDENTED_NODE,
|
|
289
305
|
style: {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
labelPadding:
|
|
306
|
+
// Paint the node itself so its fill and outline share one geometry.
|
|
307
|
+
fill: (datum) => datum.id === rootId ? palette[0] : "transparent",
|
|
308
|
+
radius: baseTheme === "academy" ? 0 : 4,
|
|
309
|
+
labelBackground: false,
|
|
310
|
+
labelPadding: 0,
|
|
295
311
|
labelFill: (datum) => datum.id === rootId ? "#fff" : isDark ? "#d0d0d0" : "#666",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
labelTextAlign: (datum) => datum.id === rootId ? "center" : "left",
|
|
301
|
-
labelTextBaseline: "top",
|
|
312
|
+
labelTextAlign: "left",
|
|
313
|
+
labelTextBaseline: "middle",
|
|
314
|
+
labelX: (datum) => datum.id === rootId ? 8 : 3,
|
|
315
|
+
labelY: nodeHeight / 2,
|
|
302
316
|
color: (datum) => {
|
|
303
317
|
try {
|
|
304
318
|
const depth = graph.getAncestorsData(datum.id, "tree").length - 1;
|
|
@@ -306,6 +320,23 @@ var IndentedTree = (options) => {
|
|
|
306
320
|
} catch {
|
|
307
321
|
return palette[0] ?? "#1783FF";
|
|
308
322
|
}
|
|
323
|
+
},
|
|
324
|
+
...nodeTheme,
|
|
325
|
+
size: (d) => {
|
|
326
|
+
var _a;
|
|
327
|
+
return [
|
|
328
|
+
measureTextWidth(
|
|
329
|
+
String(((_a = d.style) == null ? void 0 : _a.labelText) || d.id || ""),
|
|
330
|
+
nodeFontSize,
|
|
331
|
+
nodeTheme.labelFontFamily,
|
|
332
|
+
nodeTheme.labelFontWeight
|
|
333
|
+
) + (d.id === rootId ? 16 : 6),
|
|
334
|
+
nodeHeight
|
|
335
|
+
];
|
|
336
|
+
},
|
|
337
|
+
labelText: (d) => {
|
|
338
|
+
var _a;
|
|
339
|
+
return ((_a = d.style) == null ? void 0 : _a.labelText) || d.id;
|
|
309
340
|
}
|
|
310
341
|
},
|
|
311
342
|
state: {
|
|
@@ -324,8 +355,6 @@ var IndentedTree = (options) => {
|
|
|
324
355
|
style: {
|
|
325
356
|
radius: 16,
|
|
326
357
|
lineWidth: 2,
|
|
327
|
-
sourcePort: "out",
|
|
328
|
-
targetPort: "in",
|
|
329
358
|
stroke: (datum) => {
|
|
330
359
|
try {
|
|
331
360
|
if ((datum == null ? void 0 : datum.source) == null)
|
|
@@ -335,7 +364,10 @@ var IndentedTree = (options) => {
|
|
|
335
364
|
} catch {
|
|
336
365
|
return palette[0] ?? "#1783FF";
|
|
337
366
|
}
|
|
338
|
-
}
|
|
367
|
+
},
|
|
368
|
+
...edgeTheme,
|
|
369
|
+
sourcePort: "out",
|
|
370
|
+
targetPort: "in"
|
|
339
371
|
}
|
|
340
372
|
},
|
|
341
373
|
layout: {
|
|
@@ -343,7 +375,7 @@ var IndentedTree = (options) => {
|
|
|
343
375
|
direction,
|
|
344
376
|
isHorizontal: true,
|
|
345
377
|
indent: 40,
|
|
346
|
-
getHeight: () =>
|
|
378
|
+
getHeight: () => nodeHeight,
|
|
347
379
|
getVGap: () => 10
|
|
348
380
|
},
|
|
349
381
|
behaviors: [
|
|
@@ -354,15 +386,7 @@ var IndentedTree = (options) => {
|
|
|
354
386
|
enable: (event) => event.targetType === "node" && event.target.id !== rootId
|
|
355
387
|
}
|
|
356
388
|
],
|
|
357
|
-
plugins:
|
|
358
|
-
{
|
|
359
|
-
key: "title",
|
|
360
|
-
type: "title",
|
|
361
|
-
title,
|
|
362
|
-
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
363
|
-
titleFontFamily: "sans-serif"
|
|
364
|
-
}
|
|
365
|
-
] : []
|
|
389
|
+
plugins: graphTitle.plugins
|
|
366
390
|
});
|
|
367
391
|
graph.render();
|
|
368
392
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* LineDataItem is the type for each data item in the line chart.
|
|
4
4
|
*/
|
|
@@ -14,14 +14,11 @@ export interface LineConfig {
|
|
|
14
14
|
type?: 'line';
|
|
15
15
|
data: LineDataItem[];
|
|
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
|
-
lineWidth?: number;
|
|
24
|
-
};
|
|
21
|
+
style?: ThemeStyle;
|
|
25
22
|
}
|
|
26
23
|
/**
|
|
27
24
|
* LineInstance represents a line chart instance with render and destroy methods.
|
|
@@ -23,7 +23,10 @@ __export(line_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(line_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 Line = (options) => {
|
|
28
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
32
|
let chart = null;
|
|
@@ -31,16 +34,44 @@ var Line = (options) => {
|
|
|
31
34
|
let cleanupCrosshairAxisLabels = null;
|
|
32
35
|
const render = (config) => {
|
|
33
36
|
var _a;
|
|
34
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
data = [],
|
|
39
|
+
theme = chartTheme,
|
|
40
|
+
title,
|
|
41
|
+
subtitle,
|
|
42
|
+
axisXTitle,
|
|
43
|
+
axisYTitle,
|
|
44
|
+
style: localStyle = {}
|
|
45
|
+
} = config;
|
|
35
46
|
if (chart) {
|
|
36
47
|
cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
|
|
37
48
|
cleanupCrosshairAxisLabels = null;
|
|
38
49
|
chart.destroy();
|
|
39
50
|
}
|
|
40
|
-
const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
|
|
41
51
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
42
|
-
const
|
|
43
|
-
|
|
52
|
+
const cartesianAxisOptions = {
|
|
53
|
+
axisXTitle,
|
|
54
|
+
axisYTitle,
|
|
55
|
+
xLabels: data.map(({ time }) => time),
|
|
56
|
+
chartWidth: width
|
|
57
|
+
};
|
|
58
|
+
const appearance = (0, import_g22.getThemeObject)("line", theme, localStyle);
|
|
59
|
+
const { theme: rendererTheme } = appearance;
|
|
60
|
+
const lineMark = {
|
|
61
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
|
|
62
|
+
lineCap: "round",
|
|
63
|
+
lineJoin: "round",
|
|
64
|
+
...appearance.mark.line
|
|
65
|
+
};
|
|
66
|
+
const pointStyle = {
|
|
67
|
+
shape: "point",
|
|
68
|
+
size: import_tokens.CHART_STYLE_DEFAULTS.pointSize,
|
|
69
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
70
|
+
stroke: rendererTheme.view.viewFill,
|
|
71
|
+
...appearance.mark.point
|
|
72
|
+
};
|
|
73
|
+
const baseTheme = rendererTheme.type;
|
|
74
|
+
const colors = rendererTheme.category10;
|
|
44
75
|
const tooltip = {
|
|
45
76
|
items: [
|
|
46
77
|
(d) => ({
|
|
@@ -51,12 +82,6 @@ var Line = (options) => {
|
|
|
51
82
|
};
|
|
52
83
|
const lineAnimation = (0, import_util.getChartAnimation)(hasRendered, "pathIn");
|
|
53
84
|
const pointAnimation = (0, import_util.getChartAnimation)(hasRendered, "fadeIn");
|
|
54
|
-
const cartesianAxisOptions = {
|
|
55
|
-
axisXTitle,
|
|
56
|
-
axisYTitle,
|
|
57
|
-
xLabels: data.map(({ time }) => time),
|
|
58
|
-
chartWidth: width
|
|
59
|
-
};
|
|
60
85
|
chart = new import_g2.Chart({
|
|
61
86
|
container,
|
|
62
87
|
width,
|
|
@@ -76,9 +101,7 @@ var Line = (options) => {
|
|
|
76
101
|
type: "line",
|
|
77
102
|
tooltip,
|
|
78
103
|
style: {
|
|
79
|
-
|
|
80
|
-
lineCap: "round",
|
|
81
|
-
lineJoin: "round",
|
|
104
|
+
...lineMark,
|
|
82
105
|
...!hasGroupField ? { stroke: colors[0] } : {}
|
|
83
106
|
},
|
|
84
107
|
animate: lineAnimation
|
|
@@ -86,20 +109,19 @@ var Line = (options) => {
|
|
|
86
109
|
];
|
|
87
110
|
const showPoints = data.length <= (hasGroupField ? 36 : 24);
|
|
88
111
|
if (showPoints) {
|
|
112
|
+
const { size: pointSize, ...pointMark } = pointStyle;
|
|
89
113
|
children.push({
|
|
90
114
|
type: "point",
|
|
91
115
|
encode: {
|
|
92
116
|
x: "time",
|
|
93
117
|
y: "value",
|
|
94
|
-
|
|
95
|
-
size: import_util.CHART_STYLE_DEFAULTS.pointSize,
|
|
118
|
+
size: pointSize,
|
|
96
119
|
...hasGroupField ? { color: "group" } : {}
|
|
97
120
|
},
|
|
98
121
|
animate: pointAnimation,
|
|
99
122
|
tooltip: false,
|
|
100
123
|
style: {
|
|
101
|
-
|
|
102
|
-
stroke: backgroundColor,
|
|
124
|
+
...pointMark,
|
|
103
125
|
...!hasGroupField ? { fill: colors[0] } : {}
|
|
104
126
|
}
|
|
105
127
|
});
|
|
@@ -107,21 +129,20 @@ var Line = (options) => {
|
|
|
107
129
|
const chartOptions = {
|
|
108
130
|
type: "view",
|
|
109
131
|
data,
|
|
110
|
-
title: title
|
|
132
|
+
title: title ? { title, subtitle } : "",
|
|
111
133
|
encode,
|
|
112
134
|
children,
|
|
113
135
|
scale: scaleConfig,
|
|
114
136
|
...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
|
|
115
137
|
axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
|
|
116
|
-
legend: (0,
|
|
138
|
+
legend: (0, import_components.getColorLegend)(hasGroupField),
|
|
117
139
|
interaction: {
|
|
118
140
|
tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true })
|
|
119
141
|
},
|
|
120
|
-
|
|
121
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
142
|
+
theme: rendererTheme
|
|
122
143
|
};
|
|
123
144
|
chart.options(chartOptions);
|
|
124
|
-
cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart,
|
|
145
|
+
cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, baseTheme);
|
|
125
146
|
chart.render();
|
|
126
147
|
hasRendered = true;
|
|
127
148
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* LiquidConfig defines the configuration for rendering the liquid chart.
|
|
4
4
|
*/
|
|
5
5
|
export interface LiquidConfig {
|
|
6
6
|
type?: 'liquid';
|
|
7
7
|
percent: number;
|
|
8
|
-
shape?: '
|
|
8
|
+
shape?: 'circle' | 'rect' | 'pin' | 'triangle';
|
|
9
9
|
theme?: VisualizationTheme;
|
|
10
10
|
title?: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
palette?: string[];
|
|
14
|
-
};
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
style?: ThemeStyle;
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
15
|
* LiquidInstance represents a liquid chart instance with render and destroy methods.
|