@antv/gpt-vis 1.0.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -36
- package/README.zh-CN.md +113 -36
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +58 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +107 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +7 -2
- package/dist/cjs/util/crosshair-axis-labels.js +144 -30
- package/dist/cjs/util/html.d.ts +1 -0
- package/dist/cjs/util/html.js +29 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +13 -10
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +87 -51
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -6
- package/dist/cjs/vis/funnel/index.js +77 -58
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +56 -8
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +27 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +107 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +7 -2
- package/dist/esm/util/crosshair-axis-labels.js +156 -35
- package/dist/esm/util/html.d.ts +1 -0
- package/dist/esm/util/html.js +3 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +13 -10
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +97 -57
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -6
- package/dist/esm/vis/funnel/index.js +78 -68
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +48 -11
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
5
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
6
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
7
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19,7 +22,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
19
22
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
23
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
24
|
import { ExtensionCategory, Graph, HoverActivate, idOf, register } from '@antv/g6';
|
|
22
|
-
import {
|
|
25
|
+
import { getThemeObject } from "../../theme/g6";
|
|
26
|
+
import { getGraphTitle } from "../../util/components";
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* FlowDiagramConfig defines the configuration for rendering the flow diagram.
|
|
@@ -119,17 +123,23 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
119
123
|
var render = function render(config) {
|
|
120
124
|
var data = config.data,
|
|
121
125
|
title = config.title,
|
|
126
|
+
subtitle = config.subtitle,
|
|
122
127
|
_config$theme = config.theme,
|
|
123
128
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
124
129
|
_config$style = config.style,
|
|
125
|
-
|
|
130
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
126
131
|
if (graph) {
|
|
127
132
|
graph.destroy();
|
|
128
133
|
graph = null;
|
|
129
134
|
}
|
|
130
135
|
ensureBehaviorRegistered();
|
|
131
|
-
var
|
|
132
|
-
var
|
|
136
|
+
var appearance = getThemeObject('flow-diagram', theme, localStyle);
|
|
137
|
+
var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
|
|
138
|
+
var rendererTheme = appearance.theme;
|
|
139
|
+
var baseTheme = appearance.baseTheme;
|
|
140
|
+
var colors = appearance.colors;
|
|
141
|
+
var backgroundColor = appearance.backgroundColor;
|
|
142
|
+
var edgeTheme = appearance.edge.style;
|
|
133
143
|
|
|
134
144
|
// Resolve container element
|
|
135
145
|
var containerEl;
|
|
@@ -227,7 +237,7 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
227
237
|
}
|
|
228
238
|
};
|
|
229
239
|
});
|
|
230
|
-
var isDark =
|
|
240
|
+
var isDark = baseTheme === 'dark';
|
|
231
241
|
var edgeStroke = isDark ? '#5a6b7f' : '#8b9baf';
|
|
232
242
|
var labelFill = isDark ? '#aab4c0' : '#8b9baf';
|
|
233
243
|
var labelBgFill = isDark ? '#1a1a2e' : '#f8f8f8';
|
|
@@ -238,21 +248,15 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
238
248
|
container: containerEl,
|
|
239
249
|
width: width,
|
|
240
250
|
height: height,
|
|
241
|
-
theme:
|
|
251
|
+
theme: rendererTheme,
|
|
242
252
|
data: {
|
|
243
253
|
nodes: g6Nodes,
|
|
244
254
|
edges: g6Edges
|
|
245
255
|
},
|
|
246
256
|
autoFit: 'view',
|
|
247
257
|
autoResize: true,
|
|
248
|
-
padding:
|
|
249
|
-
plugins:
|
|
250
|
-
key: 'title',
|
|
251
|
-
type: 'title',
|
|
252
|
-
title: title,
|
|
253
|
-
titleFill: isDark ? '#e0e6ed' : '#000',
|
|
254
|
-
titleFontFamily: 'sans-serif'
|
|
255
|
-
}] : [],
|
|
258
|
+
padding: graphTitle.padding,
|
|
259
|
+
plugins: graphTitle.plugins,
|
|
256
260
|
node: {
|
|
257
261
|
type: 'html',
|
|
258
262
|
style: function style(d) {
|
|
@@ -264,7 +268,7 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
264
268
|
size: size,
|
|
265
269
|
dx: -DEFAULT_NODE_WIDTH / 2,
|
|
266
270
|
dy: -height / 2,
|
|
267
|
-
innerHTML: createNodeHTML(d, color, selectedBorder,
|
|
271
|
+
innerHTML: createNodeHTML(d, color, selectedBorder, baseTheme),
|
|
268
272
|
ports: [{
|
|
269
273
|
placement: 'top'
|
|
270
274
|
}, {
|
|
@@ -283,15 +287,11 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
283
287
|
},
|
|
284
288
|
edge: {
|
|
285
289
|
type: 'polyline',
|
|
286
|
-
style: {
|
|
290
|
+
style: _objectSpread(_objectSpread({
|
|
287
291
|
lineWidth: 3,
|
|
288
292
|
radius: 20,
|
|
289
293
|
stroke: edgeStroke,
|
|
290
294
|
endArrow: true,
|
|
291
|
-
labelText: function labelText(d) {
|
|
292
|
-
var _d$data2;
|
|
293
|
-
return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
|
|
294
|
-
},
|
|
295
295
|
labelFill: labelFill,
|
|
296
296
|
labelFontWeight: 600,
|
|
297
297
|
labelBackground: true,
|
|
@@ -300,12 +300,17 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
300
300
|
labelBackgroundLineWidth: 3,
|
|
301
301
|
labelBackgroundStroke: labelBgStroke,
|
|
302
302
|
labelPadding: [1, 10],
|
|
303
|
-
labelBackgroundRadius: 4
|
|
303
|
+
labelBackgroundRadius: 4
|
|
304
|
+
}, edgeTheme), {}, {
|
|
305
|
+
labelText: function labelText(d) {
|
|
306
|
+
var _d$data2;
|
|
307
|
+
return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
|
|
308
|
+
},
|
|
304
309
|
router: {
|
|
305
310
|
type: 'orth',
|
|
306
311
|
padding: 40
|
|
307
312
|
}
|
|
308
|
-
},
|
|
313
|
+
}),
|
|
309
314
|
state: {
|
|
310
315
|
active: {
|
|
311
316
|
stroke: ACTIVE_COLOR,
|
|
@@ -324,7 +329,7 @@ export var FlowDiagram = function FlowDiagram(options) {
|
|
|
324
329
|
// Measure real node heights after initial render
|
|
325
330
|
graph.once('afterrender', function () {
|
|
326
331
|
if (graph) {
|
|
327
|
-
measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder,
|
|
332
|
+
measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder, baseTheme);
|
|
328
333
|
}
|
|
329
334
|
});
|
|
330
335
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* FunnelDataItem is the type for each data item in the funnel chart.
|
|
4
4
|
*/
|
|
@@ -14,12 +14,9 @@ export interface FunnelConfig {
|
|
|
14
14
|
data: FunnelDataItem[];
|
|
15
15
|
theme?: VisualizationTheme;
|
|
16
16
|
title?: string;
|
|
17
|
-
|
|
17
|
+
subtitle?: string;
|
|
18
18
|
conversionRateLabel?: string;
|
|
19
|
-
style?:
|
|
20
|
-
backgroundColor?: string;
|
|
21
|
-
palette?: string[];
|
|
22
|
-
};
|
|
19
|
+
style?: ThemeStyle;
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* FunnelInstance represents a funnel chart instance with render and destroy methods.
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
7
|
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; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
|
-
import {
|
|
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
18
|
|
|
16
19
|
/**
|
|
17
20
|
* FunnelDataItem is the type for each data item in the funnel chart.
|
|
@@ -89,17 +92,17 @@ export var Funnel = function Funnel(options) {
|
|
|
89
92
|
* Render the funnel chart with the given configuration.
|
|
90
93
|
*/
|
|
91
94
|
var render = function render(config) {
|
|
95
|
+
var _getDataLabels;
|
|
92
96
|
var _config$data = config.data,
|
|
93
97
|
data = _config$data === void 0 ? [] : _config$data,
|
|
94
98
|
_config$theme = config.theme,
|
|
95
99
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
96
100
|
title = config.title,
|
|
97
|
-
|
|
98
|
-
renderLocale = _config$locale === void 0 ? locale : _config$locale,
|
|
101
|
+
subtitle = config.subtitle,
|
|
99
102
|
conversionRateLabel = config.conversionRateLabel,
|
|
100
103
|
_config$style = config.style,
|
|
101
|
-
|
|
102
|
-
var chartLocale = resolveChartLocale(
|
|
104
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
105
|
+
var chartLocale = resolveChartLocale(locale);
|
|
103
106
|
var labels = FUNNEL_LABELS[chartLocale];
|
|
104
107
|
var numberFormatter = new Intl.NumberFormat(chartLocale);
|
|
105
108
|
var stageConversionRateLabel = conversionRateLabel !== null && conversionRateLabel !== void 0 ? conversionRateLabel : labels.conversionRate;
|
|
@@ -111,12 +114,30 @@ export var Funnel = function Funnel(options) {
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
// Get colors from style.palette or theme defaults
|
|
114
|
-
var
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
+
var appearance = getThemeObject('funnel', theme, localStyle);
|
|
118
|
+
var rendererTheme = appearance.theme;
|
|
119
|
+
var intervalMark = _objectSpread(_objectSpread({
|
|
120
|
+
shape: 'funnel',
|
|
121
|
+
fillOpacity: 0.94,
|
|
122
|
+
stroke: getChartVisualTokens(rendererTheme.type).separator,
|
|
123
|
+
lineWidth: 2
|
|
124
|
+
}, rendererTheme.type === 'academy' ? {} : {
|
|
125
|
+
radius: 4
|
|
126
|
+
}), appearance.mark.interval);
|
|
127
|
+
var connectorStyle = _objectSpread({
|
|
128
|
+
stroke: getChartVisualTokens(rendererTheme.type).axisLine,
|
|
129
|
+
strokeOpacity: rendererTheme.type === 'academy' ? 1 : 0.82,
|
|
130
|
+
lineWidth: rendererTheme.type === 'academy' ? 1 : 0.75,
|
|
131
|
+
endMarker: false,
|
|
132
|
+
connectLength1: -12
|
|
133
|
+
}, appearance.mark.connector);
|
|
134
|
+
var colors = rendererTheme.category10;
|
|
135
|
+
var tokens = getChartVisualTokens(rendererTheme.type);
|
|
136
|
+
var connectorMark = connectorStyle;
|
|
117
137
|
var formatValue = function formatValue(value) {
|
|
118
138
|
return Number.isFinite(value) ? numberFormatter.format(value) : '—';
|
|
119
139
|
};
|
|
140
|
+
var isInverted = data.length > 1 && data[0].value < data[data.length - 1].value;
|
|
120
141
|
var metricsByCategory = new Map(data.map(function (item, index) {
|
|
121
142
|
var previous = data[index - 1];
|
|
122
143
|
return [item.category, {
|
|
@@ -145,6 +166,23 @@ export var Funnel = function Funnel(options) {
|
|
|
145
166
|
};
|
|
146
167
|
}]
|
|
147
168
|
};
|
|
169
|
+
var primaryLabels = (_getDataLabels = getDataLabels(rendererTheme, {
|
|
170
|
+
style: {
|
|
171
|
+
fontFamily: CHART_FONT_FAMILY,
|
|
172
|
+
fontSize: 12,
|
|
173
|
+
fontWeight: 500,
|
|
174
|
+
lineHeight: 17
|
|
175
|
+
},
|
|
176
|
+
defaultVisible: true,
|
|
177
|
+
text: function text(d) {
|
|
178
|
+
return "".concat(d.category, "\n").concat(formatValue(d.value));
|
|
179
|
+
},
|
|
180
|
+
position: 'inside',
|
|
181
|
+
contrast: 'inside',
|
|
182
|
+
transform: [{
|
|
183
|
+
type: 'overflowStroke'
|
|
184
|
+
}]
|
|
185
|
+
})) !== null && _getDataLabels !== void 0 ? _getDataLabels : [];
|
|
148
186
|
|
|
149
187
|
// Create chart
|
|
150
188
|
chart = new Chart({
|
|
@@ -163,15 +201,17 @@ export var Funnel = function Funnel(options) {
|
|
|
163
201
|
animate: false,
|
|
164
202
|
type: 'view',
|
|
165
203
|
data: data,
|
|
166
|
-
title: title
|
|
204
|
+
title: title ? {
|
|
205
|
+
title: title,
|
|
206
|
+
subtitle: subtitle
|
|
207
|
+
} : '',
|
|
167
208
|
children: [{
|
|
168
209
|
type: 'interval',
|
|
169
210
|
data: data,
|
|
170
211
|
encode: {
|
|
171
212
|
x: 'category',
|
|
172
213
|
y: 'value',
|
|
173
|
-
color: 'category'
|
|
174
|
-
shape: 'funnel' // Use funnel shape for proper funnel visualization
|
|
214
|
+
color: 'category'
|
|
175
215
|
},
|
|
176
216
|
transform: [{
|
|
177
217
|
type: 'symmetryY'
|
|
@@ -191,31 +231,15 @@ export var Funnel = function Funnel(options) {
|
|
|
191
231
|
},
|
|
192
232
|
legend: false,
|
|
193
233
|
tooltip: funnelTooltip,
|
|
194
|
-
labels: [{
|
|
195
|
-
text: function text(
|
|
196
|
-
return
|
|
197
|
-
},
|
|
198
|
-
position: 'inside',
|
|
199
|
-
transform: [{
|
|
200
|
-
type: 'contrastReverse'
|
|
201
|
-
}, {
|
|
202
|
-
type: 'overflowStroke'
|
|
203
|
-
}],
|
|
204
|
-
style: {
|
|
205
|
-
fontFamily: CHART_FONT_FAMILY,
|
|
206
|
-
fontSize: 12,
|
|
207
|
-
fontWeight: 500,
|
|
208
|
-
lineHeight: 17
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
text: function text(_d, index) {
|
|
212
|
-
return index === 0 ? '' : '———';
|
|
234
|
+
labels: [].concat(_toConsumableArray(primaryLabels), [{
|
|
235
|
+
text: function text(_d, index, items) {
|
|
236
|
+
return (isInverted ? index < items.length - 1 : index > 0) ? '———' : '';
|
|
213
237
|
},
|
|
214
|
-
position: 'top-right',
|
|
238
|
+
position: isInverted ? 'bottom-right' : 'top-right',
|
|
215
239
|
fill: tokens.textSecondary,
|
|
216
240
|
fillOpacity: 0.72,
|
|
217
|
-
dx:
|
|
218
|
-
dy: -6,
|
|
241
|
+
dx: 8,
|
|
242
|
+
dy: isInverted ? 6 : -6,
|
|
219
243
|
style: {
|
|
220
244
|
fontFamily: CHART_FONT_FAMILY,
|
|
221
245
|
fontSize: 8,
|
|
@@ -224,43 +248,36 @@ export var Funnel = function Funnel(options) {
|
|
|
224
248
|
}
|
|
225
249
|
}, {
|
|
226
250
|
text: function text(_d, index, items) {
|
|
227
|
-
|
|
251
|
+
var from = isInverted ? items[index] : items[index - 1];
|
|
252
|
+
var to = isInverted ? items[index + 1] : items[index];
|
|
253
|
+
return from && to ? formatMetricLabel(stageConversionRateLabel, formatConversionRate(from.value, to.value), chartLocale) : '';
|
|
228
254
|
},
|
|
229
|
-
position: 'top-right',
|
|
255
|
+
position: isInverted ? 'bottom-right' : 'top-right',
|
|
230
256
|
textAlign: 'left',
|
|
231
257
|
textBaseline: 'middle',
|
|
232
258
|
fill: tokens.textPrimary,
|
|
233
|
-
dx:
|
|
259
|
+
dx: 26,
|
|
234
260
|
style: {
|
|
235
261
|
fontFamily: CHART_FONT_FAMILY,
|
|
236
262
|
fontSize: 11,
|
|
237
263
|
fontWeight: 500
|
|
238
264
|
}
|
|
239
|
-
}],
|
|
240
|
-
style:
|
|
241
|
-
fillOpacity: 0.94,
|
|
242
|
-
stroke: tokens.separator,
|
|
243
|
-
lineWidth: 2
|
|
244
|
-
}, theme === 'academy' ? {} : {
|
|
245
|
-
radius: 4
|
|
246
|
-
}),
|
|
265
|
+
}]),
|
|
266
|
+
style: intervalMark,
|
|
247
267
|
state: {
|
|
248
268
|
active: {
|
|
249
269
|
fillOpacity: 1,
|
|
250
270
|
stroke: tokens.separator,
|
|
251
271
|
lineWidth: 3
|
|
252
272
|
}
|
|
253
|
-
}
|
|
254
|
-
viewStyle: style.backgroundColor ? {
|
|
255
|
-
viewFill: backgroundColor
|
|
256
|
-
} : undefined
|
|
273
|
+
}
|
|
257
274
|
}].concat(_toConsumableArray(data.length > 1 ? [{
|
|
258
275
|
type: 'connector',
|
|
259
276
|
data: [{
|
|
260
|
-
startX: data[0].category,
|
|
261
|
-
startY: data[data.length - 1].category,
|
|
277
|
+
startX: isInverted ? data[data.length - 1].category : data[0].category,
|
|
278
|
+
startY: isInverted ? data[0].category : data[data.length - 1].category,
|
|
262
279
|
endX: 0,
|
|
263
|
-
endY: (data[0].value - data[data.length - 1].value) / 2
|
|
280
|
+
endY: Math.abs(data[0].value - data[data.length - 1].value) / 2
|
|
264
281
|
}],
|
|
265
282
|
encode: {
|
|
266
283
|
x: 'startX',
|
|
@@ -269,13 +286,7 @@ export var Funnel = function Funnel(options) {
|
|
|
269
286
|
y1: 'endY'
|
|
270
287
|
},
|
|
271
288
|
tooltip: false,
|
|
272
|
-
style:
|
|
273
|
-
stroke: tokens.axisLine,
|
|
274
|
-
strokeOpacity: theme === 'academy' ? 1 : 0.82,
|
|
275
|
-
lineWidth: theme === 'academy' ? 1 : 0.75,
|
|
276
|
-
markerEnd: false,
|
|
277
|
-
connectLength1: -12
|
|
278
|
-
},
|
|
289
|
+
style: connectorMark,
|
|
279
290
|
labels: [{
|
|
280
291
|
text: formatMetricLabel(overallConversionRateLabel, formatConversionRate(data[0].value, data[data.length - 1].value), chartLocale),
|
|
281
292
|
position: 'left',
|
|
@@ -293,12 +304,11 @@ export var Funnel = function Funnel(options) {
|
|
|
293
304
|
axis: false,
|
|
294
305
|
interaction: {
|
|
295
306
|
tooltip: true,
|
|
296
|
-
elementHighlight:
|
|
307
|
+
elementHighlight: {
|
|
308
|
+
delay: CHART_STYLE_DEFAULTS.interactionDelay
|
|
309
|
+
}
|
|
297
310
|
},
|
|
298
|
-
|
|
299
|
-
viewFill: backgroundColor
|
|
300
|
-
} : undefined,
|
|
301
|
-
theme: getThemeObject(theme)
|
|
311
|
+
theme: rendererTheme
|
|
302
312
|
};
|
|
303
313
|
chart.options(chartOptions);
|
|
304
314
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* HistogramConfig defines the configuration for rendering the histogram chart.
|
|
4
4
|
*/
|
|
@@ -7,13 +7,11 @@ export interface HistogramConfig {
|
|
|
7
7
|
data: number[];
|
|
8
8
|
binNumber?: number;
|
|
9
9
|
title?: string;
|
|
10
|
+
subtitle?: string;
|
|
10
11
|
axisXTitle?: string;
|
|
11
12
|
axisYTitle?: string;
|
|
12
|
-
theme?:
|
|
13
|
-
style?:
|
|
14
|
-
backgroundColor?: string;
|
|
15
|
-
palette?: string[];
|
|
16
|
-
};
|
|
13
|
+
theme?: VisualizationTheme;
|
|
14
|
+
style?: ThemeStyle;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* HistogramInstance represents a histogram chart instance with render and destroy methods.
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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); }
|
|
1
7
|
import { Chart } from '@antv/g2';
|
|
2
|
-
import { getThemeObject
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { getCartesianAxis } from "../../util/components";
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* HistogramConfig defines the configuration for rendering the histogram chart.
|
|
@@ -48,11 +55,12 @@ export var Histogram = function Histogram(options) {
|
|
|
48
55
|
_config$theme = config.theme,
|
|
49
56
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
50
57
|
title = config.title,
|
|
58
|
+
subtitle = config.subtitle,
|
|
51
59
|
axisXTitle = config.axisXTitle,
|
|
52
60
|
axisYTitle = config.axisYTitle,
|
|
53
61
|
binNumber = config.binNumber,
|
|
54
62
|
_config$style = config.style,
|
|
55
|
-
|
|
63
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
56
64
|
|
|
57
65
|
// Clean up previous chart if exists
|
|
58
66
|
if (chart) {
|
|
@@ -60,7 +68,14 @@ export var Histogram = function Histogram(options) {
|
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
// Get colors from style.palette or theme defaults
|
|
63
|
-
var
|
|
71
|
+
var appearance = getThemeObject('histogram', theme, localStyle);
|
|
72
|
+
var rendererTheme = appearance.theme;
|
|
73
|
+
var intervalMark = _objectSpread({
|
|
74
|
+
minHeight: 1,
|
|
75
|
+
columnWidthRatio: 1,
|
|
76
|
+
inset: 0.5
|
|
77
|
+
}, appearance.mark.interval);
|
|
78
|
+
var colors = rendererTheme.category10;
|
|
64
79
|
|
|
65
80
|
// Create chart
|
|
66
81
|
chart = new Chart({
|
|
@@ -77,7 +92,10 @@ export var Histogram = function Histogram(options) {
|
|
|
77
92
|
animate: false,
|
|
78
93
|
type: 'interval',
|
|
79
94
|
data: data,
|
|
80
|
-
title: title
|
|
95
|
+
title: title ? {
|
|
96
|
+
title: title,
|
|
97
|
+
subtitle: subtitle
|
|
98
|
+
} : '',
|
|
81
99
|
encode: {
|
|
82
100
|
x: function x(d) {
|
|
83
101
|
return d;
|
|
@@ -93,19 +111,11 @@ export var Histogram = function Histogram(options) {
|
|
|
93
111
|
y: 'count',
|
|
94
112
|
thresholds: binNumber
|
|
95
113
|
}],
|
|
96
|
-
style:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
axis: {
|
|
102
|
-
x: {
|
|
103
|
-
title: axisXTitle
|
|
104
|
-
},
|
|
105
|
-
y: {
|
|
106
|
-
title: axisYTitle
|
|
107
|
-
}
|
|
108
|
-
},
|
|
114
|
+
style: intervalMark,
|
|
115
|
+
axis: getCartesianAxis({
|
|
116
|
+
axisXTitle: axisXTitle,
|
|
117
|
+
axisYTitle: axisYTitle
|
|
118
|
+
}),
|
|
109
119
|
scale: {
|
|
110
120
|
y: {
|
|
111
121
|
nice: true
|
|
@@ -121,10 +131,7 @@ export var Histogram = function Histogram(options) {
|
|
|
121
131
|
name: '频数'
|
|
122
132
|
}]
|
|
123
133
|
},
|
|
124
|
-
|
|
125
|
-
viewFill: style.backgroundColor
|
|
126
|
-
} : undefined,
|
|
127
|
-
theme: getThemeObject(theme)
|
|
134
|
+
theme: rendererTheme
|
|
128
135
|
};
|
|
129
136
|
chart.options(chartOptions);
|
|
130
137
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Indented tree node data — only name + optional children, no description.
|
|
4
4
|
* Aligns with the official G6 indented tree example data structure.
|
|
@@ -13,14 +13,12 @@ export interface IndentedTreeData {
|
|
|
13
13
|
export interface IndentedTreeConfig {
|
|
14
14
|
type?: 'indented-tree';
|
|
15
15
|
data: IndentedTreeData;
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
/** Layout direction: 'LR' = root left (default), 'RL' = root right, 'H' = root center */
|
|
19
20
|
direction?: 'LR' | 'RL' | 'H';
|
|
20
|
-
style?:
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
23
|
-
};
|
|
21
|
+
style?: ThemeStyle;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* IndentedTreeInstance represents a chart instance with render and destroy methods.
|