@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,11 +1,17 @@
|
|
|
1
|
+
var _excluded = ["size"];
|
|
1
2
|
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); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
2
5
|
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
6
|
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
7
|
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
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
10
|
import { Chart } from '@antv/g2';
|
|
8
|
-
import {
|
|
11
|
+
import { getThemeObject } from "../../theme/g2";
|
|
12
|
+
import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
|
|
13
|
+
import { getColorLegend } from "../../util/components";
|
|
14
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* AreaDataItem is the type for each data item in the area chart.
|
|
@@ -65,18 +71,19 @@ export var Area = function Area(options) {
|
|
|
65
71
|
* Render the area chart with the given configuration.
|
|
66
72
|
*/
|
|
67
73
|
var render = function render(config) {
|
|
68
|
-
var _data
|
|
74
|
+
var _data$, _areaMark$fillOpacity;
|
|
69
75
|
var _config$data = config.data,
|
|
70
76
|
data = _config$data === void 0 ? [] : _config$data,
|
|
71
77
|
_config$theme = config.theme,
|
|
72
78
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
73
79
|
title = config.title,
|
|
80
|
+
subtitle = config.subtitle,
|
|
74
81
|
axisXTitle = config.axisXTitle,
|
|
75
82
|
axisYTitle = config.axisYTitle,
|
|
76
83
|
_config$stack = config.stack,
|
|
77
84
|
stack = _config$stack === void 0 ? false : _config$stack,
|
|
78
85
|
_config$style = config.style,
|
|
79
|
-
|
|
86
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
80
87
|
|
|
81
88
|
// Clean up previous chart if exists
|
|
82
89
|
if (chart) {
|
|
@@ -85,14 +92,7 @@ export var Area = function Area(options) {
|
|
|
85
92
|
cleanupCrosshairAxisLabels = null;
|
|
86
93
|
chart.destroy();
|
|
87
94
|
}
|
|
88
|
-
var _style$lineWidth = style.lineWidth,
|
|
89
|
-
lineWidth = _style$lineWidth === void 0 ? CHART_STYLE_DEFAULTS.lineWidth : _style$lineWidth;
|
|
90
95
|
var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
|
|
91
|
-
var colors = normalizePalette(style.palette, theme);
|
|
92
|
-
var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
|
|
93
|
-
var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
|
|
94
|
-
var areaOpacity = CHART_STYLE_DEFAULTS.areaOpacity;
|
|
95
|
-
var lineOpacity = CHART_STYLE_DEFAULTS.lineOpacity;
|
|
96
96
|
var cartesianAxisOptions = {
|
|
97
97
|
axisXTitle: axisXTitle,
|
|
98
98
|
axisYTitle: axisYTitle,
|
|
@@ -102,6 +102,27 @@ export var Area = function Area(options) {
|
|
|
102
102
|
}),
|
|
103
103
|
chartWidth: width
|
|
104
104
|
};
|
|
105
|
+
var appearance = getThemeObject('area', theme, localStyle);
|
|
106
|
+
var rendererTheme = appearance.theme;
|
|
107
|
+
var areaMark = _objectSpread({
|
|
108
|
+
fillOpacity: CHART_STYLE_DEFAULTS.areaOpacity
|
|
109
|
+
}, appearance.mark.area);
|
|
110
|
+
var lineMark = _objectSpread({
|
|
111
|
+
lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
|
|
112
|
+
strokeOpacity: CHART_STYLE_DEFAULTS.lineOpacity
|
|
113
|
+
}, appearance.mark.line);
|
|
114
|
+
var pointStyle = _objectSpread({
|
|
115
|
+
shape: 'point',
|
|
116
|
+
size: CHART_STYLE_DEFAULTS.pointSize,
|
|
117
|
+
lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
118
|
+
stroke: rendererTheme.view.viewFill
|
|
119
|
+
}, appearance.mark.point);
|
|
120
|
+
var baseTheme = rendererTheme.type;
|
|
121
|
+
var lineWidth = lineMark.lineWidth;
|
|
122
|
+
var colors = rendererTheme.category10;
|
|
123
|
+
var backgroundColor = rendererTheme.view.viewFill;
|
|
124
|
+
var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
|
|
125
|
+
var areaOpacity = (_areaMark$fillOpacity = areaMark.fillOpacity) !== null && _areaMark$fillOpacity !== void 0 ? _areaMark$fillOpacity : CHART_STYLE_DEFAULTS.areaOpacity;
|
|
105
126
|
var tooltip = {
|
|
106
127
|
items: [function (d) {
|
|
107
128
|
return {
|
|
@@ -143,15 +164,10 @@ export var Area = function Area(options) {
|
|
|
143
164
|
};
|
|
144
165
|
children = [{
|
|
145
166
|
type: 'area',
|
|
146
|
-
style:
|
|
147
|
-
fillOpacity: areaOpacity
|
|
148
|
-
}
|
|
167
|
+
style: areaMark
|
|
149
168
|
}, {
|
|
150
169
|
type: 'line',
|
|
151
|
-
style:
|
|
152
|
-
lineWidth: lineWidth,
|
|
153
|
-
strokeOpacity: lineOpacity
|
|
154
|
-
}
|
|
170
|
+
style: lineMark
|
|
155
171
|
}];
|
|
156
172
|
} else if (hasGroupField) {
|
|
157
173
|
// Multi-line area chart (not stacked)
|
|
@@ -165,15 +181,10 @@ export var Area = function Area(options) {
|
|
|
165
181
|
};
|
|
166
182
|
children = [{
|
|
167
183
|
type: 'area',
|
|
168
|
-
style:
|
|
169
|
-
fillOpacity: areaOpacity
|
|
170
|
-
}
|
|
184
|
+
style: areaMark
|
|
171
185
|
}, {
|
|
172
186
|
type: 'line',
|
|
173
|
-
style:
|
|
174
|
-
lineWidth: lineWidth,
|
|
175
|
-
strokeOpacity: lineOpacity
|
|
176
|
-
}
|
|
187
|
+
style: lineMark
|
|
177
188
|
}];
|
|
178
189
|
} else {
|
|
179
190
|
// Single area chart
|
|
@@ -183,19 +194,17 @@ export var Area = function Area(options) {
|
|
|
183
194
|
};
|
|
184
195
|
children = [{
|
|
185
196
|
type: 'area',
|
|
186
|
-
style: {
|
|
187
|
-
fillOpacity: areaOpacity,
|
|
197
|
+
style: _objectSpread(_objectSpread({}, areaMark), {}, {
|
|
188
198
|
fill: fillColor
|
|
189
|
-
}
|
|
199
|
+
})
|
|
190
200
|
}, {
|
|
191
201
|
type: 'line',
|
|
192
|
-
style: {
|
|
193
|
-
lineWidth: lineWidth,
|
|
194
|
-
strokeOpacity: lineOpacity,
|
|
202
|
+
style: _objectSpread(_objectSpread({
|
|
195
203
|
lineCap: 'round',
|
|
196
|
-
lineJoin: 'round'
|
|
204
|
+
lineJoin: 'round'
|
|
205
|
+
}, lineMark), {}, {
|
|
197
206
|
stroke: colors[0]
|
|
198
|
-
}
|
|
207
|
+
})
|
|
199
208
|
}];
|
|
200
209
|
}
|
|
201
210
|
children = children.map(function (child) {
|
|
@@ -213,21 +222,20 @@ export var Area = function Area(options) {
|
|
|
213
222
|
});
|
|
214
223
|
});
|
|
215
224
|
if (!hasGroupField && data.length <= 24) {
|
|
225
|
+
var pointSize = pointStyle.size,
|
|
226
|
+
pointMark = _objectWithoutProperties(pointStyle, _excluded);
|
|
216
227
|
children.push({
|
|
217
228
|
type: 'point',
|
|
218
229
|
encode: {
|
|
219
230
|
x: 'time',
|
|
220
231
|
y: 'value',
|
|
221
|
-
|
|
222
|
-
size: CHART_STYLE_DEFAULTS.pointSize
|
|
232
|
+
size: pointSize
|
|
223
233
|
},
|
|
224
234
|
animate: getChartAnimation(hasRendered, 'fadeIn'),
|
|
225
235
|
tooltip: false,
|
|
226
|
-
style: {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
stroke: backgroundColor
|
|
230
|
-
}
|
|
236
|
+
style: _objectSpread(_objectSpread({}, pointMark), {}, {
|
|
237
|
+
fill: colors[0]
|
|
238
|
+
})
|
|
231
239
|
});
|
|
232
240
|
}
|
|
233
241
|
|
|
@@ -237,7 +245,10 @@ export var Area = function Area(options) {
|
|
|
237
245
|
var chartOptions = _objectSpread(_objectSpread({
|
|
238
246
|
type: 'view',
|
|
239
247
|
data: data,
|
|
240
|
-
title: title
|
|
248
|
+
title: title ? {
|
|
249
|
+
title: title,
|
|
250
|
+
subtitle: subtitle
|
|
251
|
+
} : '',
|
|
241
252
|
encode: encode,
|
|
242
253
|
transform: transform,
|
|
243
254
|
children: children,
|
|
@@ -250,13 +261,10 @@ export var Area = function Area(options) {
|
|
|
250
261
|
crosshairs: true
|
|
251
262
|
})
|
|
252
263
|
}, hasGroupField ? getSeriesHighlightByColorInteraction() : {}),
|
|
253
|
-
|
|
254
|
-
viewFill: backgroundColor
|
|
255
|
-
} : undefined,
|
|
256
|
-
theme: getThemeObject(theme)
|
|
264
|
+
theme: rendererTheme
|
|
257
265
|
});
|
|
258
266
|
chart.options(chartOptions);
|
|
259
|
-
cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart,
|
|
267
|
+
cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, baseTheme);
|
|
260
268
|
chart.render();
|
|
261
269
|
hasRendered = true;
|
|
262
270
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* BarDataItem is the type for each data item in the bar chart.
|
|
4
4
|
*/
|
|
@@ -16,13 +16,13 @@ export interface BarConfig {
|
|
|
16
16
|
group?: boolean;
|
|
17
17
|
stack?: boolean;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/** Show value labels. Defaults to `true`. */
|
|
21
|
+
label?: boolean;
|
|
19
22
|
axisXTitle?: string;
|
|
20
23
|
axisYTitle?: string;
|
|
21
24
|
theme?: VisualizationTheme;
|
|
22
|
-
style?:
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
palette?: string[];
|
|
25
|
-
};
|
|
25
|
+
style?: ThemeStyle;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* BarInstance represents a bar chart instance with render and destroy methods.
|
|
@@ -5,7 +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 {
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction } from "../../util";
|
|
10
|
+
import { getColorLegend, getDataLabels } from "../../util/components";
|
|
11
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* BarDataItem is the type for each data item in the bar chart.
|
|
@@ -52,7 +55,6 @@ export var Bar = function Bar(options) {
|
|
|
52
55
|
_options$theme = options.theme,
|
|
53
56
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
54
57
|
var chart = null;
|
|
55
|
-
var hasRendered = false;
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Render the bar chart with the given configuration.
|
|
@@ -64,6 +66,8 @@ export var Bar = function Bar(options) {
|
|
|
64
66
|
_config$theme = config.theme,
|
|
65
67
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
66
68
|
title = config.title,
|
|
69
|
+
subtitle = config.subtitle,
|
|
70
|
+
label = config.label,
|
|
67
71
|
axisXTitle = config.axisXTitle,
|
|
68
72
|
axisYTitle = config.axisYTitle,
|
|
69
73
|
_config$group = config.group,
|
|
@@ -71,14 +75,24 @@ export var Bar = function Bar(options) {
|
|
|
71
75
|
_config$stack = config.stack,
|
|
72
76
|
stack = _config$stack === void 0 ? false : _config$stack,
|
|
73
77
|
_config$style = config.style,
|
|
74
|
-
|
|
78
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
75
79
|
|
|
76
80
|
// Clean up previous chart if exists
|
|
77
81
|
if (chart) {
|
|
78
82
|
chart.destroy();
|
|
79
83
|
}
|
|
80
84
|
var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
|
|
81
|
-
var
|
|
85
|
+
var appearance = getThemeObject('bar', theme, localStyle);
|
|
86
|
+
var rendererTheme = appearance.theme;
|
|
87
|
+
var intervalMark = _objectSpread(_objectSpread(_objectSpread({}, rendererTheme.type !== 'academy' ? {
|
|
88
|
+
radius: 4
|
|
89
|
+
} : {}), {}, {
|
|
90
|
+
columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
|
|
91
|
+
}, !hasGroupField ? {
|
|
92
|
+
fill: rendererTheme.category10[0]
|
|
93
|
+
} : {}), appearance.mark.interval);
|
|
94
|
+
var baseTheme = rendererTheme.type;
|
|
95
|
+
var colors = rendererTheme.category10;
|
|
82
96
|
|
|
83
97
|
// Create chart
|
|
84
98
|
chart = new Chart({
|
|
@@ -91,14 +105,6 @@ export var Bar = function Bar(options) {
|
|
|
91
105
|
// Configure chart encode and transform based on group/stack
|
|
92
106
|
var encode = {};
|
|
93
107
|
var transform = [];
|
|
94
|
-
var radiusStyle = {};
|
|
95
|
-
|
|
96
|
-
// Academy uses square corners; other themes use a subtle radius on every corner.
|
|
97
|
-
if (theme !== 'academy') {
|
|
98
|
-
radiusStyle = {
|
|
99
|
-
radius: 4
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
108
|
|
|
103
109
|
// Configure transforms based on group/stack flags
|
|
104
110
|
if (hasGroupField && group) {
|
|
@@ -136,15 +142,20 @@ export var Bar = function Bar(options) {
|
|
|
136
142
|
range: colors
|
|
137
143
|
}
|
|
138
144
|
} : {});
|
|
139
|
-
|
|
140
145
|
// Configure chart options
|
|
141
146
|
// Note: Using 'any' type due to G2's complex type system with transformations
|
|
142
147
|
// This is consistent with how G2 5.0 is used elsewhere in the codebase
|
|
143
148
|
var chartOptions = {
|
|
144
|
-
|
|
149
|
+
// G2 growInX currently computes interval label bounds from the animated
|
|
150
|
+
// clip path, which leaves inside labels at the axis baseline. Keep the
|
|
151
|
+
// interval and its labels in sync until the upstream runtime is fixed.
|
|
152
|
+
animate: false,
|
|
145
153
|
type: 'interval',
|
|
146
154
|
data: data,
|
|
147
|
-
title: title
|
|
155
|
+
title: title ? {
|
|
156
|
+
title: title,
|
|
157
|
+
subtitle: subtitle
|
|
158
|
+
} : '',
|
|
148
159
|
encode: encode,
|
|
149
160
|
transform: transform,
|
|
150
161
|
coordinate: {
|
|
@@ -158,6 +169,15 @@ export var Bar = function Bar(options) {
|
|
|
158
169
|
axisYTitle: axisYTitle
|
|
159
170
|
}),
|
|
160
171
|
legend: getColorLegend(hasGroupField),
|
|
172
|
+
labels: getDataLabels(rendererTheme, {
|
|
173
|
+
visible: label,
|
|
174
|
+
defaultVisible: true,
|
|
175
|
+
text: 'value',
|
|
176
|
+
position: 'right',
|
|
177
|
+
contrast: 'inside',
|
|
178
|
+
dx: -4,
|
|
179
|
+
dy: 0
|
|
180
|
+
}),
|
|
161
181
|
tooltip: {
|
|
162
182
|
items: [function (d) {
|
|
163
183
|
return {
|
|
@@ -166,24 +186,16 @@ export var Bar = function Bar(options) {
|
|
|
166
186
|
};
|
|
167
187
|
}]
|
|
168
188
|
},
|
|
169
|
-
state: getCategoryBackgroundHighlightState(
|
|
189
|
+
state: getCategoryBackgroundHighlightState(baseTheme),
|
|
170
190
|
interaction: {
|
|
171
191
|
tooltip: true,
|
|
172
192
|
elementHighlight: getCategoryHighlightInteraction()
|
|
173
193
|
},
|
|
174
|
-
style:
|
|
175
|
-
|
|
176
|
-
}, !hasGroupField ? {
|
|
177
|
-
fill: colors[0]
|
|
178
|
-
} : {}),
|
|
179
|
-
viewStyle: style.backgroundColor ? {
|
|
180
|
-
viewFill: style.backgroundColor
|
|
181
|
-
} : undefined,
|
|
182
|
-
theme: getThemeObject(theme)
|
|
194
|
+
style: intervalMark,
|
|
195
|
+
theme: rendererTheme
|
|
183
196
|
};
|
|
184
197
|
chart.options(chartOptions);
|
|
185
198
|
chart.render();
|
|
186
|
-
hasRendered = true;
|
|
187
199
|
};
|
|
188
200
|
|
|
189
201
|
/**
|
|
@@ -194,7 +206,6 @@ export var Bar = function Bar(options) {
|
|
|
194
206
|
chart.destroy();
|
|
195
207
|
chart = null;
|
|
196
208
|
}
|
|
197
|
-
hasRendered = false;
|
|
198
209
|
};
|
|
199
210
|
return {
|
|
200
211
|
render: render,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* BoxplotDataItem is the type for each data item in the boxplot chart.
|
|
4
4
|
*/
|
|
@@ -13,13 +13,12 @@ export type BoxplotDataItem = {
|
|
|
13
13
|
export interface BoxplotConfig {
|
|
14
14
|
type?: 'boxplot';
|
|
15
15
|
data: BoxplotDataItem[];
|
|
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
|
}
|
|
@@ -4,8 +4,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import { Chart } from '@antv/g2';
|
|
8
|
-
import { getThemeObject
|
|
14
|
+
import { getThemeObject } from "../../theme/g2";
|
|
15
|
+
import { getCartesianAxis, getColorLegend } from "../../util/components";
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* BoxplotDataItem is the type for each data item in the boxplot chart.
|
|
@@ -19,6 +26,15 @@ import { getThemeObject, normalizePalette } from "../../util/theme";
|
|
|
19
26
|
* BoxplotInstance represents a boxplot chart instance with render and destroy.
|
|
20
27
|
*/
|
|
21
28
|
|
|
29
|
+
var prefixMarkStyle = function prefixMarkStyle(prefix, style) {
|
|
30
|
+
return Object.fromEntries(Object.entries(style !== null && style !== void 0 ? style : {}).map(function (_ref) {
|
|
31
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
32
|
+
key = _ref2[0],
|
|
33
|
+
value = _ref2[1];
|
|
34
|
+
return ["".concat(prefix).concat(key.charAt(0).toUpperCase()).concat(key.slice(1)), value];
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
|
|
22
38
|
/**
|
|
23
39
|
* Boxplot chart component using G2 5.0.
|
|
24
40
|
*
|
|
@@ -63,10 +79,11 @@ export var Boxplot = function Boxplot(options) {
|
|
|
63
79
|
_config$theme = config.theme,
|
|
64
80
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
65
81
|
title = config.title,
|
|
82
|
+
subtitle = config.subtitle,
|
|
66
83
|
axisXTitle = config.axisXTitle,
|
|
67
84
|
axisYTitle = config.axisYTitle,
|
|
68
85
|
_config$style = config.style,
|
|
69
|
-
|
|
86
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
70
87
|
|
|
71
88
|
// Clean up previous chart if exists
|
|
72
89
|
if (chart) {
|
|
@@ -74,11 +91,11 @@ export var Boxplot = function Boxplot(options) {
|
|
|
74
91
|
}
|
|
75
92
|
|
|
76
93
|
// Get colors from style.palette or theme defaults
|
|
77
|
-
var colors = normalizePalette(style.palette, theme);
|
|
78
|
-
var startAtZero = style.startAtZero || false;
|
|
79
|
-
|
|
80
|
-
// Determine if data has group field for grouped boxplot
|
|
81
94
|
var hasGroupField = ((_ = (data || [])[0]) === null || _ === void 0 ? void 0 : _.group) !== undefined;
|
|
95
|
+
var appearance = getThemeObject('boxplot', theme, localStyle);
|
|
96
|
+
var rendererTheme = appearance.theme;
|
|
97
|
+
var colors = rendererTheme.category10;
|
|
98
|
+
var startAtZero = localStyle.startAtZero || false;
|
|
82
99
|
var encode = {};
|
|
83
100
|
if (hasGroupField) {
|
|
84
101
|
encode = {
|
|
@@ -94,6 +111,13 @@ export var Boxplot = function Boxplot(options) {
|
|
|
94
111
|
color: 'category'
|
|
95
112
|
};
|
|
96
113
|
}
|
|
114
|
+
var showPoints = !hasGroupField;
|
|
115
|
+
var boxStyle = appearance.mark.box;
|
|
116
|
+
var resolvedPointStyle = appearance.mark.point;
|
|
117
|
+
var markStyle = showPoints ? _objectSpread(_objectSpread({}, prefixMarkStyle('box', boxStyle)), prefixMarkStyle('point', resolvedPointStyle)) : _objectSpread(_objectSpread({}, boxStyle), {}, {
|
|
118
|
+
point: false
|
|
119
|
+
});
|
|
120
|
+
var legend = getColorLegend(hasGroupField);
|
|
97
121
|
|
|
98
122
|
// Create chart
|
|
99
123
|
chart = new Chart({
|
|
@@ -110,16 +134,15 @@ export var Boxplot = function Boxplot(options) {
|
|
|
110
134
|
animate: false,
|
|
111
135
|
type: 'boxplot',
|
|
112
136
|
data: data,
|
|
113
|
-
title: title
|
|
137
|
+
title: title ? {
|
|
138
|
+
title: title,
|
|
139
|
+
subtitle: subtitle
|
|
140
|
+
} : '',
|
|
114
141
|
encode: encode,
|
|
115
|
-
axis: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
y: {
|
|
120
|
-
title: axisYTitle || false
|
|
121
|
-
}
|
|
122
|
-
},
|
|
142
|
+
axis: getCartesianAxis({
|
|
143
|
+
axisXTitle: axisXTitle,
|
|
144
|
+
axisYTitle: axisYTitle
|
|
145
|
+
}),
|
|
123
146
|
scale: {
|
|
124
147
|
x: {
|
|
125
148
|
paddingInner: 0.6,
|
|
@@ -137,24 +160,19 @@ export var Boxplot = function Boxplot(options) {
|
|
|
137
160
|
range: colors
|
|
138
161
|
}
|
|
139
162
|
},
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
// the `scale` config, causing legendFilter interaction to throw
|
|
143
|
-
// "Cannot read properties of undefined (reading 'color')" when clicking legend items.
|
|
163
|
+
// Grouped boxplots keep outliers disabled because G2's point child does
|
|
164
|
+
// not inherit the composite color scale used by legend filtering.
|
|
144
165
|
style: _objectSpread({
|
|
145
166
|
stroke: 'black'
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
color:
|
|
167
|
+
}, markStyle),
|
|
168
|
+
legend: legend === false ? {
|
|
169
|
+
color: false
|
|
170
|
+
} : {
|
|
171
|
+
color: _objectSpread({
|
|
151
172
|
position: 'top'
|
|
152
|
-
}
|
|
173
|
+
}, legend.color)
|
|
153
174
|
},
|
|
154
|
-
|
|
155
|
-
viewFill: style.backgroundColor
|
|
156
|
-
} : undefined,
|
|
157
|
-
theme: getThemeObject(theme)
|
|
175
|
+
theme: rendererTheme
|
|
158
176
|
};
|
|
159
177
|
chart.options(chartOptions);
|
|
160
178
|
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
|
* ColumnDataItem is the type for each data item in the column chart.
|
|
4
4
|
*/
|
|
@@ -16,13 +16,13 @@ export interface ColumnConfig {
|
|
|
16
16
|
group?: boolean;
|
|
17
17
|
stack?: boolean;
|
|
18
18
|
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/** Show value labels. Defaults to `true`. */
|
|
21
|
+
label?: boolean;
|
|
19
22
|
axisXTitle?: string;
|
|
20
23
|
axisYTitle?: string;
|
|
21
24
|
theme?: VisualizationTheme;
|
|
22
|
-
style?:
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
palette?: string[];
|
|
25
|
-
};
|
|
25
|
+
style?: ThemeStyle;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* ColumnInstance represents a column chart instance with render and destroy methods.
|