@antv/gpt-vis 1.0.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -6
- package/README.zh-CN.md +32 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +58 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +107 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/cjs/util/crosshair-axis-labels.js +17 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +9 -6
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +70 -52
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -5
- package/dist/cjs/vis/funnel/index.js +63 -42
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +44 -4
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +27 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +107 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/esm/util/crosshair-axis-labels.js +18 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +9 -6
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +68 -58
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -5
- package/dist/esm/vis/funnel/index.js +63 -54
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +41 -4
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -1,5 +1,11 @@
|
|
|
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
2
|
var _excluded = ["children"];
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3
9
|
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; }
|
|
4
10
|
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; }
|
|
5
11
|
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; }
|
|
@@ -8,7 +14,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
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; }
|
|
10
16
|
import { Graph, treeToGraphData } from '@antv/g6';
|
|
11
|
-
import {
|
|
17
|
+
import { getThemeObject } from "../../theme/g6";
|
|
18
|
+
import { getGraphTitle } from "../../util/components";
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
|
|
@@ -19,19 +26,26 @@ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme
|
|
|
19
26
|
*/
|
|
20
27
|
|
|
21
28
|
var FONT_FAMILY = 'system-ui, sans-serif';
|
|
22
|
-
function getNodeSize(
|
|
23
|
-
|
|
29
|
+
function getNodeSize(text, depth, style) {
|
|
30
|
+
var _style$labelFontSize;
|
|
31
|
+
var defaultFontSize = depth === 0 ? 24 : depth === 1 ? 18 : 16;
|
|
32
|
+
var fontSize = (_style$labelFontSize = style.labelFontSize) !== null && _style$labelFontSize !== void 0 ? _style$labelFontSize : defaultFontSize;
|
|
33
|
+
var scale = fontSize / defaultFontSize;
|
|
34
|
+
if (depth >= 2) return [2, Math.ceil(30 * scale)];
|
|
35
|
+
var textWidth = measureText(text, fontSize, style.labelFontWeight, style.labelFontFamily);
|
|
36
|
+
return [Math.ceil(textWidth + (depth === 0 ? 80 : 50) * scale), Math.ceil((depth === 0 ? 70 : 42) * scale)];
|
|
24
37
|
}
|
|
25
38
|
var measureText = function () {
|
|
26
39
|
var canvas = null;
|
|
27
40
|
return function (text) {
|
|
28
41
|
var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
29
42
|
var fontWeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'normal';
|
|
43
|
+
var fontFamily = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : FONT_FAMILY;
|
|
30
44
|
if (typeof document === 'undefined') return text.length * fontSize * 0.6;
|
|
31
45
|
if (!canvas) canvas = document.createElement('canvas');
|
|
32
46
|
var ctx = canvas.getContext('2d');
|
|
33
|
-
if (!ctx) return 0;
|
|
34
|
-
ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(
|
|
47
|
+
if (!ctx) return text.length * fontSize * 0.6;
|
|
48
|
+
ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily);
|
|
35
49
|
return ctx.measureText(text).width;
|
|
36
50
|
};
|
|
37
51
|
}();
|
|
@@ -95,8 +109,9 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
95
109
|
_config$theme = config.theme,
|
|
96
110
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
97
111
|
title = config.title,
|
|
112
|
+
subtitle = config.subtitle,
|
|
98
113
|
_config$style = config.style,
|
|
99
|
-
|
|
114
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
100
115
|
if (!(data !== null && data !== void 0 && data.name)) {
|
|
101
116
|
throw new Error('FishboneDiagram: data with a name field is required');
|
|
102
117
|
}
|
|
@@ -109,13 +124,26 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
109
124
|
containerEl.innerHTML = '';
|
|
110
125
|
|
|
111
126
|
// Theme-derived colors, allowing style.palette to override the theme default
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
127
|
+
var appearance = getThemeObject('fishbone-diagram', theme, localStyle);
|
|
128
|
+
var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
|
|
129
|
+
var rendererTheme = appearance.theme;
|
|
130
|
+
var baseTheme = appearance.baseTheme;
|
|
131
|
+
var isDark = baseTheme === 'dark';
|
|
132
|
+
var backgroundColor = appearance.backgroundColor;
|
|
133
|
+
var palette = appearance.colors;
|
|
115
134
|
var rootFill = isDark ? '#2a2a2a' : '#EFF0F0';
|
|
116
135
|
var rootLabelFill = isDark ? '#e0e0e0' : '#262626';
|
|
117
136
|
var leafLabelFill = isDark ? '#c0c0c0' : '#262626';
|
|
118
137
|
var edgeStroke = isDark ? '#555' : '#99ADD1';
|
|
138
|
+
var nodeTheme = appearance.node.style;
|
|
139
|
+
// Deep nodes only anchor the layout; their labels consume the theme,
|
|
140
|
+
// while box paint (including outlines and shadows) belongs to depths 0–1.
|
|
141
|
+
var leafTheme = Object.fromEntries(Object.entries(nodeTheme).filter(function (_ref) {
|
|
142
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
143
|
+
key = _ref2[0];
|
|
144
|
+
return key.startsWith('label');
|
|
145
|
+
}));
|
|
146
|
+
var edgeTheme = appearance.edge.style;
|
|
119
147
|
containerEl.style.backgroundColor = backgroundColor;
|
|
120
148
|
var graphData = convertData(data);
|
|
121
149
|
assignBranchColors(graphData, palette);
|
|
@@ -126,15 +154,9 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
126
154
|
height: height,
|
|
127
155
|
autoFit: 'view',
|
|
128
156
|
autoResize: true,
|
|
129
|
-
padding:
|
|
130
|
-
theme:
|
|
131
|
-
plugins:
|
|
132
|
-
key: 'title',
|
|
133
|
-
type: 'title',
|
|
134
|
-
title: title,
|
|
135
|
-
titleFill: isDark ? '#e0e6ed' : '#000',
|
|
136
|
-
titleFontFamily: 'sans-serif'
|
|
137
|
-
}] : [],
|
|
157
|
+
padding: graphTitle.padding,
|
|
158
|
+
theme: rendererTheme,
|
|
159
|
+
plugins: graphTitle.plugins,
|
|
138
160
|
data: graphData,
|
|
139
161
|
node: {
|
|
140
162
|
type: 'rect',
|
|
@@ -142,19 +164,21 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
142
164
|
var _d$depth;
|
|
143
165
|
var depth = (_d$depth = d.depth) !== null && _d$depth !== void 0 ? _d$depth : 0;
|
|
144
166
|
var nodeStyle = {
|
|
145
|
-
radius:
|
|
146
|
-
size: getNodeSize(String(d.id), depth),
|
|
167
|
+
radius: baseTheme === 'academy' ? 0 : 8,
|
|
147
168
|
labelText: String(d.id),
|
|
148
169
|
labelPlacement: 'left',
|
|
149
170
|
labelFontFamily: FONT_FAMILY
|
|
150
171
|
};
|
|
172
|
+
if (appearance.texture === 'rough') {
|
|
173
|
+
nodeStyle.lineWidth = 0.5;
|
|
174
|
+
}
|
|
151
175
|
if (depth === 0) {
|
|
152
176
|
Object.assign(nodeStyle, {
|
|
153
177
|
fill: rootFill,
|
|
154
178
|
labelFill: rootLabelFill,
|
|
155
179
|
labelFontWeight: 'bold',
|
|
156
180
|
labelFontSize: 24,
|
|
157
|
-
labelOffsetY:
|
|
181
|
+
labelOffsetY: 0,
|
|
158
182
|
labelPlacement: 'center'
|
|
159
183
|
});
|
|
160
184
|
} else if (depth === 1) {
|
|
@@ -169,24 +193,25 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
169
193
|
} else {
|
|
170
194
|
Object.assign(nodeStyle, {
|
|
171
195
|
fill: 'transparent',
|
|
196
|
+
stroke: 'transparent',
|
|
197
|
+
lineWidth: 0,
|
|
172
198
|
labelFill: leafLabelFill,
|
|
173
199
|
labelFontSize: 16
|
|
174
200
|
});
|
|
175
201
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
202
|
+
Object.assign(nodeStyle, depth < 2 ? nodeTheme : leafTheme);
|
|
203
|
+
nodeStyle.size = getNodeSize(String(d.id), depth, nodeStyle);
|
|
179
204
|
return nodeStyle;
|
|
180
205
|
}
|
|
181
206
|
},
|
|
182
207
|
edge: {
|
|
183
208
|
type: 'polyline',
|
|
184
|
-
style: _objectSpread({
|
|
209
|
+
style: _objectSpread(_objectSpread({
|
|
185
210
|
lineWidth: 3,
|
|
186
211
|
stroke: edgeStroke
|
|
187
|
-
},
|
|
212
|
+
}, appearance.texture === 'rough' ? {
|
|
188
213
|
labelFontFamily: 'Comic Sans MS'
|
|
189
|
-
} : {})
|
|
214
|
+
} : {}), edgeTheme)
|
|
190
215
|
},
|
|
191
216
|
layout: {
|
|
192
217
|
type: 'fishbone',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphData, VisualizationOptions } from '../../types';
|
|
1
|
+
import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* FlowDiagramConfig defines the configuration for rendering the flow diagram.
|
|
4
4
|
*/
|
|
@@ -6,11 +6,9 @@ export interface FlowDiagramConfig {
|
|
|
6
6
|
type?: 'flow-diagram';
|
|
7
7
|
data: GraphData;
|
|
8
8
|
title?: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
palette?: string[];
|
|
13
|
-
};
|
|
9
|
+
subtitle?: string;
|
|
10
|
+
theme?: VisualizationTheme;
|
|
11
|
+
style?: ThemeStyle;
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* FlowDiagramInstance represents a flow diagram instance with render and destroy methods.
|
|
@@ -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,11 +14,9 @@ export interface FunnelConfig {
|
|
|
14
14
|
data: FunnelDataItem[];
|
|
15
15
|
theme?: VisualizationTheme;
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
conversionRateLabel?: string;
|
|
18
|
-
style?:
|
|
19
|
-
backgroundColor?: string;
|
|
20
|
-
palette?: string[];
|
|
21
|
-
};
|
|
19
|
+
style?: ThemeStyle;
|
|
22
20
|
}
|
|
23
21
|
/**
|
|
24
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,14 +92,16 @@ 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,
|
|
101
|
+
subtitle = config.subtitle,
|
|
97
102
|
conversionRateLabel = config.conversionRateLabel,
|
|
98
103
|
_config$style = config.style,
|
|
99
|
-
|
|
104
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
100
105
|
var chartLocale = resolveChartLocale(locale);
|
|
101
106
|
var labels = FUNNEL_LABELS[chartLocale];
|
|
102
107
|
var numberFormatter = new Intl.NumberFormat(chartLocale);
|
|
@@ -109,9 +114,26 @@ export var Funnel = function Funnel(options) {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
// Get colors from style.palette or theme defaults
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
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;
|
|
115
137
|
var formatValue = function formatValue(value) {
|
|
116
138
|
return Number.isFinite(value) ? numberFormatter.format(value) : '—';
|
|
117
139
|
};
|
|
@@ -144,6 +166,23 @@ export var Funnel = function Funnel(options) {
|
|
|
144
166
|
};
|
|
145
167
|
}]
|
|
146
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 : [];
|
|
147
186
|
|
|
148
187
|
// Create chart
|
|
149
188
|
chart = new Chart({
|
|
@@ -162,15 +201,17 @@ export var Funnel = function Funnel(options) {
|
|
|
162
201
|
animate: false,
|
|
163
202
|
type: 'view',
|
|
164
203
|
data: data,
|
|
165
|
-
title: title
|
|
204
|
+
title: title ? {
|
|
205
|
+
title: title,
|
|
206
|
+
subtitle: subtitle
|
|
207
|
+
} : '',
|
|
166
208
|
children: [{
|
|
167
209
|
type: 'interval',
|
|
168
210
|
data: data,
|
|
169
211
|
encode: {
|
|
170
212
|
x: 'category',
|
|
171
213
|
y: 'value',
|
|
172
|
-
color: 'category'
|
|
173
|
-
shape: 'funnel' // Use funnel shape for proper funnel visualization
|
|
214
|
+
color: 'category'
|
|
174
215
|
},
|
|
175
216
|
transform: [{
|
|
176
217
|
type: 'symmetryY'
|
|
@@ -190,23 +231,7 @@ export var Funnel = function Funnel(options) {
|
|
|
190
231
|
},
|
|
191
232
|
legend: false,
|
|
192
233
|
tooltip: funnelTooltip,
|
|
193
|
-
labels: [{
|
|
194
|
-
text: function text(d) {
|
|
195
|
-
return "".concat(d.category, "\n").concat(formatValue(d.value));
|
|
196
|
-
},
|
|
197
|
-
position: 'inside',
|
|
198
|
-
transform: [{
|
|
199
|
-
type: 'contrastReverse'
|
|
200
|
-
}, {
|
|
201
|
-
type: 'overflowStroke'
|
|
202
|
-
}],
|
|
203
|
-
style: {
|
|
204
|
-
fontFamily: CHART_FONT_FAMILY,
|
|
205
|
-
fontSize: 12,
|
|
206
|
-
fontWeight: 500,
|
|
207
|
-
lineHeight: 17
|
|
208
|
-
}
|
|
209
|
-
}, {
|
|
234
|
+
labels: [].concat(_toConsumableArray(primaryLabels), [{
|
|
210
235
|
text: function text(_d, index, items) {
|
|
211
236
|
return (isInverted ? index < items.length - 1 : index > 0) ? '———' : '';
|
|
212
237
|
},
|
|
@@ -237,24 +262,15 @@ export var Funnel = function Funnel(options) {
|
|
|
237
262
|
fontSize: 11,
|
|
238
263
|
fontWeight: 500
|
|
239
264
|
}
|
|
240
|
-
}],
|
|
241
|
-
style:
|
|
242
|
-
fillOpacity: 0.94,
|
|
243
|
-
stroke: tokens.separator,
|
|
244
|
-
lineWidth: 2
|
|
245
|
-
}, theme === 'academy' ? {} : {
|
|
246
|
-
radius: 4
|
|
247
|
-
}),
|
|
265
|
+
}]),
|
|
266
|
+
style: intervalMark,
|
|
248
267
|
state: {
|
|
249
268
|
active: {
|
|
250
269
|
fillOpacity: 1,
|
|
251
270
|
stroke: tokens.separator,
|
|
252
271
|
lineWidth: 3
|
|
253
272
|
}
|
|
254
|
-
}
|
|
255
|
-
viewStyle: style.backgroundColor ? {
|
|
256
|
-
viewFill: backgroundColor
|
|
257
|
-
} : undefined
|
|
273
|
+
}
|
|
258
274
|
}].concat(_toConsumableArray(data.length > 1 ? [{
|
|
259
275
|
type: 'connector',
|
|
260
276
|
data: [{
|
|
@@ -270,13 +286,7 @@ export var Funnel = function Funnel(options) {
|
|
|
270
286
|
y1: 'endY'
|
|
271
287
|
},
|
|
272
288
|
tooltip: false,
|
|
273
|
-
style:
|
|
274
|
-
stroke: tokens.axisLine,
|
|
275
|
-
strokeOpacity: theme === 'academy' ? 1 : 0.82,
|
|
276
|
-
lineWidth: theme === 'academy' ? 1 : 0.75,
|
|
277
|
-
markerEnd: false,
|
|
278
|
-
connectLength1: -12
|
|
279
|
-
},
|
|
289
|
+
style: connectorMark,
|
|
280
290
|
labels: [{
|
|
281
291
|
text: formatMetricLabel(overallConversionRateLabel, formatConversionRate(data[0].value, data[data.length - 1].value), chartLocale),
|
|
282
292
|
position: 'left',
|
|
@@ -294,12 +304,11 @@ export var Funnel = function Funnel(options) {
|
|
|
294
304
|
axis: false,
|
|
295
305
|
interaction: {
|
|
296
306
|
tooltip: true,
|
|
297
|
-
elementHighlight:
|
|
307
|
+
elementHighlight: {
|
|
308
|
+
delay: CHART_STYLE_DEFAULTS.interactionDelay
|
|
309
|
+
}
|
|
298
310
|
},
|
|
299
|
-
|
|
300
|
-
viewFill: backgroundColor
|
|
301
|
-
} : undefined,
|
|
302
|
-
theme: getThemeObject(theme)
|
|
311
|
+
theme: rendererTheme
|
|
303
312
|
};
|
|
304
313
|
chart.options(chartOptions);
|
|
305
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.
|