@antv/gpt-vis 1.0.2 → 1.3.1
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 +53 -7
- 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/presets.d.ts +5 -0
- package/dist/cjs/theme/presets.js +663 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +59 -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 +109 -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 +46 -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/presets.d.ts +5 -0
- package/dist/esm/theme/presets.js +1070 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +31 -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 +109 -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
|
@@ -5,7 +5,8 @@ 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 { getThemeObject
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { getDataLabels } from "../../util/components";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* VennDataItem is the type for each data item in the venn chart.
|
|
@@ -73,8 +74,9 @@ export var Venn = function Venn(options) {
|
|
|
73
74
|
_config$theme = config.theme,
|
|
74
75
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
75
76
|
title = config.title,
|
|
77
|
+
subtitle = config.subtitle,
|
|
76
78
|
_config$style = config.style,
|
|
77
|
-
|
|
79
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
78
80
|
|
|
79
81
|
// Clean up previous chart if exists
|
|
80
82
|
if (chart) {
|
|
@@ -82,7 +84,10 @@ export var Venn = function Venn(options) {
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// Get colors from style.palette or theme defaults
|
|
85
|
-
var
|
|
87
|
+
var appearance = getThemeObject('venn', theme, localStyle);
|
|
88
|
+
var rendererTheme = appearance.theme;
|
|
89
|
+
var colors = rendererTheme.category10;
|
|
90
|
+
var pathMark = appearance.mark.path;
|
|
86
91
|
var normalizedData = data.map(function (d) {
|
|
87
92
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
88
93
|
sets: normalizeVennSets(d.sets)
|
|
@@ -113,7 +118,10 @@ export var Venn = function Venn(options) {
|
|
|
113
118
|
as: ['key', 'path']
|
|
114
119
|
}]
|
|
115
120
|
},
|
|
116
|
-
title: title
|
|
121
|
+
title: title ? {
|
|
122
|
+
title: title,
|
|
123
|
+
subtitle: subtitle
|
|
124
|
+
} : '',
|
|
117
125
|
encode: {
|
|
118
126
|
d: 'path',
|
|
119
127
|
color: 'key'
|
|
@@ -123,25 +131,25 @@ export var Venn = function Venn(options) {
|
|
|
123
131
|
range: colors
|
|
124
132
|
}
|
|
125
133
|
},
|
|
126
|
-
style: {
|
|
134
|
+
style: _objectSpread({
|
|
127
135
|
// Set opacity: intersections (sets.length > 1) are nearly transparent, single sets are more opaque
|
|
128
136
|
opacity: function opacity(d) {
|
|
129
137
|
return normalizeVennSets(d.sets).length > 1 ? 0.001 : 0.65;
|
|
130
138
|
}
|
|
131
|
-
},
|
|
132
|
-
labels:
|
|
139
|
+
}, pathMark),
|
|
140
|
+
labels: getDataLabels(rendererTheme, {
|
|
141
|
+
style: {
|
|
142
|
+
fillOpacity: 0.85,
|
|
143
|
+
fontSize: 10
|
|
144
|
+
},
|
|
145
|
+
defaultVisible: true,
|
|
133
146
|
position: 'inside',
|
|
147
|
+
contrast: 'inside',
|
|
134
148
|
text: function text(d) {
|
|
135
149
|
return d.label || '';
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
fontSize: 10
|
|
140
|
-
}],
|
|
141
|
-
viewStyle: style.backgroundColor ? {
|
|
142
|
-
viewFill: style.backgroundColor
|
|
143
|
-
} : undefined,
|
|
144
|
-
theme: getThemeObject(theme),
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
theme: rendererTheme,
|
|
145
153
|
legend: false,
|
|
146
154
|
axis: false,
|
|
147
155
|
tooltip: false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* ViolinDataItem is the type for each data item in the violin chart.
|
|
4
4
|
*/
|
|
@@ -13,13 +13,12 @@ export type ViolinDataItem = {
|
|
|
13
13
|
export interface ViolinConfig {
|
|
14
14
|
type?: 'violin';
|
|
15
15
|
data: ViolinDataItem[];
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
axisYTitle?: string;
|
|
20
|
-
style?: {
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
21
|
+
style?: ThemeStyle & {
|
|
23
22
|
startAtZero?: boolean;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -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 {
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { getCartesianAxis, getColorLegend } from "../../util/components";
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* ViolinDataItem is the type for each data item in the violin chart.
|
|
@@ -57,10 +64,11 @@ export var Violin = function Violin(options) {
|
|
|
57
64
|
_config$theme = config.theme,
|
|
58
65
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
59
66
|
title = config.title,
|
|
67
|
+
subtitle = config.subtitle,
|
|
60
68
|
axisXTitle = config.axisXTitle,
|
|
61
69
|
axisYTitle = config.axisYTitle,
|
|
62
70
|
_config$style = config.style,
|
|
63
|
-
|
|
71
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
64
72
|
|
|
65
73
|
// Clean up previous chart if exists
|
|
66
74
|
if (chart) {
|
|
@@ -68,12 +76,18 @@ export var Violin = function Violin(options) {
|
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
// Get colors from style.palette or theme defaults
|
|
71
|
-
var colors = normalizePalette(style.palette, theme);
|
|
72
|
-
var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
|
|
73
|
-
var startAtZero = style.startAtZero || false;
|
|
74
|
-
|
|
75
|
-
// Determine if data has group field for grouped violin plot
|
|
76
79
|
var hasGroupField = ((_ = (data || [])[0]) === null || _ === void 0 ? void 0 : _.group) !== undefined;
|
|
80
|
+
var appearance = getThemeObject('violin', theme, localStyle);
|
|
81
|
+
var rendererTheme = appearance.theme;
|
|
82
|
+
var boxMark = _objectSpread({
|
|
83
|
+
shape: 'violin',
|
|
84
|
+
opacity: 0.5,
|
|
85
|
+
strokeOpacity: 0.5
|
|
86
|
+
}, appearance.mark.box);
|
|
87
|
+
var colors = rendererTheme.category10;
|
|
88
|
+
var startAtZero = localStyle.startAtZero || false;
|
|
89
|
+
var densityStyle = appearance.mark.density;
|
|
90
|
+
var legend = getColorLegend(hasGroupField);
|
|
77
91
|
|
|
78
92
|
// Create chart
|
|
79
93
|
chart = new Chart({
|
|
@@ -111,21 +125,19 @@ export var Violin = function Violin(options) {
|
|
|
111
125
|
color: {
|
|
112
126
|
range: colors
|
|
113
127
|
}
|
|
114
|
-
}
|
|
128
|
+
},
|
|
129
|
+
style: densityStyle
|
|
115
130
|
}, {
|
|
116
131
|
type: 'boxplot',
|
|
117
132
|
encode: {
|
|
118
133
|
x: 'category',
|
|
119
134
|
y: 'value',
|
|
120
135
|
series: 'group',
|
|
121
|
-
color: 'group'
|
|
122
|
-
shape: 'violin'
|
|
136
|
+
color: 'group'
|
|
123
137
|
},
|
|
124
|
-
style: {
|
|
125
|
-
opacity: 0.5,
|
|
126
|
-
strokeOpacity: 0.5,
|
|
138
|
+
style: _objectSpread(_objectSpread({}, boxMark), {}, {
|
|
127
139
|
point: false
|
|
128
|
-
},
|
|
140
|
+
}),
|
|
129
141
|
scale: {
|
|
130
142
|
y: {
|
|
131
143
|
nice: true
|
|
@@ -160,20 +172,18 @@ export var Violin = function Violin(options) {
|
|
|
160
172
|
color: {
|
|
161
173
|
range: colors
|
|
162
174
|
}
|
|
163
|
-
}
|
|
175
|
+
},
|
|
176
|
+
style: densityStyle
|
|
164
177
|
}, {
|
|
165
178
|
type: 'boxplot',
|
|
166
179
|
encode: {
|
|
167
180
|
x: 'category',
|
|
168
181
|
y: 'value',
|
|
169
|
-
color: 'category'
|
|
170
|
-
shape: 'violin'
|
|
182
|
+
color: 'category'
|
|
171
183
|
},
|
|
172
|
-
style: {
|
|
173
|
-
opacity: 0.5,
|
|
174
|
-
strokeOpacity: 0.5,
|
|
184
|
+
style: _objectSpread(_objectSpread({}, boxMark), {}, {
|
|
175
185
|
point: false
|
|
176
|
-
},
|
|
186
|
+
}),
|
|
177
187
|
scale: {
|
|
178
188
|
y: {
|
|
179
189
|
nice: true
|
|
@@ -192,15 +202,14 @@ export var Violin = function Violin(options) {
|
|
|
192
202
|
animate: false,
|
|
193
203
|
type: 'view',
|
|
194
204
|
data: data,
|
|
195
|
-
title: title
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
},
|
|
205
|
+
title: title ? {
|
|
206
|
+
title: title,
|
|
207
|
+
subtitle: subtitle
|
|
208
|
+
} : '',
|
|
209
|
+
axis: getCartesianAxis({
|
|
210
|
+
axisXTitle: axisXTitle,
|
|
211
|
+
axisYTitle: axisYTitle
|
|
212
|
+
}),
|
|
204
213
|
scale: {
|
|
205
214
|
y: {
|
|
206
215
|
nice: true,
|
|
@@ -208,15 +217,14 @@ export var Violin = function Violin(options) {
|
|
|
208
217
|
}
|
|
209
218
|
},
|
|
210
219
|
children: children,
|
|
211
|
-
legend: {
|
|
212
|
-
color:
|
|
220
|
+
legend: legend === false ? {
|
|
221
|
+
color: false
|
|
222
|
+
} : {
|
|
223
|
+
color: _objectSpread({
|
|
213
224
|
position: 'top'
|
|
214
|
-
}
|
|
225
|
+
}, legend.color)
|
|
215
226
|
},
|
|
216
|
-
|
|
217
|
-
viewFill: backgroundColor
|
|
218
|
-
} : undefined,
|
|
219
|
-
theme: getThemeObject(theme)
|
|
227
|
+
theme: rendererTheme
|
|
220
228
|
};
|
|
221
229
|
chart.options(chartOptions);
|
|
222
230
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* WaterfallDataItem is the type for each data item in the waterfall chart.
|
|
4
4
|
*/
|
|
@@ -14,12 +14,12 @@ export type WaterfallDataItem = {
|
|
|
14
14
|
export interface WaterfallConfig {
|
|
15
15
|
type?: 'waterfall';
|
|
16
16
|
data: WaterfallDataItem[];
|
|
17
|
-
theme?:
|
|
17
|
+
theme?: VisualizationTheme;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
19
20
|
axisXTitle?: string;
|
|
20
21
|
axisYTitle?: string;
|
|
21
|
-
style?: {
|
|
22
|
-
backgroundColor?: string;
|
|
22
|
+
style?: ThemeStyle & {
|
|
23
23
|
/**
|
|
24
24
|
* Custom color palette for waterfall bars.
|
|
25
25
|
* Array order: [0] positive color, [1] negative color, [2] total/intermediate-total color.
|
|
@@ -1,11 +1,18 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
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; }
|
|
3
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; }
|
|
4
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; }
|
|
5
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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); }
|
|
7
13
|
import { Chart } from '@antv/g2';
|
|
8
|
-
import {
|
|
14
|
+
import { getThemeObject } from "../../theme/g2";
|
|
15
|
+
import { getDataLabels } from "../../util/components";
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* WaterfallDataItem is the type for each data item in the waterfall chart.
|
|
@@ -19,11 +26,6 @@ import { getBackgroundColor, getThemeObject } from "../../util/theme";
|
|
|
19
26
|
* WaterfallInstance represents a waterfall chart instance with render/destroy.
|
|
20
27
|
*/
|
|
21
28
|
|
|
22
|
-
// Default colors for waterfall chart
|
|
23
|
-
var DEFAULT_POSITIVE_COLOR = '#FF4D4F';
|
|
24
|
-
var DEFAULT_NEGATIVE_COLOR = '#2EBB59';
|
|
25
|
-
var DEFAULT_TOTAL_COLOR = '#1783FF';
|
|
26
|
-
|
|
27
29
|
/**
|
|
28
30
|
* Transform waterfall data to add __start__ and __end__ fields
|
|
29
31
|
* for proper rendering of stacked intervals
|
|
@@ -117,10 +119,11 @@ export var Waterfall = function Waterfall(options) {
|
|
|
117
119
|
_config$theme = config.theme,
|
|
118
120
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
119
121
|
title = config.title,
|
|
122
|
+
subtitle = config.subtitle,
|
|
120
123
|
axisXTitle = config.axisXTitle,
|
|
121
124
|
axisYTitle = config.axisYTitle,
|
|
122
125
|
_config$style = config.style,
|
|
123
|
-
|
|
126
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
124
127
|
|
|
125
128
|
// Clean up previous chart if exists
|
|
126
129
|
if (chart) {
|
|
@@ -129,11 +132,24 @@ export var Waterfall = function Waterfall(options) {
|
|
|
129
132
|
|
|
130
133
|
// Get colors from style.palette or defaults
|
|
131
134
|
// palette array order: [0] positive, [1] negative, [2] total
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
var appearance = getThemeObject('waterfall', theme, localStyle);
|
|
136
|
+
var rendererTheme = appearance.theme;
|
|
137
|
+
var intervalMark = _objectSpread(_objectSpread({
|
|
138
|
+
maxWidth: 60,
|
|
139
|
+
stroke: '#666'
|
|
140
|
+
}, rendererTheme.type !== 'academy' ? {
|
|
141
|
+
radius: 4
|
|
142
|
+
} : {}), appearance.mark.interval);
|
|
143
|
+
var linkMark = _objectSpread({
|
|
144
|
+
stroke: '#ccc',
|
|
145
|
+
lineDash: [4, 2],
|
|
146
|
+
lineWidth: 1
|
|
147
|
+
}, appearance.mark.link);
|
|
148
|
+
var _ref = rendererTheme.category10,
|
|
149
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
150
|
+
positiveColor = _ref2[0],
|
|
151
|
+
negativeColor = _ref2[1],
|
|
152
|
+
totalColor = _ref2[2];
|
|
137
153
|
|
|
138
154
|
// Transform data to include __start__ and __end__ fields
|
|
139
155
|
var transformedData = transformWaterfallData(data);
|
|
@@ -156,7 +172,10 @@ export var Waterfall = function Waterfall(options) {
|
|
|
156
172
|
animate: false,
|
|
157
173
|
type: 'view',
|
|
158
174
|
data: transformedData,
|
|
159
|
-
title: title
|
|
175
|
+
title: title ? {
|
|
176
|
+
title: title,
|
|
177
|
+
subtitle: subtitle
|
|
178
|
+
} : '',
|
|
160
179
|
marginRight: 28,
|
|
161
180
|
axis: {
|
|
162
181
|
x: {
|
|
@@ -181,28 +200,26 @@ export var Waterfall = function Waterfall(options) {
|
|
|
181
200
|
y: ['__start__', '__end__'],
|
|
182
201
|
color: 'category'
|
|
183
202
|
},
|
|
184
|
-
style: _objectSpread(
|
|
185
|
-
maxWidth: 60,
|
|
186
|
-
stroke: '#666'
|
|
187
|
-
}, theme !== 'academy' ? {
|
|
188
|
-
radius: 4
|
|
189
|
-
} : {}), {}, {
|
|
203
|
+
style: _objectSpread({
|
|
190
204
|
fill: function fill(d) {
|
|
191
205
|
return d.isTotal || d.isIntermediateTotal ? totalColor : d.__value__ > 0 ? positiveColor : negativeColor;
|
|
192
206
|
}
|
|
193
|
-
}),
|
|
194
|
-
labels:
|
|
207
|
+
}, intervalMark),
|
|
208
|
+
labels: getDataLabels(rendererTheme, {
|
|
209
|
+
style: {
|
|
210
|
+
fontSize: 10,
|
|
211
|
+
fontWeight: 600,
|
|
212
|
+
stroke: '#fff'
|
|
213
|
+
},
|
|
214
|
+
defaultVisible: true,
|
|
195
215
|
text: '__value__',
|
|
196
216
|
position: 'inside',
|
|
197
|
-
|
|
217
|
+
contrast: 'inside',
|
|
198
218
|
transform: [{
|
|
199
219
|
type: 'overflowHide'
|
|
200
220
|
}],
|
|
201
|
-
formatter: '~s'
|
|
202
|
-
|
|
203
|
-
fontWeight: 600,
|
|
204
|
-
stroke: '#fff'
|
|
205
|
-
}],
|
|
221
|
+
formatter: '~s'
|
|
222
|
+
}),
|
|
206
223
|
tooltip: {
|
|
207
224
|
title: function title(d) {
|
|
208
225
|
return d.category;
|
|
@@ -230,18 +247,11 @@ export var Waterfall = function Waterfall(options) {
|
|
|
230
247
|
y: 'y'
|
|
231
248
|
},
|
|
232
249
|
zIndex: -1,
|
|
233
|
-
style:
|
|
234
|
-
stroke: '#ccc',
|
|
235
|
-
lineDash: [4, 2],
|
|
236
|
-
lineWidth: 1
|
|
237
|
-
},
|
|
250
|
+
style: linkMark,
|
|
238
251
|
tooltip: false
|
|
239
252
|
}],
|
|
240
253
|
legend: false,
|
|
241
|
-
|
|
242
|
-
viewFill: backgroundColor
|
|
243
|
-
} : undefined,
|
|
244
|
-
theme: getThemeObject(theme)
|
|
254
|
+
theme: rendererTheme
|
|
245
255
|
};
|
|
246
256
|
chart.options(chartOptions);
|
|
247
257
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* WordCloudDataItem is the type for each data item in the word cloud chart.
|
|
4
4
|
*/
|
|
@@ -14,11 +14,9 @@ export interface WordCloudConfig {
|
|
|
14
14
|
data: WordCloudDataItem[];
|
|
15
15
|
theme?: VisualizationTheme;
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
locale?: string;
|
|
18
|
-
style?:
|
|
19
|
-
backgroundColor?: string;
|
|
20
|
-
palette?: string[];
|
|
21
|
-
};
|
|
19
|
+
style?: ThemeStyle;
|
|
22
20
|
}
|
|
23
21
|
/**
|
|
24
22
|
* WordCloudInstance represents a word cloud chart 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 { Chart } from '@antv/g2';
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
8
9
|
import { resolveChartLocale } from "../../util/components";
|
|
9
|
-
import {
|
|
10
|
+
import { getElementHoverScaleInteraction } from "../../util/interaction";
|
|
11
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
10
12
|
var WORD_CLOUD_MAX_WORDS = 50;
|
|
11
13
|
var WORD_CLOUD_FONT_FAMILY = 'Impact';
|
|
12
14
|
var WORD_CLOUD_ROTATIONS = [-90, -60, -30, 0, 30, 60];
|
|
@@ -45,9 +47,6 @@ var createSeededRandom = function createSeededRandom(seed) {
|
|
|
45
47
|
return ((value ^ value >>> 14) >>> 0) / 4294967296;
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
|
-
var getWordCloudPalette = function getWordCloudPalette(palette, theme) {
|
|
49
|
-
return normalizePalette(palette, theme);
|
|
50
|
-
};
|
|
51
50
|
var prepareWordCloudData = function prepareWordCloudData(data, colors) {
|
|
52
51
|
var rankedData = data.map(function (item, index) {
|
|
53
52
|
return {
|
|
@@ -136,15 +135,17 @@ export var WordCloud = function WordCloud(options) {
|
|
|
136
135
|
* Render the word cloud chart with the given configuration.
|
|
137
136
|
*/
|
|
138
137
|
var render = function render(config) {
|
|
138
|
+
var _ref5;
|
|
139
139
|
var _config$data = config.data,
|
|
140
140
|
data = _config$data === void 0 ? [] : _config$data,
|
|
141
141
|
_config$theme = config.theme,
|
|
142
142
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
143
143
|
title = config.title,
|
|
144
|
+
subtitle = config.subtitle,
|
|
144
145
|
_config$locale = config.locale,
|
|
145
146
|
renderLocale = _config$locale === void 0 ? locale : _config$locale,
|
|
146
147
|
_config$style = config.style,
|
|
147
|
-
|
|
148
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
148
149
|
var chartLocale = resolveChartLocale(renderLocale);
|
|
149
150
|
var labels = WORD_CLOUD_LABELS[chartLocale];
|
|
150
151
|
var valueFormatter = new Intl.NumberFormat(chartLocale, {
|
|
@@ -161,7 +162,11 @@ export var WordCloud = function WordCloud(options) {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
// Assign a stable categorical color to each word while preserving custom palettes.
|
|
164
|
-
var
|
|
165
|
+
var appearance = getThemeObject('word-cloud', theme, localStyle);
|
|
166
|
+
var rendererTheme = appearance.theme;
|
|
167
|
+
var colors = rendererTheme.category10;
|
|
168
|
+
var wordCloudStyle = appearance.mark.wordCloud;
|
|
169
|
+
var fontFamily = (_ref5 = wordCloudStyle.fontFamily) !== null && _ref5 !== void 0 ? _ref5 : WORD_CLOUD_FONT_FAMILY;
|
|
165
170
|
var preparedData = prepareWordCloudData(data, colors);
|
|
166
171
|
var layoutSeed = hashWordCloudData(preparedData);
|
|
167
172
|
var rotationRandom = createSeededRandom(layoutSeed ^ 0x9e3779b9);
|
|
@@ -181,9 +186,12 @@ export var WordCloud = function WordCloud(options) {
|
|
|
181
186
|
animate: false,
|
|
182
187
|
type: 'wordCloud',
|
|
183
188
|
data: preparedData,
|
|
184
|
-
title: title
|
|
189
|
+
title: title ? {
|
|
190
|
+
title: title,
|
|
191
|
+
subtitle: subtitle
|
|
192
|
+
} : '',
|
|
185
193
|
layout: {
|
|
186
|
-
font:
|
|
194
|
+
font: fontFamily,
|
|
187
195
|
fontSize: [11, 44],
|
|
188
196
|
fontWeight: function fontWeight(d) {
|
|
189
197
|
return d.fontWeight;
|
|
@@ -199,11 +207,11 @@ export var WordCloud = function WordCloud(options) {
|
|
|
199
207
|
color: 'text',
|
|
200
208
|
value: 'value'
|
|
201
209
|
},
|
|
202
|
-
style: {
|
|
210
|
+
style: _objectSpread({
|
|
203
211
|
fill: function fill(d) {
|
|
204
212
|
return d.wordColor;
|
|
205
213
|
},
|
|
206
|
-
fontFamily:
|
|
214
|
+
fontFamily: fontFamily,
|
|
207
215
|
fontWeight: function fontWeight(d) {
|
|
208
216
|
var _d$weight;
|
|
209
217
|
return (_d$weight = d.weight) !== null && _d$weight !== void 0 ? _d$weight : d.fontWeight;
|
|
@@ -211,7 +219,7 @@ export var WordCloud = function WordCloud(options) {
|
|
|
211
219
|
stroke: function stroke(d) {
|
|
212
220
|
return d.wordColor;
|
|
213
221
|
}
|
|
214
|
-
},
|
|
222
|
+
}, wordCloudStyle),
|
|
215
223
|
scale: {
|
|
216
224
|
color: {
|
|
217
225
|
range: colors
|
|
@@ -249,13 +257,12 @@ export var WordCloud = function WordCloud(options) {
|
|
|
249
257
|
},
|
|
250
258
|
interaction: {
|
|
251
259
|
tooltip: true,
|
|
252
|
-
elementHighlight:
|
|
253
|
-
|
|
260
|
+
elementHighlight: {
|
|
261
|
+
delay: CHART_STYLE_DEFAULTS.interactionDelay
|
|
262
|
+
},
|
|
263
|
+
elementHoverScale: getElementHoverScaleInteraction(rendererTheme.type)
|
|
254
264
|
},
|
|
255
|
-
|
|
256
|
-
viewFill: style.backgroundColor
|
|
257
|
-
} : undefined,
|
|
258
|
-
theme: getThemeObject(theme)
|
|
265
|
+
theme: rendererTheme
|
|
259
266
|
};
|
|
260
267
|
chart.options(chartOptions);
|
|
261
268
|
chart.render();
|