@antv/gpt-vis 1.3.1 → 1.4.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 +261 -137
- package/README.zh-CN.md +263 -116
- package/dist/cjs/annotation/components/bottom-n.d.ts +2 -0
- package/dist/cjs/annotation/components/bottom-n.js +57 -0
- package/dist/cjs/annotation/components/centroid.d.ts +2 -0
- package/dist/cjs/annotation/components/centroid.js +75 -0
- package/dist/cjs/annotation/components/connector.d.ts +25 -0
- package/dist/cjs/annotation/components/connector.js +298 -0
- package/dist/cjs/annotation/components/contribution.d.ts +3 -0
- package/dist/cjs/annotation/components/contribution.js +136 -0
- package/dist/cjs/annotation/components/crossing.d.ts +3 -0
- package/dist/cjs/annotation/components/crossing.js +504 -0
- package/dist/cjs/annotation/components/event.d.ts +2 -0
- package/dist/cjs/annotation/components/event.js +62 -0
- package/dist/cjs/annotation/components/first.d.ts +2 -0
- package/dist/cjs/annotation/components/first.js +42 -0
- package/dist/cjs/annotation/components/group.d.ts +3 -0
- package/dist/cjs/annotation/components/group.js +73 -0
- package/dist/cjs/annotation/components/highlight.d.ts +14 -0
- package/dist/cjs/annotation/components/highlight.js +552 -0
- package/dist/cjs/annotation/components/index.d.ts +34 -0
- package/dist/cjs/annotation/components/index.js +128 -0
- package/dist/cjs/annotation/components/last.d.ts +2 -0
- package/dist/cjs/annotation/components/last.js +42 -0
- package/dist/cjs/annotation/components/max-x.d.ts +2 -0
- package/dist/cjs/annotation/components/max-x.js +41 -0
- package/dist/cjs/annotation/components/max-y.d.ts +2 -0
- package/dist/cjs/annotation/components/max-y.js +41 -0
- package/dist/cjs/annotation/components/mean.d.ts +2 -0
- package/dist/cjs/annotation/components/mean.js +50 -0
- package/dist/cjs/annotation/components/median.d.ts +2 -0
- package/dist/cjs/annotation/components/median.js +49 -0
- package/dist/cjs/annotation/components/min-x.d.ts +2 -0
- package/dist/cjs/annotation/components/min-x.js +41 -0
- package/dist/cjs/annotation/components/min-y.d.ts +2 -0
- package/dist/cjs/annotation/components/min-y.js +41 -0
- package/dist/cjs/annotation/components/outlier.d.ts +3 -0
- package/dist/cjs/annotation/components/outlier.js +83 -0
- package/dist/cjs/annotation/components/path.d.ts +20 -0
- package/dist/cjs/annotation/components/path.js +147 -0
- package/dist/cjs/annotation/components/peak.d.ts +2 -0
- package/dist/cjs/annotation/components/peak.js +42 -0
- package/dist/cjs/annotation/components/point.d.ts +26 -0
- package/dist/cjs/annotation/components/point.js +241 -0
- package/dist/cjs/annotation/components/quadrant.d.ts +3 -0
- package/dist/cjs/annotation/components/quadrant.js +97 -0
- package/dist/cjs/annotation/components/quantile.d.ts +2 -0
- package/dist/cjs/annotation/components/quantile.js +49 -0
- package/dist/cjs/annotation/components/range-inside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-inside.js +65 -0
- package/dist/cjs/annotation/components/range-outside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-outside.js +65 -0
- package/dist/cjs/annotation/components/range-x.d.ts +2 -0
- package/dist/cjs/annotation/components/range-x.js +39 -0
- package/dist/cjs/annotation/components/range-y.d.ts +2 -0
- package/dist/cjs/annotation/components/range-y.js +39 -0
- package/dist/cjs/annotation/components/range.d.ts +15 -0
- package/dist/cjs/annotation/components/range.js +87 -0
- package/dist/cjs/annotation/components/target.d.ts +2 -0
- package/dist/cjs/annotation/components/target.js +51 -0
- package/dist/cjs/annotation/components/text.d.ts +15 -0
- package/dist/cjs/annotation/components/text.js +74 -0
- package/dist/cjs/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/cjs/annotation/components/threshold-highlight.js +223 -0
- package/dist/cjs/annotation/components/threshold-x.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-x.js +39 -0
- package/dist/cjs/annotation/components/threshold-y.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-y.js +40 -0
- package/dist/cjs/annotation/components/top-n.d.ts +2 -0
- package/dist/cjs/annotation/components/top-n.js +57 -0
- package/dist/cjs/annotation/components/valley.d.ts +2 -0
- package/dist/cjs/annotation/components/valley.js +42 -0
- package/dist/cjs/annotation/index.d.ts +1 -0
- package/dist/cjs/annotation/index.js +29 -0
- package/dist/cjs/annotation/label.d.ts +38 -0
- package/dist/cjs/annotation/label.js +347 -0
- package/dist/cjs/annotation/layout.d.ts +12 -0
- package/dist/cjs/annotation/layout.js +142 -0
- package/dist/cjs/annotation/merge.d.ts +19 -0
- package/dist/cjs/annotation/merge.js +60 -0
- package/dist/cjs/annotation/registry.d.ts +190 -0
- package/dist/cjs/annotation/registry.js +134 -0
- package/dist/cjs/annotation/runtime/g2.d.ts +90 -0
- package/dist/cjs/annotation/runtime/g2.js +521 -0
- package/dist/cjs/annotation/runtime/g6.d.ts +40 -0
- package/dist/cjs/annotation/runtime/g6.js +310 -0
- package/dist/cjs/annotation/runtime/index.d.ts +11 -0
- package/dist/cjs/annotation/runtime/index.js +41 -0
- package/dist/cjs/annotation/runtime/summary.d.ts +17 -0
- package/dist/cjs/annotation/runtime/summary.js +39 -0
- package/dist/cjs/annotation/runtime/table.d.ts +16 -0
- package/dist/cjs/annotation/runtime/table.js +39 -0
- package/dist/cjs/annotation/utils.d.ts +40 -0
- package/dist/cjs/annotation/utils.js +275 -0
- package/dist/cjs/theme/annotation.d.ts +236 -0
- package/dist/cjs/theme/annotation.js +167 -0
- package/dist/cjs/theme/g2.js +13 -15
- package/dist/cjs/theme/g6.js +2 -2
- package/dist/cjs/theme/summary.js +2 -2
- package/dist/cjs/types/annotation.d.ts +310 -0
- package/dist/cjs/types/annotation.js +17 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/util/axis.d.ts +28 -0
- package/dist/cjs/util/axis.js +184 -0
- package/dist/cjs/util/components.d.ts +0 -10
- package/dist/cjs/util/components.js +9 -64
- package/dist/cjs/util/index.d.ts +7 -4
- package/dist/cjs/util/index.js +53 -9
- package/dist/cjs/vis/area/index.d.ts +2 -0
- package/dist/cjs/vis/area/index.js +30 -13
- package/dist/cjs/vis/bar/index.d.ts +2 -0
- package/dist/cjs/vis/bar/index.js +37 -7
- package/dist/cjs/vis/boxplot/index.js +14 -3
- package/dist/cjs/vis/column/index.d.ts +2 -0
- package/dist/cjs/vis/column/index.js +28 -9
- package/dist/cjs/vis/dual-axes/index.js +9 -9
- package/dist/cjs/vis/fishbone-diagram/index.js +2 -2
- package/dist/cjs/vis/flow-diagram/index.js +2 -2
- package/dist/cjs/vis/funnel/index.js +10 -13
- package/dist/cjs/vis/histogram/index.js +2 -2
- package/dist/cjs/vis/indented-tree/index.js +2 -2
- package/dist/cjs/vis/line/index.d.ts +2 -0
- package/dist/cjs/vis/line/index.js +26 -10
- package/dist/cjs/vis/liquid/index.js +2 -2
- package/dist/cjs/vis/mindmap/index.js +2 -2
- package/dist/cjs/vis/network-graph/index.d.ts +2 -0
- package/dist/cjs/vis/network-graph/index.js +24 -3
- package/dist/cjs/vis/organization-chart/index.js +2 -2
- package/dist/cjs/vis/pie/index.d.ts +2 -0
- package/dist/cjs/vis/pie/index.js +21 -10
- package/dist/cjs/vis/radar/index.js +4 -6
- package/dist/cjs/vis/sankey/index.js +14 -1
- package/dist/cjs/vis/scatter/index.d.ts +10 -3
- package/dist/cjs/vis/scatter/index.js +18 -7
- package/dist/cjs/vis/summary/index.d.ts +9 -2
- package/dist/cjs/vis/summary/index.js +25 -8
- package/dist/cjs/vis/table/index.d.ts +2 -0
- package/dist/cjs/vis/table/index.js +48 -30
- package/dist/cjs/vis/venn/index.js +2 -2
- package/dist/cjs/vis/violin/index.js +14 -3
- package/dist/cjs/vis/waterfall/index.js +17 -9
- package/dist/cjs/vis/word-cloud/index.js +4 -6
- package/dist/cjs/vis-wrapper/index.js +2 -1
- package/dist/esm/annotation/components/bottom-n.d.ts +2 -0
- package/dist/esm/annotation/components/bottom-n.js +42 -0
- package/dist/esm/annotation/components/centroid.d.ts +2 -0
- package/dist/esm/annotation/components/centroid.js +73 -0
- package/dist/esm/annotation/components/connector.d.ts +25 -0
- package/dist/esm/annotation/components/connector.js +332 -0
- package/dist/esm/annotation/components/contribution.d.ts +3 -0
- package/dist/esm/annotation/components/contribution.js +174 -0
- package/dist/esm/annotation/components/crossing.d.ts +3 -0
- package/dist/esm/annotation/components/crossing.js +665 -0
- package/dist/esm/annotation/components/event.d.ts +2 -0
- package/dist/esm/annotation/components/event.js +46 -0
- package/dist/esm/annotation/components/first.d.ts +2 -0
- package/dist/esm/annotation/components/first.js +18 -0
- package/dist/esm/annotation/components/group.d.ts +3 -0
- package/dist/esm/annotation/components/group.js +64 -0
- package/dist/esm/annotation/components/highlight.d.ts +14 -0
- package/dist/esm/annotation/components/highlight.js +838 -0
- package/dist/esm/annotation/components/index.d.ts +34 -0
- package/dist/esm/annotation/components/index.js +34 -0
- package/dist/esm/annotation/components/last.d.ts +2 -0
- package/dist/esm/annotation/components/last.js +18 -0
- package/dist/esm/annotation/components/max-x.d.ts +2 -0
- package/dist/esm/annotation/components/max-x.js +17 -0
- package/dist/esm/annotation/components/max-y.d.ts +2 -0
- package/dist/esm/annotation/components/max-y.js +17 -0
- package/dist/esm/annotation/components/mean.d.ts +2 -0
- package/dist/esm/annotation/components/mean.js +40 -0
- package/dist/esm/annotation/components/median.d.ts +2 -0
- package/dist/esm/annotation/components/median.js +32 -0
- package/dist/esm/annotation/components/min-x.d.ts +2 -0
- package/dist/esm/annotation/components/min-x.js +17 -0
- package/dist/esm/annotation/components/min-y.d.ts +2 -0
- package/dist/esm/annotation/components/min-y.js +17 -0
- package/dist/esm/annotation/components/outlier.d.ts +3 -0
- package/dist/esm/annotation/components/outlier.js +98 -0
- package/dist/esm/annotation/components/path.d.ts +20 -0
- package/dist/esm/annotation/components/path.js +165 -0
- package/dist/esm/annotation/components/peak.d.ts +2 -0
- package/dist/esm/annotation/components/peak.js +20 -0
- package/dist/esm/annotation/components/point.d.ts +26 -0
- package/dist/esm/annotation/components/point.js +277 -0
- package/dist/esm/annotation/components/quadrant.d.ts +3 -0
- package/dist/esm/annotation/components/quadrant.js +83 -0
- package/dist/esm/annotation/components/quantile.d.ts +2 -0
- package/dist/esm/annotation/components/quantile.js +32 -0
- package/dist/esm/annotation/components/range-inside.d.ts +2 -0
- package/dist/esm/annotation/components/range-inside.js +55 -0
- package/dist/esm/annotation/components/range-outside.d.ts +2 -0
- package/dist/esm/annotation/components/range-outside.js +55 -0
- package/dist/esm/annotation/components/range-x.d.ts +2 -0
- package/dist/esm/annotation/components/range-x.js +15 -0
- package/dist/esm/annotation/components/range-y.d.ts +2 -0
- package/dist/esm/annotation/components/range-y.js +15 -0
- package/dist/esm/annotation/components/range.d.ts +15 -0
- package/dist/esm/annotation/components/range.js +92 -0
- package/dist/esm/annotation/components/target.d.ts +2 -0
- package/dist/esm/annotation/components/target.js +44 -0
- package/dist/esm/annotation/components/text.d.ts +15 -0
- package/dist/esm/annotation/components/text.js +78 -0
- package/dist/esm/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/esm/annotation/components/threshold-highlight.js +297 -0
- package/dist/esm/annotation/components/threshold-x.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-x.js +23 -0
- package/dist/esm/annotation/components/threshold-y.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-y.js +24 -0
- package/dist/esm/annotation/components/top-n.d.ts +2 -0
- package/dist/esm/annotation/components/top-n.js +42 -0
- package/dist/esm/annotation/components/valley.d.ts +2 -0
- package/dist/esm/annotation/components/valley.js +20 -0
- package/dist/esm/annotation/index.d.ts +1 -0
- package/dist/esm/annotation/index.js +1 -0
- package/dist/esm/annotation/label.d.ts +38 -0
- package/dist/esm/annotation/label.js +449 -0
- package/dist/esm/annotation/layout.d.ts +12 -0
- package/dist/esm/annotation/layout.js +182 -0
- package/dist/esm/annotation/merge.d.ts +19 -0
- package/dist/esm/annotation/merge.js +67 -0
- package/dist/esm/annotation/registry.d.ts +190 -0
- package/dist/esm/annotation/registry.js +220 -0
- package/dist/esm/annotation/runtime/g2.d.ts +90 -0
- package/dist/esm/annotation/runtime/g2.js +754 -0
- package/dist/esm/annotation/runtime/g6.d.ts +40 -0
- package/dist/esm/annotation/runtime/g6.js +447 -0
- package/dist/esm/annotation/runtime/index.d.ts +11 -0
- package/dist/esm/annotation/runtime/index.js +26 -0
- package/dist/esm/annotation/runtime/summary.d.ts +17 -0
- package/dist/esm/annotation/runtime/summary.js +21 -0
- package/dist/esm/annotation/runtime/table.d.ts +16 -0
- package/dist/esm/annotation/runtime/table.js +21 -0
- package/dist/esm/annotation/utils.d.ts +40 -0
- package/dist/esm/annotation/utils.js +370 -0
- package/dist/esm/theme/annotation.d.ts +236 -0
- package/dist/esm/theme/annotation.js +186 -0
- package/dist/esm/theme/g2.js +2 -10
- package/dist/esm/theme/g6.js +1 -1
- package/dist/esm/theme/summary.js +1 -1
- package/dist/esm/types/annotation.d.ts +310 -0
- package/dist/esm/types/annotation.js +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/util/axis.d.ts +28 -0
- package/dist/esm/util/axis.js +222 -0
- package/dist/esm/util/components.d.ts +0 -10
- package/dist/esm/util/components.js +24 -69
- package/dist/esm/util/index.d.ts +7 -4
- package/dist/esm/util/index.js +7 -4
- package/dist/esm/vis/area/index.d.ts +2 -0
- package/dist/esm/vis/area/index.js +32 -9
- package/dist/esm/vis/bar/index.d.ts +2 -0
- package/dist/esm/vis/bar/index.js +37 -6
- package/dist/esm/vis/boxplot/index.js +10 -2
- package/dist/esm/vis/column/index.d.ts +2 -0
- package/dist/esm/vis/column/index.js +33 -12
- package/dist/esm/vis/dual-axes/index.js +10 -10
- package/dist/esm/vis/fishbone-diagram/index.js +1 -1
- package/dist/esm/vis/flow-diagram/index.js +1 -1
- package/dist/esm/vis/funnel/index.js +2 -7
- package/dist/esm/vis/histogram/index.js +4 -3
- package/dist/esm/vis/indented-tree/index.js +1 -1
- package/dist/esm/vis/line/index.d.ts +2 -0
- package/dist/esm/vis/line/index.js +31 -9
- package/dist/esm/vis/liquid/index.js +1 -1
- package/dist/esm/vis/mindmap/index.js +1 -1
- package/dist/esm/vis/network-graph/index.d.ts +2 -0
- package/dist/esm/vis/network-graph/index.js +29 -2
- package/dist/esm/vis/organization-chart/index.js +1 -1
- package/dist/esm/vis/pie/index.d.ts +2 -0
- package/dist/esm/vis/pie/index.js +25 -8
- package/dist/esm/vis/radar/index.js +1 -3
- package/dist/esm/vis/sankey/index.js +15 -1
- package/dist/esm/vis/scatter/index.d.ts +10 -3
- package/dist/esm/vis/scatter/index.js +28 -5
- package/dist/esm/vis/summary/index.d.ts +9 -2
- package/dist/esm/vis/summary/index.js +31 -13
- package/dist/esm/vis/table/index.d.ts +2 -0
- package/dist/esm/vis/table/index.js +50 -33
- package/dist/esm/vis/venn/index.js +1 -1
- package/dist/esm/vis/violin/index.js +10 -2
- package/dist/esm/vis/waterfall/index.js +16 -13
- package/dist/esm/vis/word-cloud/index.js +1 -3
- package/dist/esm/vis-wrapper/index.js +2 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +2 -2
|
@@ -23,13 +23,13 @@ __export(column_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(column_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
26
27
|
var import_g22 = require("../../theme/g2");
|
|
27
28
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
29
|
var Column = (options) => {
|
|
31
30
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
32
31
|
let chart = null;
|
|
32
|
+
let cleanupAnnotations;
|
|
33
33
|
const render = (config) => {
|
|
34
34
|
var _a;
|
|
35
35
|
const {
|
|
@@ -45,20 +45,24 @@ var Column = (options) => {
|
|
|
45
45
|
style: localStyle = {}
|
|
46
46
|
} = config;
|
|
47
47
|
if (chart) {
|
|
48
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
48
49
|
chart.destroy();
|
|
49
50
|
}
|
|
50
51
|
const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
|
|
51
52
|
const cartesianAxisOptions = {
|
|
53
|
+
xType: "category",
|
|
54
|
+
xValues: data.map(({ category }) => category),
|
|
52
55
|
axisXTitle,
|
|
53
56
|
axisYTitle,
|
|
54
|
-
|
|
55
|
-
chartWidth: width
|
|
57
|
+
container,
|
|
58
|
+
chartWidth: width,
|
|
59
|
+
chartHeight: height
|
|
56
60
|
};
|
|
57
61
|
const appearance = (0, import_g22.getThemeObject)("column", theme, localStyle);
|
|
58
62
|
const { theme: rendererTheme } = appearance;
|
|
59
63
|
const intervalMark = {
|
|
60
64
|
...rendererTheme.type !== "academy" && appearance.mark.interval.radius === void 0 ? { radiusTopLeft: 4, radiusTopRight: 4 } : {},
|
|
61
|
-
columnWidthRatio:
|
|
65
|
+
columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
62
66
|
...!hasGroupField ? { fill: rendererTheme.category10[0] } : {},
|
|
63
67
|
...appearance.mark.interval
|
|
64
68
|
};
|
|
@@ -98,10 +102,9 @@ var Column = (options) => {
|
|
|
98
102
|
encode,
|
|
99
103
|
transform,
|
|
100
104
|
scale: scaleConfig,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
labels: (0, import_components.getDataLabels)(rendererTheme, {
|
|
105
|
+
axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions, rendererTheme),
|
|
106
|
+
legend: (0, import_util.getColorLegend)(hasGroupField),
|
|
107
|
+
labels: (0, import_util.getDataLabels)(rendererTheme, {
|
|
105
108
|
visible: label,
|
|
106
109
|
defaultVisible: true,
|
|
107
110
|
text: "value",
|
|
@@ -125,9 +128,25 @@ var Column = (options) => {
|
|
|
125
128
|
theme: rendererTheme
|
|
126
129
|
};
|
|
127
130
|
chart.options(chartOptions);
|
|
131
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
132
|
+
renderer: "g2",
|
|
133
|
+
chartType: "column",
|
|
134
|
+
chart,
|
|
135
|
+
annotations: config.annotations,
|
|
136
|
+
mapping: {
|
|
137
|
+
x: "category",
|
|
138
|
+
y: "value",
|
|
139
|
+
series: hasGroupField ? "group" : void 0,
|
|
140
|
+
data,
|
|
141
|
+
interval: true
|
|
142
|
+
},
|
|
143
|
+
themeObject: appearance
|
|
144
|
+
});
|
|
128
145
|
chart.render();
|
|
129
146
|
};
|
|
130
147
|
const destroy = () => {
|
|
148
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
149
|
+
cleanupAnnotations = void 0;
|
|
131
150
|
if (chart) {
|
|
132
151
|
chart.destroy();
|
|
133
152
|
chart = null;
|
|
@@ -25,8 +25,6 @@ module.exports = __toCommonJS(dual_axes_exports);
|
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
27
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
28
|
var getSeriesField = (index) => `value_${index + 1}`;
|
|
31
29
|
function transformData(series, categories) {
|
|
32
30
|
return categories.map((category, index) => {
|
|
@@ -58,22 +56,25 @@ var DualAxes = (options) => {
|
|
|
58
56
|
chart.destroy();
|
|
59
57
|
}
|
|
60
58
|
const cartesianAxisOptions = {
|
|
59
|
+
xType: "category",
|
|
60
|
+
xValues: categories,
|
|
61
61
|
axisXTitle,
|
|
62
|
-
|
|
63
|
-
chartWidth: width
|
|
62
|
+
container,
|
|
63
|
+
chartWidth: width,
|
|
64
|
+
chartHeight: height
|
|
64
65
|
};
|
|
65
|
-
const cartesianAxis = (0, import_util.getCartesianAxis)(cartesianAxisOptions);
|
|
66
66
|
const appearance = (0, import_g22.getThemeObject)("dual-axes", theme, localStyle);
|
|
67
67
|
const { theme: rendererTheme } = appearance;
|
|
68
|
+
const cartesianAxis = (0, import_util.getCartesianAxis)(cartesianAxisOptions, rendererTheme);
|
|
68
69
|
const intervalMark = {
|
|
69
70
|
fillOpacity: 0.86,
|
|
70
|
-
columnWidthRatio:
|
|
71
|
+
columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
|
|
71
72
|
...rendererTheme.type !== "academy" && appearance.mark.interval.radius === void 0 ? { radiusTopLeft: 4, radiusTopRight: 4 } : {},
|
|
72
73
|
...appearance.mark.interval
|
|
73
74
|
};
|
|
74
75
|
const lineMark = {
|
|
75
76
|
shape: "smooth",
|
|
76
|
-
lineWidth:
|
|
77
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.lineWidth,
|
|
77
78
|
lineCap: "round",
|
|
78
79
|
lineJoin: "round",
|
|
79
80
|
...appearance.mark.line
|
|
@@ -167,13 +168,12 @@ var DualAxes = (options) => {
|
|
|
167
168
|
}
|
|
168
169
|
});
|
|
169
170
|
const xAxis = cartesianAxis.x;
|
|
170
|
-
const legend = (0,
|
|
171
|
+
const legend = (0, import_util.getColorLegend)(series.length > 0);
|
|
171
172
|
const chartOptions = {
|
|
172
173
|
type: "view",
|
|
173
174
|
data,
|
|
174
175
|
title: title ? { title, subtitle } : "",
|
|
175
176
|
children,
|
|
176
|
-
...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
|
|
177
177
|
axis: { x: xAxis },
|
|
178
178
|
scale: {
|
|
179
179
|
y: { nice: true },
|
|
@@ -24,7 +24,7 @@ __export(fishbone_diagram_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(fishbone_diagram_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
26
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var FONT_FAMILY = "system-ui, sans-serif";
|
|
29
29
|
function getNodeSize(text, depth, style) {
|
|
30
30
|
const defaultFontSize = depth === 0 ? 24 : depth === 1 ? 18 : 16;
|
|
@@ -94,7 +94,7 @@ var FishboneDiagram = (options) => {
|
|
|
94
94
|
throw new Error("FishboneDiagram: container element not found");
|
|
95
95
|
containerEl.innerHTML = "";
|
|
96
96
|
const appearance = (0, import_g62.getThemeObject)("fishbone-diagram", theme, localStyle);
|
|
97
|
-
const graphTitle = (0,
|
|
97
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
98
98
|
const { theme: rendererTheme } = appearance;
|
|
99
99
|
const baseTheme = appearance.baseTheme;
|
|
100
100
|
const isDark = baseTheme === "dark";
|
|
@@ -24,7 +24,7 @@ __export(flow_diagram_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(flow_diagram_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
26
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var ACTIVE_COLOR = "#f6c523";
|
|
29
29
|
var DEFAULT_NODE_WIDTH = 200;
|
|
30
30
|
var DEFAULT_NODE_HEIGHT = 80;
|
|
@@ -129,7 +129,7 @@ var FlowDiagram = (options) => {
|
|
|
129
129
|
}
|
|
130
130
|
ensureBehaviorRegistered();
|
|
131
131
|
const appearance = (0, import_g62.getThemeObject)("flow-diagram", theme, localStyle);
|
|
132
|
-
const graphTitle = (0,
|
|
132
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
133
133
|
const { theme: rendererTheme } = appearance;
|
|
134
134
|
const baseTheme = appearance.baseTheme;
|
|
135
135
|
const colors = appearance.colors;
|
|
@@ -25,8 +25,6 @@ module.exports = __toCommonJS(funnel_exports);
|
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
27
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
28
|
var FUNNEL_LABELS = {
|
|
31
29
|
"en-US": {
|
|
32
30
|
baseline: "Baseline",
|
|
@@ -76,13 +74,13 @@ var Funnel = (options) => {
|
|
|
76
74
|
const intervalMark = {
|
|
77
75
|
shape: "funnel",
|
|
78
76
|
fillOpacity: 0.94,
|
|
79
|
-
stroke: (0,
|
|
77
|
+
stroke: (0, import_util.getChartVisualTokens)(rendererTheme.type).separator,
|
|
80
78
|
lineWidth: 2,
|
|
81
79
|
...rendererTheme.type === "academy" ? {} : { radius: 4 },
|
|
82
80
|
...appearance.mark.interval
|
|
83
81
|
};
|
|
84
82
|
const connectorStyle = {
|
|
85
|
-
stroke: (0,
|
|
83
|
+
stroke: (0, import_util.getChartVisualTokens)(rendererTheme.type).axisLine,
|
|
86
84
|
strokeOpacity: rendererTheme.type === "academy" ? 1 : 0.82,
|
|
87
85
|
lineWidth: rendererTheme.type === "academy" ? 1 : 0.75,
|
|
88
86
|
endMarker: false,
|
|
@@ -90,7 +88,7 @@ var Funnel = (options) => {
|
|
|
90
88
|
...appearance.mark.connector
|
|
91
89
|
};
|
|
92
90
|
const colors = rendererTheme.category10;
|
|
93
|
-
const tokens = (0,
|
|
91
|
+
const tokens = (0, import_util.getChartVisualTokens)(rendererTheme.type);
|
|
94
92
|
const connectorMark = connectorStyle;
|
|
95
93
|
const formatValue = (value) => Number.isFinite(value) ? numberFormatter.format(value) : "—";
|
|
96
94
|
const isInverted = data.length > 1 && data[0].value < data[data.length - 1].value;
|
|
@@ -129,9 +127,9 @@ var Funnel = (options) => {
|
|
|
129
127
|
}
|
|
130
128
|
]
|
|
131
129
|
};
|
|
132
|
-
const primaryLabels = (0,
|
|
130
|
+
const primaryLabels = (0, import_util.getDataLabels)(rendererTheme, {
|
|
133
131
|
style: {
|
|
134
|
-
fontFamily:
|
|
132
|
+
fontFamily: import_util.CHART_FONT_FAMILY,
|
|
135
133
|
fontSize: 12,
|
|
136
134
|
fontWeight: 500,
|
|
137
135
|
lineHeight: 17
|
|
@@ -140,8 +138,7 @@ var Funnel = (options) => {
|
|
|
140
138
|
text: (d) => `${d.category}
|
|
141
139
|
${formatValue(d.value)}`,
|
|
142
140
|
position: "inside",
|
|
143
|
-
contrast: "inside"
|
|
144
|
-
transform: [{ type: "overflowStroke" }]
|
|
141
|
+
contrast: "inside"
|
|
145
142
|
}) ?? [];
|
|
146
143
|
chart = new import_g2.Chart({
|
|
147
144
|
container,
|
|
@@ -183,7 +180,7 @@ ${formatValue(d.value)}`,
|
|
|
183
180
|
dx: 8,
|
|
184
181
|
dy: isInverted ? 6 : -6,
|
|
185
182
|
style: {
|
|
186
|
-
fontFamily:
|
|
183
|
+
fontFamily: import_util.CHART_FONT_FAMILY,
|
|
187
184
|
fontSize: 8,
|
|
188
185
|
fontWeight: 400,
|
|
189
186
|
letterSpacing: -2
|
|
@@ -205,7 +202,7 @@ ${formatValue(d.value)}`,
|
|
|
205
202
|
fill: tokens.textPrimary,
|
|
206
203
|
dx: 26,
|
|
207
204
|
style: {
|
|
208
|
-
fontFamily:
|
|
205
|
+
fontFamily: import_util.CHART_FONT_FAMILY,
|
|
209
206
|
fontSize: 11,
|
|
210
207
|
fontWeight: 500
|
|
211
208
|
}
|
|
@@ -252,7 +249,7 @@ ${formatValue(d.value)}`,
|
|
|
252
249
|
fill: tokens.textPrimary,
|
|
253
250
|
dx: 8,
|
|
254
251
|
style: {
|
|
255
|
-
fontFamily:
|
|
252
|
+
fontFamily: import_util.CHART_FONT_FAMILY,
|
|
256
253
|
fontSize: 11,
|
|
257
254
|
fontWeight: 500
|
|
258
255
|
}
|
|
@@ -264,7 +261,7 @@ ${formatValue(d.value)}`,
|
|
|
264
261
|
axis: false,
|
|
265
262
|
interaction: {
|
|
266
263
|
tooltip: true,
|
|
267
|
-
elementHighlight: { delay:
|
|
264
|
+
elementHighlight: { delay: import_util.CHART_STYLE_DEFAULTS.interactionDelay }
|
|
268
265
|
},
|
|
269
266
|
theme: rendererTheme
|
|
270
267
|
};
|
|
@@ -24,7 +24,7 @@ __export(histogram_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(histogram_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var Histogram = (options) => {
|
|
29
29
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
30
30
|
let chart = null;
|
|
@@ -70,7 +70,7 @@ var Histogram = (options) => {
|
|
|
70
70
|
// binX transform groups continuous data into bins and counts frequency
|
|
71
71
|
transform: [{ type: "binX", y: "count", thresholds: binNumber }],
|
|
72
72
|
style: intervalMark,
|
|
73
|
-
axis: (0,
|
|
73
|
+
axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle, xType: "number" }, rendererTheme),
|
|
74
74
|
scale: {
|
|
75
75
|
y: {
|
|
76
76
|
nice: true
|
|
@@ -24,7 +24,7 @@ __export(indented_tree_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(indented_tree_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
26
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var TreeEvent = {
|
|
29
29
|
COLLAPSE_EXPAND: "collapse-expand",
|
|
30
30
|
ADD_CHILD: "add-child"
|
|
@@ -272,7 +272,7 @@ var IndentedTree = (options) => {
|
|
|
272
272
|
throw new Error("IndentedTree: container element not found");
|
|
273
273
|
containerEl.innerHTML = "";
|
|
274
274
|
const appearance = (0, import_g62.getThemeObject)("indented-tree", theme, localStyle);
|
|
275
|
-
const graphTitle = (0,
|
|
275
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
276
276
|
const { theme: rendererTheme } = appearance;
|
|
277
277
|
const baseTheme = appearance.baseTheme;
|
|
278
278
|
const backgroundColor = appearance.backgroundColor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* LineDataItem is the type for each data item in the line chart.
|
|
@@ -19,6 +20,7 @@ export interface LineConfig {
|
|
|
19
20
|
axisYTitle?: string;
|
|
20
21
|
theme?: VisualizationTheme;
|
|
21
22
|
style?: ThemeStyle;
|
|
23
|
+
annotations?: RendererAnnotation<LineDataItem, 'g2', 'line'>[];
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* LineInstance represents a line chart instance with render and destroy methods.
|
|
@@ -23,15 +23,15 @@ __export(line_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(line_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
26
27
|
var import_g22 = require("../../theme/g2");
|
|
27
28
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_tokens = require("../../util/tokens");
|
|
30
29
|
var Line = (options) => {
|
|
31
30
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
32
31
|
let chart = null;
|
|
33
32
|
let hasRendered = false;
|
|
34
33
|
let cleanupCrosshairAxisLabels = null;
|
|
34
|
+
let cleanupAnnotations;
|
|
35
35
|
const render = (config) => {
|
|
36
36
|
var _a;
|
|
37
37
|
const {
|
|
@@ -44,6 +44,7 @@ var Line = (options) => {
|
|
|
44
44
|
style: localStyle = {}
|
|
45
45
|
} = config;
|
|
46
46
|
if (chart) {
|
|
47
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
47
48
|
cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
|
|
48
49
|
cleanupCrosshairAxisLabels = null;
|
|
49
50
|
chart.destroy();
|
|
@@ -52,21 +53,25 @@ var Line = (options) => {
|
|
|
52
53
|
const cartesianAxisOptions = {
|
|
53
54
|
axisXTitle,
|
|
54
55
|
axisYTitle,
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
preferHorizontal: true,
|
|
57
|
+
xValues: data.map(({ time }) => time),
|
|
58
|
+
container,
|
|
59
|
+
chartWidth: width,
|
|
60
|
+
chartHeight: height
|
|
57
61
|
};
|
|
58
62
|
const appearance = (0, import_g22.getThemeObject)("line", theme, localStyle);
|
|
59
63
|
const { theme: rendererTheme } = appearance;
|
|
64
|
+
const cartesianAxis = (0, import_util.createCartesianAxis)(cartesianAxisOptions, rendererTheme);
|
|
60
65
|
const lineMark = {
|
|
61
|
-
lineWidth:
|
|
66
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.lineWidth,
|
|
62
67
|
lineCap: "round",
|
|
63
68
|
lineJoin: "round",
|
|
64
69
|
...appearance.mark.line
|
|
65
70
|
};
|
|
66
71
|
const pointStyle = {
|
|
67
72
|
shape: "point",
|
|
68
|
-
size:
|
|
69
|
-
lineWidth:
|
|
73
|
+
size: import_util.CHART_STYLE_DEFAULTS.pointSize,
|
|
74
|
+
lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
70
75
|
stroke: rendererTheme.view.viewFill,
|
|
71
76
|
...appearance.mark.point
|
|
72
77
|
};
|
|
@@ -133,20 +138,31 @@ var Line = (options) => {
|
|
|
133
138
|
encode,
|
|
134
139
|
children,
|
|
135
140
|
scale: scaleConfig,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
legend: (0,
|
|
141
|
+
axis: cartesianAxis.axis,
|
|
142
|
+
...cartesianAxis.layout(),
|
|
143
|
+
legend: (0, import_util.getColorLegend)(hasGroupField),
|
|
139
144
|
interaction: {
|
|
140
145
|
tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true })
|
|
141
146
|
},
|
|
142
147
|
theme: rendererTheme
|
|
143
148
|
};
|
|
144
149
|
chart.options(chartOptions);
|
|
150
|
+
(0, import_util.bindCartesianAxisLayout)(chart, cartesianAxis);
|
|
151
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
152
|
+
renderer: "g2",
|
|
153
|
+
chartType: "line",
|
|
154
|
+
chart,
|
|
155
|
+
annotations: config.annotations,
|
|
156
|
+
mapping: { x: "time", y: "value", series: hasGroupField ? "group" : void 0, data },
|
|
157
|
+
themeObject: appearance
|
|
158
|
+
});
|
|
145
159
|
cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, baseTheme);
|
|
146
160
|
chart.render();
|
|
147
161
|
hasRendered = true;
|
|
148
162
|
};
|
|
149
163
|
const destroy = () => {
|
|
164
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
165
|
+
cleanupAnnotations = void 0;
|
|
150
166
|
if (chart) {
|
|
151
167
|
cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
|
|
152
168
|
cleanupCrosshairAxisLabels = null;
|
|
@@ -24,7 +24,7 @@ __export(liquid_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(liquid_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
26
|
var import_g22 = require("../../theme/g2");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var DEFAULT_WIDTH = 640;
|
|
29
29
|
var DEFAULT_HEIGHT = 480;
|
|
30
30
|
var Liquid = (options) => {
|
|
@@ -70,7 +70,7 @@ var Liquid = (options) => {
|
|
|
70
70
|
contentStroke: backgroundColor,
|
|
71
71
|
contentStrokeOpacity: 0.92,
|
|
72
72
|
contentLineWidth: baseTheme === "dark" ? 3 : 2.5,
|
|
73
|
-
contentFontFamily:
|
|
73
|
+
contentFontFamily: import_util.CHART_FONT_FAMILY,
|
|
74
74
|
contentFontWeight: 600,
|
|
75
75
|
contentLetterSpacing: -0.8,
|
|
76
76
|
contentFontVariantNumeric: "tabular-nums",
|
|
@@ -24,7 +24,7 @@ __export(mindmap_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(mindmap_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
26
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
function toG6TreeData(node) {
|
|
29
29
|
return {
|
|
30
30
|
id: node.name,
|
|
@@ -100,7 +100,7 @@ var Mindmap = (options) => {
|
|
|
100
100
|
}
|
|
101
101
|
containerEl.innerHTML = "";
|
|
102
102
|
const appearance = (0, import_g62.getThemeObject)("mindmap", theme, localStyle);
|
|
103
|
-
const graphTitle = (0,
|
|
103
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
104
104
|
const { theme: rendererTheme } = appearance;
|
|
105
105
|
const baseTheme = appearance.baseTheme;
|
|
106
106
|
const colors = appearance.colors;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
export type NetworkGraphNode = GraphData['nodes'][number];
|
|
3
4
|
export type NetworkGraphEdge = GraphData['edges'][number];
|
|
@@ -13,6 +14,7 @@ export interface NetworkGraphConfig {
|
|
|
13
14
|
title?: string;
|
|
14
15
|
subtitle?: string;
|
|
15
16
|
style?: ThemeStyle;
|
|
17
|
+
annotations?: RendererAnnotation<NetworkGraphNode | NetworkGraphEdge, 'g6', 'network-graph'>[];
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* NetworkGraphInstance represents a network graph instance with render and destroy methods.
|
|
@@ -23,11 +23,14 @@ __export(network_graph_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(network_graph_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
27
|
+
var import_annotation2 = require("../../theme/annotation");
|
|
26
28
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
29
|
+
var import_util = require("../../util");
|
|
28
30
|
var NetworkGraph = (options) => {
|
|
29
31
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
30
32
|
let graph = null;
|
|
33
|
+
let cleanupAnnotations;
|
|
31
34
|
const render = (config) => {
|
|
32
35
|
const {
|
|
33
36
|
data = { nodes: [], edges: [] },
|
|
@@ -39,11 +42,12 @@ var NetworkGraph = (options) => {
|
|
|
39
42
|
} = config;
|
|
40
43
|
const { nodes = [], edges = [] } = data;
|
|
41
44
|
if (graph) {
|
|
45
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
42
46
|
graph.destroy();
|
|
43
47
|
graph = null;
|
|
44
48
|
}
|
|
45
49
|
const appearance = (0, import_g62.getThemeObject)("network-graph", theme, localStyle);
|
|
46
|
-
const graphTitle = (0,
|
|
50
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
47
51
|
const { theme: rendererTheme } = appearance;
|
|
48
52
|
const baseTheme = appearance.baseTheme;
|
|
49
53
|
const colors = appearance.colors;
|
|
@@ -73,7 +77,14 @@ var NetworkGraph = (options) => {
|
|
|
73
77
|
labelText: node.name
|
|
74
78
|
}
|
|
75
79
|
}));
|
|
76
|
-
const
|
|
80
|
+
const edgeIds = edges.map((_, index) => {
|
|
81
|
+
let id = `gpt-vis-edge-${index}`;
|
|
82
|
+
while (nodes.some((node) => node.name === id))
|
|
83
|
+
id = `_${id}`;
|
|
84
|
+
return id;
|
|
85
|
+
});
|
|
86
|
+
const edgeData = edges.map((edge, index) => ({
|
|
87
|
+
id: edgeIds[index],
|
|
77
88
|
source: edge.source,
|
|
78
89
|
target: edge.target,
|
|
79
90
|
data: { label: edge.name ?? "" },
|
|
@@ -149,9 +160,19 @@ var NetworkGraph = (options) => {
|
|
|
149
160
|
behaviors: ["drag-canvas", "drag-element", "click-select"],
|
|
150
161
|
plugins: graphTitle.plugins
|
|
151
162
|
});
|
|
163
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
164
|
+
renderer: "g6",
|
|
165
|
+
graph,
|
|
166
|
+
annotations: config.annotations,
|
|
167
|
+
data: { nodes, edges },
|
|
168
|
+
edgeIds,
|
|
169
|
+
defaults: (0, import_annotation2.getAnnotationDefaults)("network-graph", theme, localStyle)
|
|
170
|
+
});
|
|
152
171
|
graph.render();
|
|
153
172
|
};
|
|
154
173
|
const destroy = () => {
|
|
174
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
175
|
+
cleanupAnnotations = void 0;
|
|
155
176
|
if (graph) {
|
|
156
177
|
graph.destroy();
|
|
157
178
|
graph = null;
|
|
@@ -24,7 +24,7 @@ __export(organization_chart_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(organization_chart_exports);
|
|
25
25
|
var import_g6 = require("@antv/g6");
|
|
26
26
|
var import_g62 = require("../../theme/g6");
|
|
27
|
-
var
|
|
27
|
+
var import_util = require("../../util");
|
|
28
28
|
var NODE_WIDTH = 160;
|
|
29
29
|
var NODE_HEIGHT_WITH_DESC = 72;
|
|
30
30
|
var NODE_HEIGHT_NO_DESC = 40;
|
|
@@ -56,7 +56,7 @@ var OrganizationChart = (options) => {
|
|
|
56
56
|
}
|
|
57
57
|
containerEl.innerHTML = "";
|
|
58
58
|
const appearance = (0, import_g62.getThemeObject)("organization-chart", theme, localStyle);
|
|
59
|
-
const graphTitle = (0,
|
|
59
|
+
const graphTitle = (0, import_util.getGraphTitle)(title, subtitle, appearance.titleStyle);
|
|
60
60
|
const { theme: rendererTheme } = appearance;
|
|
61
61
|
const baseTheme = appearance.baseTheme;
|
|
62
62
|
const colors = appearance.colors;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* PieDataItem is the type for each data item in the pie chart.
|
|
@@ -17,6 +18,7 @@ export interface PieConfig {
|
|
|
17
18
|
title?: string;
|
|
18
19
|
subtitle?: string;
|
|
19
20
|
style?: ThemeStyle;
|
|
21
|
+
annotations?: RendererAnnotation<PieDataItem, 'g2', 'pie'>[];
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* PieInstance represents a pie chart instance with render and destroy methods.
|
|
@@ -23,14 +23,13 @@ __export(pie_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(pie_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_annotation = require("../../annotation");
|
|
26
27
|
var import_g22 = require("../../theme/g2");
|
|
27
28
|
var import_util = require("../../util");
|
|
28
|
-
var import_components = require("../../util/components");
|
|
29
|
-
var import_interaction = require("../../util/interaction");
|
|
30
|
-
var import_tokens = require("../../util/tokens");
|
|
31
29
|
var Pie = (options) => {
|
|
32
30
|
const { container, width, height, theme: chartTheme = "default" } = options;
|
|
33
31
|
let chart = null;
|
|
32
|
+
let cleanupAnnotations;
|
|
34
33
|
let hasRendered = false;
|
|
35
34
|
const PERCENTAGE_PRECISION_MULTIPLIER = 1e4;
|
|
36
35
|
const render = (config) => {
|
|
@@ -43,6 +42,7 @@ var Pie = (options) => {
|
|
|
43
42
|
style: localStyle = {}
|
|
44
43
|
} = config;
|
|
45
44
|
if (chart) {
|
|
45
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
46
46
|
chart.destroy();
|
|
47
47
|
}
|
|
48
48
|
const sumValue = data.reduce((sum, item) => sum + item.value, 0);
|
|
@@ -50,7 +50,7 @@ var Pie = (options) => {
|
|
|
50
50
|
const { theme: rendererTheme } = appearance;
|
|
51
51
|
const intervalMark = {
|
|
52
52
|
fillOpacity: 1,
|
|
53
|
-
stroke: (0,
|
|
53
|
+
stroke: (0, import_util.getChartVisualTokens)(rendererTheme.type).separator,
|
|
54
54
|
lineWidth: 2,
|
|
55
55
|
...appearance.mark.interval
|
|
56
56
|
};
|
|
@@ -78,14 +78,15 @@ var Pie = (options) => {
|
|
|
78
78
|
scale: {
|
|
79
79
|
color: { range: colors }
|
|
80
80
|
},
|
|
81
|
-
legend: (0,
|
|
82
|
-
labels: (0,
|
|
81
|
+
legend: (0, import_util.getColorLegend)(true),
|
|
82
|
+
labels: (0, import_util.getDataLabels)(rendererTheme, {
|
|
83
83
|
defaultVisible: data.length <= 8,
|
|
84
84
|
text: (d) => {
|
|
85
85
|
const percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
|
|
86
86
|
const formattedPercentage = Number(percentage.toFixed(1)).toString();
|
|
87
87
|
return `${d.category}: ${formattedPercentage}%`;
|
|
88
88
|
},
|
|
89
|
+
style: { annotationNativePercentage: true },
|
|
89
90
|
position: "outside",
|
|
90
91
|
contrast: "outside",
|
|
91
92
|
transform: [{ type: "exceedAdjust", offsetX: 4, offsetY: 4 }, { type: "overlapHide" }]
|
|
@@ -100,26 +101,36 @@ var Pie = (options) => {
|
|
|
100
101
|
},
|
|
101
102
|
interaction: {
|
|
102
103
|
tooltip: true,
|
|
103
|
-
elementHighlight: { delay:
|
|
104
|
+
elementHighlight: { delay: import_util.CHART_STYLE_DEFAULTS.interactionDelay },
|
|
104
105
|
elementHoverScale: {
|
|
105
|
-
...(0,
|
|
106
|
+
...(0, import_util.getElementHoverScaleInteraction)(rendererTheme.type),
|
|
106
107
|
shadow: false
|
|
107
108
|
},
|
|
108
109
|
elementSelect: { single: true }
|
|
109
110
|
},
|
|
110
111
|
state: {
|
|
111
|
-
active: { fillOpacity: 1
|
|
112
|
+
active: { fillOpacity: 1 },
|
|
112
113
|
inactive: { fillOpacity: 0.3 },
|
|
113
|
-
selected: { fillOpacity: 1
|
|
114
|
+
selected: { fillOpacity: 1 }
|
|
114
115
|
},
|
|
115
116
|
style: intervalMark,
|
|
116
117
|
theme: rendererTheme
|
|
117
118
|
};
|
|
118
119
|
chart.options(chartOptions);
|
|
120
|
+
cleanupAnnotations = (0, import_annotation.bindAnnotations)({
|
|
121
|
+
renderer: "g2",
|
|
122
|
+
chartType: "pie",
|
|
123
|
+
chart,
|
|
124
|
+
annotations: config.annotations,
|
|
125
|
+
mapping: { x: "category", y: "value", data },
|
|
126
|
+
themeObject: appearance
|
|
127
|
+
});
|
|
119
128
|
chart.render();
|
|
120
129
|
hasRendered = true;
|
|
121
130
|
};
|
|
122
131
|
const destroy = () => {
|
|
132
|
+
cleanupAnnotations == null ? void 0 : cleanupAnnotations();
|
|
133
|
+
cleanupAnnotations = void 0;
|
|
123
134
|
if (chart) {
|
|
124
135
|
chart.destroy();
|
|
125
136
|
chart = null;
|