@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* BoxplotDataItem is the type for each data item in the boxplot chart.
|
|
4
4
|
*/
|
|
@@ -13,13 +13,12 @@ export type BoxplotDataItem = {
|
|
|
13
13
|
export interface BoxplotConfig {
|
|
14
14
|
type?: 'boxplot';
|
|
15
15
|
data: BoxplotDataItem[];
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
axisYTitle?: string;
|
|
20
|
-
style?: {
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
21
|
+
style?: ThemeStyle & {
|
|
23
22
|
startAtZero?: boolean;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -23,19 +23,36 @@ __export(boxplot_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(boxplot_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");
|
|
28
|
+
var prefixMarkStyle = (prefix, style) => Object.fromEntries(
|
|
29
|
+
Object.entries(style ?? {}).map(([key, value]) => [
|
|
30
|
+
`${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`,
|
|
31
|
+
value
|
|
32
|
+
])
|
|
33
|
+
);
|
|
27
34
|
var Boxplot = (options) => {
|
|
28
35
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
36
|
let chart = null;
|
|
30
37
|
const render = (config) => {
|
|
31
38
|
var _a;
|
|
32
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
data = [],
|
|
41
|
+
theme = chartTheme,
|
|
42
|
+
title,
|
|
43
|
+
subtitle,
|
|
44
|
+
axisXTitle,
|
|
45
|
+
axisYTitle,
|
|
46
|
+
style: localStyle = {}
|
|
47
|
+
} = config;
|
|
33
48
|
if (chart) {
|
|
34
49
|
chart.destroy();
|
|
35
50
|
}
|
|
36
|
-
const colors = (0, import_theme.normalizePalette)(style.palette, theme);
|
|
37
|
-
const startAtZero = style.startAtZero || false;
|
|
38
51
|
const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
|
|
52
|
+
const appearance = (0, import_g22.getThemeObject)("boxplot", theme, localStyle);
|
|
53
|
+
const { theme: rendererTheme } = appearance;
|
|
54
|
+
const colors = rendererTheme.category10;
|
|
55
|
+
const startAtZero = localStyle.startAtZero || false;
|
|
39
56
|
let encode = {};
|
|
40
57
|
if (hasGroupField) {
|
|
41
58
|
encode = {
|
|
@@ -51,6 +68,14 @@ var Boxplot = (options) => {
|
|
|
51
68
|
color: "category"
|
|
52
69
|
};
|
|
53
70
|
}
|
|
71
|
+
const showPoints = !hasGroupField;
|
|
72
|
+
const boxStyle = appearance.mark.box;
|
|
73
|
+
const resolvedPointStyle = appearance.mark.point;
|
|
74
|
+
const markStyle = showPoints ? {
|
|
75
|
+
...prefixMarkStyle("box", boxStyle),
|
|
76
|
+
...prefixMarkStyle("point", resolvedPointStyle)
|
|
77
|
+
} : { ...boxStyle, point: false };
|
|
78
|
+
const legend = (0, import_components.getColorLegend)(hasGroupField);
|
|
54
79
|
chart = new import_g2.Chart({
|
|
55
80
|
container,
|
|
56
81
|
width,
|
|
@@ -61,32 +86,20 @@ var Boxplot = (options) => {
|
|
|
61
86
|
animate: false,
|
|
62
87
|
type: "boxplot",
|
|
63
88
|
data,
|
|
64
|
-
title: title
|
|
89
|
+
title: title ? { title, subtitle } : "",
|
|
65
90
|
encode,
|
|
66
|
-
axis: {
|
|
67
|
-
x: {
|
|
68
|
-
title: axisXTitle || false
|
|
69
|
-
},
|
|
70
|
-
y: {
|
|
71
|
-
title: axisYTitle || false
|
|
72
|
-
}
|
|
73
|
-
},
|
|
91
|
+
axis: (0, import_components.getCartesianAxis)({ axisXTitle, axisYTitle }),
|
|
74
92
|
scale: {
|
|
75
93
|
x: { paddingInner: 0.6, paddingOuter: 0.3 },
|
|
76
94
|
series: { paddingInner: 0.3, paddingOuter: 0.1 },
|
|
77
95
|
y: { nice: true, zero: startAtZero },
|
|
78
96
|
color: { range: colors }
|
|
79
97
|
},
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
legend: {
|
|
86
|
-
color: hasGroupField ? { position: "top" } : false
|
|
87
|
-
},
|
|
88
|
-
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
89
|
-
theme: (0, import_theme.getThemeObject)(theme)
|
|
98
|
+
// Grouped boxplots keep outliers disabled because G2's point child does
|
|
99
|
+
// not inherit the composite color scale used by legend filtering.
|
|
100
|
+
style: { stroke: "black", ...markStyle },
|
|
101
|
+
legend: legend === false ? { color: false } : { color: { position: "top", ...legend.color } },
|
|
102
|
+
theme: rendererTheme
|
|
90
103
|
};
|
|
91
104
|
chart.options(chartOptions);
|
|
92
105
|
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
|
* ColumnDataItem is the type for each data item in the column chart.
|
|
4
4
|
*/
|
|
@@ -16,13 +16,13 @@ export interface ColumnConfig {
|
|
|
16
16
|
group?: boolean;
|
|
17
17
|
stack?: boolean;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/** Show value labels. Defaults to `true`. */
|
|
21
|
+
label?: boolean;
|
|
19
22
|
axisXTitle?: string;
|
|
20
23
|
axisYTitle?: string;
|
|
21
24
|
theme?: VisualizationTheme;
|
|
22
|
-
style?:
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
palette?: string[];
|
|
25
|
-
};
|
|
25
|
+
style?: ThemeStyle;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ColumnInstance represents a column chart instance with render and destroy methods.
|
|
@@ -23,28 +23,47 @@ __export(column_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(column_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 Column = (options) => {
|
|
28
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
29
32
|
let chart = null;
|
|
30
|
-
let hasRendered = false;
|
|
31
33
|
const render = (config) => {
|
|
32
34
|
var _a;
|
|
33
35
|
const {
|
|
34
36
|
data = [],
|
|
35
37
|
theme = chartTheme,
|
|
36
38
|
title,
|
|
39
|
+
subtitle,
|
|
40
|
+
label,
|
|
37
41
|
axisXTitle,
|
|
38
42
|
axisYTitle,
|
|
39
43
|
group = false,
|
|
40
44
|
stack = false,
|
|
41
|
-
style = {}
|
|
45
|
+
style: localStyle = {}
|
|
42
46
|
} = config;
|
|
43
47
|
if (chart) {
|
|
44
48
|
chart.destroy();
|
|
45
49
|
}
|
|
46
50
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
47
|
-
const
|
|
51
|
+
const cartesianAxisOptions = {
|
|
52
|
+
axisXTitle,
|
|
53
|
+
axisYTitle,
|
|
54
|
+
xLabels: data.map(({ category }) => category),
|
|
55
|
+
chartWidth: width
|
|
56
|
+
};
|
|
57
|
+
const appearance = (0, import_g22.getThemeObject)("column", theme, localStyle);
|
|
58
|
+
const { theme: rendererTheme } = appearance;
|
|
59
|
+
const intervalMark = {
|
|
60
|
+
...rendererTheme.type !== "academy" && appearance.mark.interval.radius === void 0 ? { radiusTopLeft: 4, radiusTopRight: 4 } : {},
|
|
61
|
+
columnWidthRatio: import_tokens.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
62
|
+
...!hasGroupField ? { fill: rendererTheme.category10[0] } : {},
|
|
63
|
+
...appearance.mark.interval
|
|
64
|
+
};
|
|
65
|
+
const baseTheme = rendererTheme.type;
|
|
66
|
+
const colors = rendererTheme.category10;
|
|
48
67
|
chart = new import_g2.Chart({
|
|
49
68
|
container,
|
|
50
69
|
width,
|
|
@@ -53,10 +72,6 @@ var Column = (options) => {
|
|
|
53
72
|
});
|
|
54
73
|
let encode = {};
|
|
55
74
|
let transform = [];
|
|
56
|
-
let radiusStyle = {};
|
|
57
|
-
if (theme !== "academy") {
|
|
58
|
-
radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
|
|
59
|
-
}
|
|
60
75
|
if (hasGroupField && group) {
|
|
61
76
|
transform = [{ type: "dodgeX" }];
|
|
62
77
|
}
|
|
@@ -72,23 +87,27 @@ var Column = (options) => {
|
|
|
72
87
|
y: { nice: true },
|
|
73
88
|
...hasGroupField ? { color: { range: colors } } : {}
|
|
74
89
|
};
|
|
75
|
-
const cartesianAxisOptions = {
|
|
76
|
-
axisXTitle,
|
|
77
|
-
axisYTitle,
|
|
78
|
-
xLabels: data.map(({ category }) => category),
|
|
79
|
-
chartWidth: width
|
|
80
|
-
};
|
|
81
90
|
const chartOptions = {
|
|
82
|
-
|
|
91
|
+
// G2 growInY currently computes interval label bounds from the animated
|
|
92
|
+
// clip path, which leaves inside labels at the axis baseline. Keep the
|
|
93
|
+
// interval and its labels in sync until the upstream runtime is fixed.
|
|
94
|
+
animate: false,
|
|
83
95
|
type: "interval",
|
|
84
96
|
data,
|
|
85
|
-
title: title
|
|
97
|
+
title: title ? { title, subtitle } : "",
|
|
86
98
|
encode,
|
|
87
99
|
transform,
|
|
88
100
|
scale: scaleConfig,
|
|
89
101
|
...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
|
|
90
102
|
axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
|
|
91
|
-
legend: (0,
|
|
103
|
+
legend: (0, import_components.getColorLegend)(hasGroupField),
|
|
104
|
+
labels: (0, import_components.getDataLabels)(rendererTheme, {
|
|
105
|
+
visible: label,
|
|
106
|
+
defaultVisible: true,
|
|
107
|
+
text: "value",
|
|
108
|
+
position: "inside",
|
|
109
|
+
contrast: "inside"
|
|
110
|
+
}),
|
|
92
111
|
tooltip: {
|
|
93
112
|
items: [
|
|
94
113
|
(d) => ({
|
|
@@ -97,29 +116,22 @@ var Column = (options) => {
|
|
|
97
116
|
})
|
|
98
117
|
]
|
|
99
118
|
},
|
|
100
|
-
state: (0, import_util.getCategoryBackgroundHighlightState)(
|
|
119
|
+
state: (0, import_util.getCategoryBackgroundHighlightState)(baseTheme),
|
|
101
120
|
interaction: {
|
|
102
121
|
tooltip: true,
|
|
103
122
|
elementHighlight: (0, import_util.getCategoryHighlightInteraction)()
|
|
104
123
|
},
|
|
105
|
-
style:
|
|
106
|
-
|
|
107
|
-
columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
108
|
-
...!hasGroupField ? { fill: colors[0] } : {}
|
|
109
|
-
},
|
|
110
|
-
viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
|
|
111
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
124
|
+
style: intervalMark,
|
|
125
|
+
theme: rendererTheme
|
|
112
126
|
};
|
|
113
127
|
chart.options(chartOptions);
|
|
114
128
|
chart.render();
|
|
115
|
-
hasRendered = true;
|
|
116
129
|
};
|
|
117
130
|
const destroy = () => {
|
|
118
131
|
if (chart) {
|
|
119
132
|
chart.destroy();
|
|
120
133
|
chart = null;
|
|
121
134
|
}
|
|
122
|
-
hasRendered = false;
|
|
123
135
|
};
|
|
124
136
|
return {
|
|
125
137
|
render,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* DualAxesSeriesItem defines a single series in the dual-axes chart.
|
|
4
4
|
*/
|
|
@@ -15,11 +15,10 @@ export interface DualAxesConfig {
|
|
|
15
15
|
categories: string[];
|
|
16
16
|
series: DualAxesSeriesItem[];
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
theme?: VisualizationTheme;
|
|
20
|
-
style?: {
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
21
|
+
style?: ThemeStyle & {
|
|
23
22
|
startAtZero?: boolean;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -23,7 +23,10 @@ __export(dual_axes_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(dual_axes_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 getSeriesField = (index) => `value_${index + 1}`;
|
|
28
31
|
function transformData(series, categories) {
|
|
29
32
|
return categories.map((category, index) => {
|
|
@@ -40,19 +43,44 @@ var DualAxes = (options) => {
|
|
|
40
43
|
let hasRendered = false;
|
|
41
44
|
let cleanupCrosshairAxisLabels = null;
|
|
42
45
|
const render = (config) => {
|
|
43
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
categories,
|
|
48
|
+
series,
|
|
49
|
+
theme = chartTheme,
|
|
50
|
+
title,
|
|
51
|
+
subtitle,
|
|
52
|
+
axisXTitle,
|
|
53
|
+
style: localStyle = {}
|
|
54
|
+
} = config;
|
|
44
55
|
if (chart) {
|
|
45
56
|
cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
|
|
46
57
|
cleanupCrosshairAxisLabels = null;
|
|
47
58
|
chart.destroy();
|
|
48
59
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
const cartesianAxisOptions = {
|
|
61
|
+
axisXTitle,
|
|
62
|
+
xLabels: categories,
|
|
63
|
+
chartWidth: width
|
|
64
|
+
};
|
|
65
|
+
const cartesianAxis = (0, import_util.getCartesianAxis)(cartesianAxisOptions);
|
|
66
|
+
const appearance = (0, import_g22.getThemeObject)("dual-axes", theme, localStyle);
|
|
67
|
+
const { theme: rendererTheme } = appearance;
|
|
68
|
+
const intervalMark = {
|
|
69
|
+
fillOpacity: 0.86,
|
|
70
|
+
columnWidthRatio: import_tokens.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
71
|
+
...rendererTheme.type !== "academy" && appearance.mark.interval.radius === void 0 ? { radiusTopLeft: 4, radiusTopRight: 4 } : {},
|
|
72
|
+
...appearance.mark.interval
|
|
73
|
+
};
|
|
74
|
+
const lineMark = {
|
|
75
|
+
shape: "smooth",
|
|
76
|
+
lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
|
|
77
|
+
lineCap: "round",
|
|
78
|
+
lineJoin: "round",
|
|
79
|
+
...appearance.mark.line
|
|
80
|
+
};
|
|
81
|
+
const baseTheme = rendererTheme.type;
|
|
82
|
+
const colors = rendererTheme.category10;
|
|
83
|
+
const { startAtZero = false } = localStyle;
|
|
56
84
|
const data = transformData(series, categories);
|
|
57
85
|
chart = new import_g2.Chart({
|
|
58
86
|
container,
|
|
@@ -73,12 +101,6 @@ var DualAxes = (options) => {
|
|
|
73
101
|
const seriesByField = new Map(
|
|
74
102
|
seriesMeta.map(({ item, yField, displayName }) => [yField, { type: item.type, displayName }])
|
|
75
103
|
);
|
|
76
|
-
const cartesianAxisOptions = {
|
|
77
|
-
axisXTitle,
|
|
78
|
-
xLabels: categories,
|
|
79
|
-
chartWidth: width
|
|
80
|
-
};
|
|
81
|
-
const cartesianAxis = (0, import_util.getCartesianAxis)(cartesianAxisOptions);
|
|
82
104
|
const children = seriesMeta.map(({ item, yField, displayName, color }) => {
|
|
83
105
|
const tooltip = {
|
|
84
106
|
items: [
|
|
@@ -89,6 +111,15 @@ var DualAxes = (options) => {
|
|
|
89
111
|
]
|
|
90
112
|
};
|
|
91
113
|
if (item.type === "column") {
|
|
114
|
+
const axis = {
|
|
115
|
+
y: {
|
|
116
|
+
...cartesianAxis.y,
|
|
117
|
+
title: item.axisYTitle || false,
|
|
118
|
+
titleFill: color,
|
|
119
|
+
titleFontWeight: 500,
|
|
120
|
+
...rendererTheme.axis
|
|
121
|
+
}
|
|
122
|
+
};
|
|
92
123
|
return {
|
|
93
124
|
type: "interval",
|
|
94
125
|
encode: {
|
|
@@ -100,63 +131,50 @@ var DualAxes = (options) => {
|
|
|
100
131
|
y: { nice: true, zero: startAtZero }
|
|
101
132
|
},
|
|
102
133
|
tooltip,
|
|
103
|
-
axis: {
|
|
104
|
-
|
|
105
|
-
...cartesianAxis.y,
|
|
106
|
-
title: item.axisYTitle || "",
|
|
107
|
-
titleFill: color,
|
|
108
|
-
titleFontWeight: 500
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
style: {
|
|
112
|
-
fill: color,
|
|
113
|
-
fillOpacity: 0.86,
|
|
114
|
-
columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
115
|
-
...theme !== "academy" ? { radiusTopLeft: 4, radiusTopRight: 4 } : {}
|
|
116
|
-
},
|
|
134
|
+
axis: { y: axis.y },
|
|
135
|
+
style: { fill: color, ...intervalMark },
|
|
117
136
|
animate: (0, import_util.getChartAnimation)(hasRendered, "growInY")
|
|
118
137
|
};
|
|
119
138
|
} else {
|
|
139
|
+
const lineWidth = lineMark.lineWidth;
|
|
140
|
+
const axis = {
|
|
141
|
+
y: {
|
|
142
|
+
...cartesianAxis.y,
|
|
143
|
+
title: item.axisYTitle || false,
|
|
144
|
+
position: "right",
|
|
145
|
+
titleFill: color,
|
|
146
|
+
titleFontWeight: 500,
|
|
147
|
+
grid: false,
|
|
148
|
+
...rendererTheme.axis
|
|
149
|
+
}
|
|
150
|
+
};
|
|
120
151
|
return {
|
|
121
152
|
type: "line",
|
|
122
153
|
encode: {
|
|
123
154
|
x: "category",
|
|
124
155
|
y: yField,
|
|
125
|
-
shape: "smooth",
|
|
126
156
|
color: () => yField
|
|
127
157
|
},
|
|
128
158
|
scale: {
|
|
129
159
|
y: { independent: true, zero: startAtZero }
|
|
130
160
|
},
|
|
131
161
|
tooltip,
|
|
132
|
-
axis: {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
position: "right",
|
|
136
|
-
title: item.axisYTitle || "",
|
|
137
|
-
titleFill: color,
|
|
138
|
-
titleFontWeight: 500,
|
|
139
|
-
grid: false
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
style: {
|
|
143
|
-
stroke: color,
|
|
144
|
-
lineWidth: import_util.CHART_STYLE_DEFAULTS.lineWidth,
|
|
145
|
-
lineCap: "round",
|
|
146
|
-
lineJoin: "round"
|
|
147
|
-
},
|
|
148
|
-
state: (0, import_util.getLineHighlightState)(import_util.CHART_STYLE_DEFAULTS.lineWidth),
|
|
162
|
+
axis: { y: axis.y },
|
|
163
|
+
style: { stroke: color, ...lineMark },
|
|
164
|
+
state: (0, import_util.getLineHighlightState)(lineWidth),
|
|
149
165
|
animate: (0, import_util.getChartAnimation)(hasRendered, "pathIn")
|
|
150
166
|
};
|
|
151
167
|
}
|
|
152
168
|
});
|
|
169
|
+
const xAxis = cartesianAxis.x;
|
|
170
|
+
const legend = (0, import_components.getColorLegend)(series.length > 0);
|
|
153
171
|
const chartOptions = {
|
|
154
172
|
type: "view",
|
|
155
173
|
data,
|
|
156
|
-
title: title
|
|
174
|
+
title: title ? { title, subtitle } : "",
|
|
157
175
|
children,
|
|
158
176
|
...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
|
|
159
|
-
axis: { x:
|
|
177
|
+
axis: { x: xAxis },
|
|
160
178
|
scale: {
|
|
161
179
|
y: { nice: true },
|
|
162
180
|
color: {
|
|
@@ -164,8 +182,9 @@ var DualAxes = (options) => {
|
|
|
164
182
|
range: seriesMeta.map(({ color }) => color)
|
|
165
183
|
}
|
|
166
184
|
},
|
|
167
|
-
legend: {
|
|
185
|
+
legend: legend === false ? false : {
|
|
168
186
|
color: {
|
|
187
|
+
...legend.color,
|
|
169
188
|
labelFormatter: (value) => {
|
|
170
189
|
var _a;
|
|
171
190
|
return ((_a = seriesByField.get(value)) == null ? void 0 : _a.displayName) || value;
|
|
@@ -180,15 +199,14 @@ var DualAxes = (options) => {
|
|
|
180
199
|
tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true }),
|
|
181
200
|
...(0, import_util.getSeriesHighlightByColorInteraction)()
|
|
182
201
|
},
|
|
183
|
-
|
|
184
|
-
theme: (0, import_util.getThemeObject)(theme)
|
|
202
|
+
theme: rendererTheme
|
|
185
203
|
};
|
|
186
204
|
chart.options(chartOptions);
|
|
187
205
|
const lineYFields = seriesMeta.filter(({ item }) => item.type === "line").map(({ yField }) => yField);
|
|
188
206
|
if (lineYFields.length) {
|
|
189
207
|
const currentChart = chart;
|
|
190
208
|
const cleanups = lineYFields.map(
|
|
191
|
-
(yField, index) => (0, import_util.bindCrosshairAxisLabels)(currentChart,
|
|
209
|
+
(yField, index) => (0, import_util.bindCrosshairAxisLabels)(currentChart, baseTheme, {
|
|
192
210
|
showXLabel: index === 0,
|
|
193
211
|
useStandaloneYLabel: true,
|
|
194
212
|
yAxisPosition: "right",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
export interface FishboneNode {
|
|
3
3
|
name: string;
|
|
4
4
|
children?: FishboneNode[];
|
|
@@ -9,16 +9,10 @@ export interface FishboneNode {
|
|
|
9
9
|
export interface FishboneDiagramConfig {
|
|
10
10
|
type?: 'fishbone-diagram';
|
|
11
11
|
data: FishboneNode;
|
|
12
|
-
theme?:
|
|
12
|
+
theme?: VisualizationTheme;
|
|
13
13
|
title?: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
palette?: string[];
|
|
17
|
-
/** Canvas background color, overrides theme default */
|
|
18
|
-
backgroundColor?: string;
|
|
19
|
-
/** Node rendering style: 'rough' for hand-drawn look, 'default' for smooth */
|
|
20
|
-
texture?: 'rough' | 'default';
|
|
21
|
-
};
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
style?: ThemeStyle;
|
|
22
16
|
}
|
|
23
17
|
/**
|
|
24
18
|
* FishboneDiagramInstance represents a fishbone diagram instance.
|
|
@@ -23,22 +23,32 @@ __export(fishbone_diagram_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(fishbone_diagram_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 FONT_FAMILY = "system-ui, sans-serif";
|
|
28
|
-
function getNodeSize(
|
|
29
|
-
|
|
29
|
+
function getNodeSize(text, depth, style) {
|
|
30
|
+
const defaultFontSize = depth === 0 ? 24 : depth === 1 ? 18 : 16;
|
|
31
|
+
const fontSize = style.labelFontSize ?? defaultFontSize;
|
|
32
|
+
const scale = fontSize / defaultFontSize;
|
|
33
|
+
if (depth >= 2)
|
|
34
|
+
return [2, Math.ceil(30 * scale)];
|
|
35
|
+
const textWidth = measureText(text, fontSize, style.labelFontWeight, style.labelFontFamily);
|
|
36
|
+
return [
|
|
37
|
+
Math.ceil(textWidth + (depth === 0 ? 80 : 50) * scale),
|
|
38
|
+
Math.ceil((depth === 0 ? 70 : 42) * scale)
|
|
39
|
+
];
|
|
30
40
|
}
|
|
31
41
|
var measureText = function() {
|
|
32
42
|
let canvas = null;
|
|
33
|
-
return (text, fontSize = 12, fontWeight = "normal") => {
|
|
43
|
+
return (text, fontSize = 12, fontWeight = "normal", fontFamily = FONT_FAMILY) => {
|
|
34
44
|
if (typeof document === "undefined")
|
|
35
45
|
return text.length * fontSize * 0.6;
|
|
36
46
|
if (!canvas)
|
|
37
47
|
canvas = document.createElement("canvas");
|
|
38
48
|
const ctx = canvas.getContext("2d");
|
|
39
49
|
if (!ctx)
|
|
40
|
-
return 0;
|
|
41
|
-
ctx.font = `${fontWeight} ${fontSize}px ${
|
|
50
|
+
return text.length * fontSize * 0.6;
|
|
51
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
42
52
|
return ctx.measureText(text).width;
|
|
43
53
|
};
|
|
44
54
|
}();
|
|
@@ -71,7 +81,7 @@ var FishboneDiagram = (options) => {
|
|
|
71
81
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
72
82
|
let graph = null;
|
|
73
83
|
const render = (config) => {
|
|
74
|
-
const { data, theme = chartTheme, title, style = {} } = config;
|
|
84
|
+
const { data, theme = chartTheme, title, subtitle, style: localStyle = {} } = config;
|
|
75
85
|
if (!(data == null ? void 0 : data.name)) {
|
|
76
86
|
throw new Error("FishboneDiagram: data with a name field is required");
|
|
77
87
|
}
|
|
@@ -83,13 +93,22 @@ var FishboneDiagram = (options) => {
|
|
|
83
93
|
if (!containerEl)
|
|
84
94
|
throw new Error("FishboneDiagram: container element not found");
|
|
85
95
|
containerEl.innerHTML = "";
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
96
|
+
const appearance = (0, import_g62.getThemeObject)("fishbone-diagram", theme, localStyle);
|
|
97
|
+
const graphTitle = (0, import_components.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
98
|
+
const { theme: rendererTheme } = appearance;
|
|
99
|
+
const baseTheme = appearance.baseTheme;
|
|
100
|
+
const isDark = baseTheme === "dark";
|
|
101
|
+
const backgroundColor = appearance.backgroundColor;
|
|
102
|
+
const palette = appearance.colors;
|
|
89
103
|
const rootFill = isDark ? "#2a2a2a" : "#EFF0F0";
|
|
90
104
|
const rootLabelFill = isDark ? "#e0e0e0" : "#262626";
|
|
91
105
|
const leafLabelFill = isDark ? "#c0c0c0" : "#262626";
|
|
92
106
|
const edgeStroke = isDark ? "#555" : "#99ADD1";
|
|
107
|
+
const nodeTheme = appearance.node.style;
|
|
108
|
+
const leafTheme = Object.fromEntries(
|
|
109
|
+
Object.entries(nodeTheme).filter(([key]) => key.startsWith("label"))
|
|
110
|
+
);
|
|
111
|
+
const edgeTheme = appearance.edge.style;
|
|
93
112
|
containerEl.style.backgroundColor = backgroundColor;
|
|
94
113
|
const graphData = convertData(data);
|
|
95
114
|
assignBranchColors(graphData, palette);
|
|
@@ -100,17 +119,9 @@ var FishboneDiagram = (options) => {
|
|
|
100
119
|
height,
|
|
101
120
|
autoFit: "view",
|
|
102
121
|
autoResize: true,
|
|
103
|
-
padding:
|
|
104
|
-
theme:
|
|
105
|
-
plugins:
|
|
106
|
-
{
|
|
107
|
-
key: "title",
|
|
108
|
-
type: "title",
|
|
109
|
-
title,
|
|
110
|
-
titleFill: isDark ? "#e0e6ed" : "#000",
|
|
111
|
-
titleFontFamily: "sans-serif"
|
|
112
|
-
}
|
|
113
|
-
] : [],
|
|
122
|
+
padding: graphTitle.padding,
|
|
123
|
+
theme: rendererTheme,
|
|
124
|
+
plugins: graphTitle.plugins,
|
|
114
125
|
data: graphData,
|
|
115
126
|
node: {
|
|
116
127
|
type: "rect",
|
|
@@ -118,19 +129,21 @@ var FishboneDiagram = (options) => {
|
|
|
118
129
|
var _a;
|
|
119
130
|
const depth = d.depth ?? 0;
|
|
120
131
|
const nodeStyle = {
|
|
121
|
-
radius:
|
|
122
|
-
size: getNodeSize(String(d.id), depth),
|
|
132
|
+
radius: baseTheme === "academy" ? 0 : 8,
|
|
123
133
|
labelText: String(d.id),
|
|
124
134
|
labelPlacement: "left",
|
|
125
135
|
labelFontFamily: FONT_FAMILY
|
|
126
136
|
};
|
|
137
|
+
if (appearance.texture === "rough") {
|
|
138
|
+
nodeStyle.lineWidth = 0.5;
|
|
139
|
+
}
|
|
127
140
|
if (depth === 0) {
|
|
128
141
|
Object.assign(nodeStyle, {
|
|
129
142
|
fill: rootFill,
|
|
130
143
|
labelFill: rootLabelFill,
|
|
131
144
|
labelFontWeight: "bold",
|
|
132
145
|
labelFontSize: 24,
|
|
133
|
-
labelOffsetY:
|
|
146
|
+
labelOffsetY: 0,
|
|
134
147
|
labelPlacement: "center"
|
|
135
148
|
});
|
|
136
149
|
} else if (depth === 1) {
|
|
@@ -144,13 +157,14 @@ var FishboneDiagram = (options) => {
|
|
|
144
157
|
} else {
|
|
145
158
|
Object.assign(nodeStyle, {
|
|
146
159
|
fill: "transparent",
|
|
160
|
+
stroke: "transparent",
|
|
161
|
+
lineWidth: 0,
|
|
147
162
|
labelFill: leafLabelFill,
|
|
148
163
|
labelFontSize: 16
|
|
149
164
|
});
|
|
150
165
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
166
|
+
Object.assign(nodeStyle, depth < 2 ? nodeTheme : leafTheme);
|
|
167
|
+
nodeStyle.size = getNodeSize(String(d.id), depth, nodeStyle);
|
|
154
168
|
return nodeStyle;
|
|
155
169
|
}
|
|
156
170
|
},
|
|
@@ -159,7 +173,8 @@ var FishboneDiagram = (options) => {
|
|
|
159
173
|
style: {
|
|
160
174
|
lineWidth: 3,
|
|
161
175
|
stroke: edgeStroke,
|
|
162
|
-
...
|
|
176
|
+
...appearance.texture === "rough" ? { labelFontFamily: "Comic Sans MS" } : {},
|
|
177
|
+
...edgeTheme
|
|
163
178
|
}
|
|
164
179
|
},
|
|
165
180
|
layout: {
|