@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
|
@@ -5,10 +5,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Chart } from '@antv/g2';
|
|
8
|
+
import { bindAnnotations } from "../../annotation";
|
|
8
9
|
import { getThemeObject } from "../../theme/g2";
|
|
9
|
-
import {
|
|
10
|
-
import { getColorLegend, getDataLabels } from "../../util/components";
|
|
11
|
-
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
10
|
+
import { CHART_STYLE_DEFAULTS, getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getColorLegend, getDataLabels } from "../../util";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* ColumnDataItem is the type for each data item in the column chart.
|
|
@@ -55,6 +54,7 @@ export var Column = function Column(options) {
|
|
|
55
54
|
_options$theme = options.theme,
|
|
56
55
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
57
56
|
var chart = null;
|
|
57
|
+
var cleanupAnnotations;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Render the column chart with the given configuration.
|
|
@@ -79,17 +79,22 @@ export var Column = function Column(options) {
|
|
|
79
79
|
|
|
80
80
|
// Clean up previous chart if exists
|
|
81
81
|
if (chart) {
|
|
82
|
+
var _cleanupAnnotations;
|
|
83
|
+
(_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
|
|
82
84
|
chart.destroy();
|
|
83
85
|
}
|
|
84
86
|
var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
|
|
85
87
|
var cartesianAxisOptions = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
xLabels: data.map(function (_ref) {
|
|
88
|
+
xType: 'category',
|
|
89
|
+
xValues: data.map(function (_ref) {
|
|
89
90
|
var category = _ref.category;
|
|
90
91
|
return category;
|
|
91
92
|
}),
|
|
92
|
-
|
|
93
|
+
axisXTitle: axisXTitle,
|
|
94
|
+
axisYTitle: axisYTitle,
|
|
95
|
+
container: container,
|
|
96
|
+
chartWidth: width,
|
|
97
|
+
chartHeight: height
|
|
93
98
|
};
|
|
94
99
|
var appearance = getThemeObject('column', theme, localStyle);
|
|
95
100
|
var rendererTheme = appearance.theme;
|
|
@@ -156,7 +161,7 @@ export var Column = function Column(options) {
|
|
|
156
161
|
// Configure chart options
|
|
157
162
|
// Note: Using 'any' type due to G2's complex type system with transformations
|
|
158
163
|
// This is consistent with how G2 5.0 is used elsewhere in the codebase
|
|
159
|
-
var chartOptions =
|
|
164
|
+
var chartOptions = {
|
|
160
165
|
// G2 growInY currently computes interval label bounds from the animated
|
|
161
166
|
// clip path, which leaves inside labels at the axis baseline. Keep the
|
|
162
167
|
// interval and its labels in sync until the upstream runtime is fixed.
|
|
@@ -169,9 +174,8 @@ export var Column = function Column(options) {
|
|
|
169
174
|
} : '',
|
|
170
175
|
encode: encode,
|
|
171
176
|
transform: transform,
|
|
172
|
-
scale: scaleConfig
|
|
173
|
-
|
|
174
|
-
axis: getCartesianAxis(cartesianAxisOptions),
|
|
177
|
+
scale: scaleConfig,
|
|
178
|
+
axis: getCartesianAxis(cartesianAxisOptions, rendererTheme),
|
|
175
179
|
legend: getColorLegend(hasGroupField),
|
|
176
180
|
labels: getDataLabels(rendererTheme, {
|
|
177
181
|
visible: label,
|
|
@@ -195,8 +199,22 @@ export var Column = function Column(options) {
|
|
|
195
199
|
},
|
|
196
200
|
style: intervalMark,
|
|
197
201
|
theme: rendererTheme
|
|
198
|
-
}
|
|
202
|
+
};
|
|
199
203
|
chart.options(chartOptions);
|
|
204
|
+
cleanupAnnotations = bindAnnotations({
|
|
205
|
+
renderer: 'g2',
|
|
206
|
+
chartType: 'column',
|
|
207
|
+
chart: chart,
|
|
208
|
+
annotations: config.annotations,
|
|
209
|
+
mapping: {
|
|
210
|
+
x: 'category',
|
|
211
|
+
y: 'value',
|
|
212
|
+
series: hasGroupField ? 'group' : undefined,
|
|
213
|
+
data: data,
|
|
214
|
+
interval: true
|
|
215
|
+
},
|
|
216
|
+
themeObject: appearance
|
|
217
|
+
});
|
|
200
218
|
chart.render();
|
|
201
219
|
};
|
|
202
220
|
|
|
@@ -204,6 +222,9 @@ export var Column = function Column(options) {
|
|
|
204
222
|
* Destroy the chart instance and clean up resources.
|
|
205
223
|
*/
|
|
206
224
|
var destroy = function destroy() {
|
|
225
|
+
var _cleanupAnnotations2;
|
|
226
|
+
(_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
|
|
227
|
+
cleanupAnnotations = undefined;
|
|
207
228
|
if (chart) {
|
|
208
229
|
chart.destroy();
|
|
209
230
|
chart = null;
|
|
@@ -6,9 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Chart } from '@antv/g2';
|
|
8
8
|
import { getThemeObject } from "../../theme/g2";
|
|
9
|
-
import { bindCrosshairAxisLabels,
|
|
10
|
-
import { getColorLegend } from "../../util/components";
|
|
11
|
-
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
9
|
+
import { bindCrosshairAxisLabels, CHART_STYLE_DEFAULTS, getCartesianAxis, getChartAnimation, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* DualAxesSeriesItem defines a single series in the dual-axes chart.
|
|
@@ -104,13 +102,16 @@ export var DualAxes = function DualAxes(options) {
|
|
|
104
102
|
chart.destroy();
|
|
105
103
|
}
|
|
106
104
|
var cartesianAxisOptions = {
|
|
105
|
+
xType: 'category',
|
|
106
|
+
xValues: categories,
|
|
107
107
|
axisXTitle: axisXTitle,
|
|
108
|
-
|
|
109
|
-
chartWidth: width
|
|
108
|
+
container: container,
|
|
109
|
+
chartWidth: width,
|
|
110
|
+
chartHeight: height
|
|
110
111
|
};
|
|
111
|
-
var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
|
|
112
112
|
var appearance = getThemeObject('dual-axes', theme, localStyle);
|
|
113
113
|
var rendererTheme = appearance.theme;
|
|
114
|
+
var cartesianAxis = getCartesianAxis(cartesianAxisOptions, rendererTheme);
|
|
114
115
|
var intervalMark = _objectSpread(_objectSpread({
|
|
115
116
|
fillOpacity: 0.86,
|
|
116
117
|
columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
|
|
@@ -261,15 +262,14 @@ export var DualAxes = function DualAxes(options) {
|
|
|
261
262
|
// Configure chart options
|
|
262
263
|
// Note: Using 'any' type due to G2's complex type system with transformations
|
|
263
264
|
// This is consistent with how G2 5.0 is used elsewhere in the codebase
|
|
264
|
-
var chartOptions =
|
|
265
|
+
var chartOptions = {
|
|
265
266
|
type: 'view',
|
|
266
267
|
data: data,
|
|
267
268
|
title: title ? {
|
|
268
269
|
title: title,
|
|
269
270
|
subtitle: subtitle
|
|
270
271
|
} : '',
|
|
271
|
-
children: children
|
|
272
|
-
}, getCartesianLayout(cartesianAxisOptions)), {}, {
|
|
272
|
+
children: children,
|
|
273
273
|
axis: {
|
|
274
274
|
x: xAxis
|
|
275
275
|
},
|
|
@@ -306,7 +306,7 @@ export var DualAxes = function DualAxes(options) {
|
|
|
306
306
|
})
|
|
307
307
|
}, getSeriesHighlightByColorInteraction()),
|
|
308
308
|
theme: rendererTheme
|
|
309
|
-
}
|
|
309
|
+
};
|
|
310
310
|
chart.options(chartOptions);
|
|
311
311
|
var lineYFields = seriesMeta.filter(function (_ref6) {
|
|
312
312
|
var item = _ref6.item;
|
|
@@ -15,7 +15,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
15
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
16
|
import { Graph, treeToGraphData } from '@antv/g6';
|
|
17
17
|
import { getThemeObject } from "../../theme/g6";
|
|
18
|
-
import { getGraphTitle } from "../../util
|
|
18
|
+
import { getGraphTitle } from "../../util";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
|
|
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
23
23
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
24
|
import { ExtensionCategory, Graph, HoverActivate, idOf, register } from '@antv/g6';
|
|
25
25
|
import { getThemeObject } from "../../theme/g6";
|
|
26
|
-
import { getGraphTitle } from "../../util
|
|
26
|
+
import { getGraphTitle } from "../../util";
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* FlowDiagramConfig defines the configuration for rendering the flow diagram.
|
|
@@ -12,9 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
import { Chart } from '@antv/g2';
|
|
14
14
|
import { getThemeObject } from "../../theme/g2";
|
|
15
|
-
import { resolveChartLocale } from "../../util";
|
|
16
|
-
import { getDataLabels } from "../../util/components";
|
|
17
|
-
import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../../util/tokens";
|
|
15
|
+
import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens, getDataLabels, resolveChartLocale } from "../../util";
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* FunnelDataItem is the type for each data item in the funnel chart.
|
|
@@ -178,10 +176,7 @@ export var Funnel = function Funnel(options) {
|
|
|
178
176
|
return "".concat(d.category, "\n").concat(formatValue(d.value));
|
|
179
177
|
},
|
|
180
178
|
position: 'inside',
|
|
181
|
-
contrast: 'inside'
|
|
182
|
-
transform: [{
|
|
183
|
-
type: 'overflowStroke'
|
|
184
|
-
}]
|
|
179
|
+
contrast: 'inside'
|
|
185
180
|
})) !== null && _getDataLabels !== void 0 ? _getDataLabels : [];
|
|
186
181
|
|
|
187
182
|
// Create chart
|
|
@@ -6,7 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Chart } from '@antv/g2';
|
|
8
8
|
import { getThemeObject } from "../../theme/g2";
|
|
9
|
-
import { getCartesianAxis } from "../../util
|
|
9
|
+
import { getCartesianAxis } from "../../util";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* HistogramConfig defines the configuration for rendering the histogram chart.
|
|
@@ -114,8 +114,9 @@ export var Histogram = function Histogram(options) {
|
|
|
114
114
|
style: intervalMark,
|
|
115
115
|
axis: getCartesianAxis({
|
|
116
116
|
axisXTitle: axisXTitle,
|
|
117
|
-
axisYTitle: axisYTitle
|
|
118
|
-
|
|
117
|
+
axisYTitle: axisYTitle,
|
|
118
|
+
xType: 'number'
|
|
119
|
+
}, rendererTheme),
|
|
119
120
|
scale: {
|
|
120
121
|
y: {
|
|
121
122
|
nice: true
|
|
@@ -28,7 +28,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
28
28
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
29
29
|
import { Badge, BaseBehavior, BaseNode, CommonEvent, ExtensionCategory, Graph, NodeEvent, Polyline, iconfont, register, subStyleProps, treeToGraphData } from '@antv/g6';
|
|
30
30
|
import { getThemeObject } from "../../theme/g6";
|
|
31
|
-
import { getGraphTitle } from "../../util
|
|
31
|
+
import { getGraphTitle } from "../../util";
|
|
32
32
|
|
|
33
33
|
// ---------------------------------------------------------------------------
|
|
34
34
|
// Official G6 indented-tree implementation (adapted for GPT-Vis)
|
|
@@ -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.
|
|
@@ -8,10 +8,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
10
|
import { Chart } from '@antv/g2';
|
|
11
|
+
import { bindAnnotations } from "../../annotation";
|
|
11
12
|
import { getThemeObject } from "../../theme/g2";
|
|
12
|
-
import { bindCrosshairAxisLabels,
|
|
13
|
-
import { getColorLegend } from "../../util/components";
|
|
14
|
-
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
13
|
+
import { bindCartesianAxisLayout, bindCrosshairAxisLabels, CHART_STYLE_DEFAULTS, createCartesianAxis, getChartAnimation, getColorLegend, getSharedTooltipInteraction } from "../../util";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* LineDataItem is the type for each data item in the line chart.
|
|
@@ -60,6 +59,7 @@ export var Line = function Line(options) {
|
|
|
60
59
|
var chart = null;
|
|
61
60
|
var hasRendered = false;
|
|
62
61
|
var cleanupCrosshairAxisLabels = null;
|
|
62
|
+
var cleanupAnnotations;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Render the line chart with the given configuration.
|
|
@@ -79,7 +79,8 @@ export var Line = function Line(options) {
|
|
|
79
79
|
|
|
80
80
|
// Clean up previous chart if exists
|
|
81
81
|
if (chart) {
|
|
82
|
-
var _cleanupCrosshairAxis;
|
|
82
|
+
var _cleanupAnnotations, _cleanupCrosshairAxis;
|
|
83
|
+
(_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
|
|
83
84
|
(_cleanupCrosshairAxis = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis === void 0 || _cleanupCrosshairAxis();
|
|
84
85
|
cleanupCrosshairAxisLabels = null;
|
|
85
86
|
chart.destroy();
|
|
@@ -88,14 +89,18 @@ export var Line = function Line(options) {
|
|
|
88
89
|
var cartesianAxisOptions = {
|
|
89
90
|
axisXTitle: axisXTitle,
|
|
90
91
|
axisYTitle: axisYTitle,
|
|
91
|
-
|
|
92
|
+
preferHorizontal: true,
|
|
93
|
+
xValues: data.map(function (_ref) {
|
|
92
94
|
var time = _ref.time;
|
|
93
95
|
return time;
|
|
94
96
|
}),
|
|
95
|
-
|
|
97
|
+
container: container,
|
|
98
|
+
chartWidth: width,
|
|
99
|
+
chartHeight: height
|
|
96
100
|
};
|
|
97
101
|
var appearance = getThemeObject('line', theme, localStyle);
|
|
98
102
|
var rendererTheme = appearance.theme;
|
|
103
|
+
var cartesianAxis = createCartesianAxis(cartesianAxisOptions, rendererTheme);
|
|
99
104
|
var lineMark = _objectSpread({
|
|
100
105
|
lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
|
|
101
106
|
lineCap: 'round',
|
|
@@ -191,9 +196,9 @@ export var Line = function Line(options) {
|
|
|
191
196
|
} : '',
|
|
192
197
|
encode: encode,
|
|
193
198
|
children: children,
|
|
194
|
-
scale: scaleConfig
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
scale: scaleConfig,
|
|
200
|
+
axis: cartesianAxis.axis
|
|
201
|
+
}, cartesianAxis.layout()), {}, {
|
|
197
202
|
legend: getColorLegend(hasGroupField),
|
|
198
203
|
interaction: {
|
|
199
204
|
tooltip: getSharedTooltipInteraction({
|
|
@@ -203,6 +208,20 @@ export var Line = function Line(options) {
|
|
|
203
208
|
theme: rendererTheme
|
|
204
209
|
});
|
|
205
210
|
chart.options(chartOptions);
|
|
211
|
+
bindCartesianAxisLayout(chart, cartesianAxis);
|
|
212
|
+
cleanupAnnotations = bindAnnotations({
|
|
213
|
+
renderer: 'g2',
|
|
214
|
+
chartType: 'line',
|
|
215
|
+
chart: chart,
|
|
216
|
+
annotations: config.annotations,
|
|
217
|
+
mapping: {
|
|
218
|
+
x: 'time',
|
|
219
|
+
y: 'value',
|
|
220
|
+
series: hasGroupField ? 'group' : undefined,
|
|
221
|
+
data: data
|
|
222
|
+
},
|
|
223
|
+
themeObject: appearance
|
|
224
|
+
});
|
|
206
225
|
cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, baseTheme);
|
|
207
226
|
chart.render();
|
|
208
227
|
hasRendered = true;
|
|
@@ -212,6 +231,9 @@ export var Line = function Line(options) {
|
|
|
212
231
|
* Destroy the chart instance and clean up resources.
|
|
213
232
|
*/
|
|
214
233
|
var destroy = function destroy() {
|
|
234
|
+
var _cleanupAnnotations2;
|
|
235
|
+
(_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
|
|
236
|
+
cleanupAnnotations = undefined;
|
|
215
237
|
if (chart) {
|
|
216
238
|
var _cleanupCrosshairAxis2;
|
|
217
239
|
(_cleanupCrosshairAxis2 = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis2 === void 0 || _cleanupCrosshairAxis2();
|
|
@@ -6,7 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Chart } from '@antv/g2';
|
|
8
8
|
import { getThemeObject } from "../../theme/g2";
|
|
9
|
-
import { CHART_FONT_FAMILY } from "../../util
|
|
9
|
+
import { CHART_FONT_FAMILY } from "../../util";
|
|
10
10
|
|
|
11
11
|
// Default dimensions used for font size calculation when not explicitly provided
|
|
12
12
|
var DEFAULT_WIDTH = 640;
|
|
@@ -16,7 +16,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
17
|
import { Graph, idOf, positionOf, treeToGraphData } from '@antv/g6';
|
|
18
18
|
import { getThemeObject } from "../../theme/g6";
|
|
19
|
-
import { getGraphTitle } from "../../util
|
|
19
|
+
import { getGraphTitle } from "../../util";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* MindmapConfig defines the configuration for rendering the mindmap.
|
|
@@ -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.
|
|
@@ -5,8 +5,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Graph } from '@antv/g6';
|
|
8
|
+
import { bindAnnotations } from "../../annotation";
|
|
9
|
+
import { getAnnotationDefaults } from "../../theme/annotation";
|
|
8
10
|
import { getThemeObject } from "../../theme/g6";
|
|
9
|
-
import { getGraphTitle } from "../../util
|
|
11
|
+
import { getGraphTitle } from "../../util";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* NetworkGraphConfig defines the configuration for rendering the network graph.
|
|
@@ -54,6 +56,7 @@ export var NetworkGraph = function NetworkGraph(options) {
|
|
|
54
56
|
_options$theme = options.theme,
|
|
55
57
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
56
58
|
var graph = null;
|
|
59
|
+
var cleanupAnnotations;
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* Render the network graph with the given configuration.
|
|
@@ -80,6 +83,8 @@ export var NetworkGraph = function NetworkGraph(options) {
|
|
|
80
83
|
|
|
81
84
|
// Clean up previous graph if exists
|
|
82
85
|
if (graph) {
|
|
86
|
+
var _cleanupAnnotations;
|
|
87
|
+
(_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
|
|
83
88
|
graph.destroy();
|
|
84
89
|
graph = null;
|
|
85
90
|
}
|
|
@@ -126,9 +131,17 @@ export var NetworkGraph = function NetworkGraph(options) {
|
|
|
126
131
|
});
|
|
127
132
|
|
|
128
133
|
// Build G6 edge data
|
|
129
|
-
var
|
|
134
|
+
var edgeIds = edges.map(function (_, index) {
|
|
135
|
+
var id = "gpt-vis-edge-".concat(index);
|
|
136
|
+
while (nodes.some(function (node) {
|
|
137
|
+
return node.name === id;
|
|
138
|
+
})) id = "_".concat(id);
|
|
139
|
+
return id;
|
|
140
|
+
});
|
|
141
|
+
var edgeData = edges.map(function (edge, index) {
|
|
130
142
|
var _edge$name, _edge$name2;
|
|
131
143
|
return {
|
|
144
|
+
id: edgeIds[index],
|
|
132
145
|
source: edge.source,
|
|
133
146
|
target: edge.target,
|
|
134
147
|
data: {
|
|
@@ -217,6 +230,17 @@ export var NetworkGraph = function NetworkGraph(options) {
|
|
|
217
230
|
behaviors: ['drag-canvas', 'drag-element', 'click-select'],
|
|
218
231
|
plugins: graphTitle.plugins
|
|
219
232
|
});
|
|
233
|
+
cleanupAnnotations = bindAnnotations({
|
|
234
|
+
renderer: 'g6',
|
|
235
|
+
graph: graph,
|
|
236
|
+
annotations: config.annotations,
|
|
237
|
+
data: {
|
|
238
|
+
nodes: nodes,
|
|
239
|
+
edges: edges
|
|
240
|
+
},
|
|
241
|
+
edgeIds: edgeIds,
|
|
242
|
+
defaults: getAnnotationDefaults('network-graph', theme, localStyle)
|
|
243
|
+
});
|
|
220
244
|
graph.render();
|
|
221
245
|
};
|
|
222
246
|
|
|
@@ -224,6 +248,9 @@ export var NetworkGraph = function NetworkGraph(options) {
|
|
|
224
248
|
* Destroy the graph instance and clean up resources.
|
|
225
249
|
*/
|
|
226
250
|
var destroy = function destroy() {
|
|
251
|
+
var _cleanupAnnotations2;
|
|
252
|
+
(_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
|
|
253
|
+
cleanupAnnotations = undefined;
|
|
227
254
|
if (graph) {
|
|
228
255
|
graph.destroy();
|
|
229
256
|
graph = null;
|
|
@@ -12,7 +12,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
13
|
import { Graph } from '@antv/g6';
|
|
14
14
|
import { getThemeObject } from "../../theme/g6";
|
|
15
|
-
import { getGraphTitle } from "../../util
|
|
15
|
+
import { getGraphTitle } from "../../util";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* OrganizationChartConfig defines the configuration for rendering the organization chart.
|
|
@@ -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.
|
|
@@ -5,11 +5,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { Chart } from '@antv/g2';
|
|
8
|
+
import { bindAnnotations } from "../../annotation";
|
|
8
9
|
import { getThemeObject } from "../../theme/g2";
|
|
9
|
-
import { getChartAnimation } from "../../util";
|
|
10
|
-
import { getColorLegend, getDataLabels } from "../../util/components";
|
|
11
|
-
import { getElementHoverScaleInteraction } from "../../util/interaction";
|
|
12
|
-
import { CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../../util/tokens";
|
|
10
|
+
import { CHART_STYLE_DEFAULTS, getChartAnimation, getChartVisualTokens, getColorLegend, getDataLabels, getElementHoverScaleInteraction } from "../../util";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* PieDataItem is the type for each data item in the pie chart.
|
|
@@ -54,6 +52,7 @@ export var Pie = function Pie(options) {
|
|
|
54
52
|
_options$theme = options.theme,
|
|
55
53
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
56
54
|
var chart = null;
|
|
55
|
+
var cleanupAnnotations;
|
|
57
56
|
var hasRendered = false;
|
|
58
57
|
|
|
59
58
|
// Precision multiplier for rounding percentages to 4 decimal places
|
|
@@ -75,6 +74,8 @@ export var Pie = function Pie(options) {
|
|
|
75
74
|
|
|
76
75
|
// Clean up previous chart if exists
|
|
77
76
|
if (chart) {
|
|
77
|
+
var _cleanupAnnotations;
|
|
78
|
+
(_cleanupAnnotations = cleanupAnnotations) === null || _cleanupAnnotations === void 0 || _cleanupAnnotations();
|
|
78
79
|
chart.destroy();
|
|
79
80
|
}
|
|
80
81
|
var sumValue = data.reduce(function (sum, item) {
|
|
@@ -132,6 +133,9 @@ export var Pie = function Pie(options) {
|
|
|
132
133
|
var formattedPercentage = Number(percentage.toFixed(1)).toString();
|
|
133
134
|
return "".concat(d.category, ": ").concat(formattedPercentage, "%");
|
|
134
135
|
},
|
|
136
|
+
style: {
|
|
137
|
+
annotationNativePercentage: true
|
|
138
|
+
},
|
|
135
139
|
position: 'outside',
|
|
136
140
|
contrast: 'outside',
|
|
137
141
|
transform: [{
|
|
@@ -164,21 +168,31 @@ export var Pie = function Pie(options) {
|
|
|
164
168
|
},
|
|
165
169
|
state: {
|
|
166
170
|
active: {
|
|
167
|
-
fillOpacity: 1
|
|
168
|
-
lineWidth: 3
|
|
171
|
+
fillOpacity: 1
|
|
169
172
|
},
|
|
170
173
|
inactive: {
|
|
171
174
|
fillOpacity: 0.3
|
|
172
175
|
},
|
|
173
176
|
selected: {
|
|
174
|
-
fillOpacity: 1
|
|
175
|
-
lineWidth: 3
|
|
177
|
+
fillOpacity: 1
|
|
176
178
|
}
|
|
177
179
|
},
|
|
178
180
|
style: intervalMark,
|
|
179
181
|
theme: rendererTheme
|
|
180
182
|
};
|
|
181
183
|
chart.options(chartOptions);
|
|
184
|
+
cleanupAnnotations = bindAnnotations({
|
|
185
|
+
renderer: 'g2',
|
|
186
|
+
chartType: 'pie',
|
|
187
|
+
chart: chart,
|
|
188
|
+
annotations: config.annotations,
|
|
189
|
+
mapping: {
|
|
190
|
+
x: 'category',
|
|
191
|
+
y: 'value',
|
|
192
|
+
data: data
|
|
193
|
+
},
|
|
194
|
+
themeObject: appearance
|
|
195
|
+
});
|
|
182
196
|
chart.render();
|
|
183
197
|
hasRendered = true;
|
|
184
198
|
};
|
|
@@ -187,6 +201,9 @@ export var Pie = function Pie(options) {
|
|
|
187
201
|
* Destroy the chart instance and clean up resources.
|
|
188
202
|
*/
|
|
189
203
|
var destroy = function destroy() {
|
|
204
|
+
var _cleanupAnnotations2;
|
|
205
|
+
(_cleanupAnnotations2 = cleanupAnnotations) === null || _cleanupAnnotations2 === void 0 || _cleanupAnnotations2();
|
|
206
|
+
cleanupAnnotations = undefined;
|
|
190
207
|
if (chart) {
|
|
191
208
|
chart.destroy();
|
|
192
209
|
chart = null;
|
|
@@ -16,9 +16,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
import { Chart } from '@antv/g2';
|
|
18
18
|
import { getThemeObject } from "../../theme/g2";
|
|
19
|
-
import { getLineHighlightState, getSeriesHighlightByColorInteraction } from "../../util";
|
|
20
|
-
import { getColorLegend } from "../../util/components";
|
|
21
|
-
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
19
|
+
import { CHART_STYLE_DEFAULTS, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction } from "../../util";
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* RadarDataItem is the type for each data item in the radar chart.
|
|
@@ -56,6 +56,7 @@ export var Sankey = function Sankey(options) {
|
|
|
56
56
|
* Render the sankey chart with the given configuration.
|
|
57
57
|
*/
|
|
58
58
|
var render = function render(config) {
|
|
59
|
+
var _sankeyStyle$nodeFill, _sankeyStyle$linkFill;
|
|
59
60
|
var _config$data = config.data,
|
|
60
61
|
data = _config$data === void 0 ? [] : _config$data,
|
|
61
62
|
_config$nodeAlign = config.nodeAlign,
|
|
@@ -119,8 +120,21 @@ export var Sankey = function Sankey(options) {
|
|
|
119
120
|
style: _objectSpread({
|
|
120
121
|
labelSpacing: 2,
|
|
121
122
|
nodeLineWidth: 1,
|
|
122
|
-
|
|
123
|
+
nodeFillOpacity: 0.5,
|
|
124
|
+
linkFillOpacity: 0.5
|
|
123
125
|
}, sankeyStyle),
|
|
126
|
+
state: {
|
|
127
|
+
active: {
|
|
128
|
+
fillOpacity: 1
|
|
129
|
+
},
|
|
130
|
+
inactive: {
|
|
131
|
+
nodeFillOpacity: (_sankeyStyle$nodeFill = sankeyStyle.nodeFillOpacity) !== null && _sankeyStyle$nodeFill !== void 0 ? _sankeyStyle$nodeFill : 0.5,
|
|
132
|
+
linkFillOpacity: (_sankeyStyle$linkFill = sankeyStyle.linkFillOpacity) !== null && _sankeyStyle$linkFill !== void 0 ? _sankeyStyle$linkFill : 0.5
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
interaction: {
|
|
136
|
+
elementHighlight: true
|
|
137
|
+
},
|
|
124
138
|
theme: rendererTheme,
|
|
125
139
|
legend: false,
|
|
126
140
|
tooltip: false
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RendererAnnotation } from '../../annotation/registry';
|
|
1
2
|
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
3
|
/**
|
|
3
4
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
@@ -7,24 +8,29 @@ export type ScatterDataItem = {
|
|
|
7
8
|
y: number;
|
|
8
9
|
group?: string;
|
|
9
10
|
};
|
|
11
|
+
/** Accept business fields without requiring caller interfaces to have an index signature. */
|
|
12
|
+
type ScatterRow = ScatterDataItem | (ScatterDataItem & Record<string, unknown>);
|
|
13
|
+
/** Distribute row alternatives so custom selector and weight fields remain available. */
|
|
14
|
+
type ScatterAnnotation<T extends ScatterDataItem> = T extends ScatterDataItem ? RendererAnnotation<T, 'g2', 'scatter'> : never;
|
|
10
15
|
/**
|
|
11
16
|
* ScatterConfig defines the configuration for rendering the scatter chart.
|
|
12
17
|
*/
|
|
13
|
-
export interface ScatterConfig {
|
|
18
|
+
export interface ScatterConfig<T extends ScatterDataItem = ScatterRow> {
|
|
14
19
|
type?: 'scatter';
|
|
15
|
-
data:
|
|
20
|
+
data: T[];
|
|
16
21
|
title?: string;
|
|
17
22
|
subtitle?: string;
|
|
18
23
|
axisXTitle?: string;
|
|
19
24
|
axisYTitle?: string;
|
|
20
25
|
theme?: VisualizationTheme;
|
|
21
26
|
style?: ThemeStyle;
|
|
27
|
+
annotations?: ScatterAnnotation<T>[];
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* ScatterInstance represents a scatter chart instance with render and destroy methods.
|
|
25
31
|
*/
|
|
26
32
|
export interface ScatterInstance {
|
|
27
|
-
render: (config: ScatterConfig) => void;
|
|
33
|
+
render: <T extends ScatterDataItem>(config: ScatterConfig<T>) => void;
|
|
28
34
|
destroy: () => void;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
@@ -52,3 +58,4 @@ export interface ScatterInstance {
|
|
|
52
58
|
* ```
|
|
53
59
|
*/
|
|
54
60
|
export declare const Scatter: (options: VisualizationOptions) => ScatterInstance;
|
|
61
|
+
export {};
|