@antv/gpt-vis 1.0.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -36
- package/README.zh-CN.md +113 -36
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +58 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +107 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +7 -2
- package/dist/cjs/util/crosshair-axis-labels.js +144 -30
- package/dist/cjs/util/html.d.ts +1 -0
- package/dist/cjs/util/html.js +29 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +13 -10
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +87 -51
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -6
- package/dist/cjs/vis/funnel/index.js +77 -58
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +56 -8
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +27 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +107 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +7 -2
- package/dist/esm/util/crosshair-axis-labels.js +156 -35
- package/dist/esm/util/html.d.ts +1 -0
- package/dist/esm/util/html.js +3 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +13 -10
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +97 -57
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -6
- package/dist/esm/vis/funnel/index.js +78 -68
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +48 -11
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* RadarDataItem is the type for each data item in the radar chart.
|
|
4
4
|
*/
|
|
@@ -14,13 +14,10 @@ export interface RadarConfig {
|
|
|
14
14
|
type?: 'radar';
|
|
15
15
|
data: RadarDataItem[];
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
align?: boolean;
|
|
18
19
|
theme?: VisualizationTheme;
|
|
19
|
-
style?:
|
|
20
|
-
backgroundColor?: string;
|
|
21
|
-
palette?: string[];
|
|
22
|
-
lineWidth?: number;
|
|
23
|
-
};
|
|
20
|
+
style?: ThemeStyle;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* RadarInstance represents a radar chart instance with render and destroy methods.
|
|
@@ -15,7 +15,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
15
15
|
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; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
import { Chart } from '@antv/g2';
|
|
18
|
-
import {
|
|
18
|
+
import { getThemeObject } from "../../theme/g2";
|
|
19
|
+
import { getLineHighlightState, getSeriesHighlightByColorInteraction } from "../../util";
|
|
20
|
+
import { getColorLegend } from "../../util/components";
|
|
21
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* RadarDataItem is the type for each data item in the radar chart.
|
|
@@ -103,31 +106,40 @@ export var Radar = function Radar(options) {
|
|
|
103
106
|
* Render the radar chart with the given configuration.
|
|
104
107
|
*/
|
|
105
108
|
var render = function render(config) {
|
|
109
|
+
var _lineMark$lineWidth;
|
|
106
110
|
var _config$data = config.data,
|
|
107
111
|
data = _config$data === void 0 ? [] : _config$data,
|
|
108
112
|
_config$theme = config.theme,
|
|
109
113
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
110
114
|
title = config.title,
|
|
115
|
+
subtitle = config.subtitle,
|
|
111
116
|
_config$align = config.align,
|
|
112
117
|
align = _config$align === void 0 ? false : _config$align,
|
|
113
118
|
_config$style = config.style,
|
|
114
|
-
|
|
119
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
115
120
|
|
|
116
121
|
// Clean up previous chart if exists
|
|
117
122
|
if (chart) {
|
|
118
123
|
chart.destroy();
|
|
119
124
|
}
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
var
|
|
125
|
+
var parallelData = transformRadarToParallel(data);
|
|
126
|
+
var appearance = getThemeObject('radar', theme, localStyle);
|
|
127
|
+
var rendererTheme = appearance.theme;
|
|
128
|
+
var lineMark = _objectSpread({
|
|
129
|
+
lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
|
|
130
|
+
lineCap: 'round',
|
|
131
|
+
lineJoin: 'round',
|
|
132
|
+
strokeOpacity: CHART_STYLE_DEFAULTS.lineOpacity
|
|
133
|
+
}, appearance.mark.line);
|
|
134
|
+
var lineWidth = (_lineMark$lineWidth = lineMark.lineWidth) !== null && _lineMark$lineWidth !== void 0 ? _lineMark$lineWidth : CHART_STYLE_DEFAULTS.lineWidth;
|
|
135
|
+
var colors = rendererTheme.category10;
|
|
123
136
|
|
|
124
137
|
// Transform data to parallel format
|
|
125
|
-
var parallelData = transformRadarToParallel(data);
|
|
126
138
|
var position = Object.keys(parallelData[0] || {}).filter(function (key) {
|
|
127
139
|
return key !== 'group';
|
|
128
140
|
});
|
|
129
141
|
var hasMultipleSeries = parallelData.length > 1;
|
|
130
|
-
var legend = getColorLegend(
|
|
142
|
+
var legend = getColorLegend(parallelData.length > 1);
|
|
131
143
|
|
|
132
144
|
// Create chart
|
|
133
145
|
chart = new Chart({
|
|
@@ -144,7 +156,10 @@ export var Radar = function Radar(options) {
|
|
|
144
156
|
animate: false,
|
|
145
157
|
type: 'line',
|
|
146
158
|
data: parallelData,
|
|
147
|
-
title: title
|
|
159
|
+
title: title ? {
|
|
160
|
+
title: title,
|
|
161
|
+
subtitle: subtitle
|
|
162
|
+
} : '',
|
|
148
163
|
coordinate: {
|
|
149
164
|
type: 'radar'
|
|
150
165
|
},
|
|
@@ -177,20 +192,16 @@ export var Radar = function Radar(options) {
|
|
|
177
192
|
axis: Object.fromEntries(Array.from({
|
|
178
193
|
length: position.length
|
|
179
194
|
}, function (_, i) {
|
|
180
|
-
|
|
195
|
+
var defaults = {
|
|
181
196
|
label: align ? i === 0 : true,
|
|
182
197
|
tickFilter: function tickFilter(_, idx) {
|
|
183
198
|
return !(i !== 0 && idx === 0);
|
|
184
199
|
},
|
|
185
200
|
grid: i === 0
|
|
186
|
-
}
|
|
201
|
+
};
|
|
202
|
+
return ["position".concat(i === 0 ? '' : i), _objectSpread(_objectSpread({}, defaults), rendererTheme.axis)];
|
|
187
203
|
})),
|
|
188
|
-
style:
|
|
189
|
-
lineWidth: lineWidth,
|
|
190
|
-
lineCap: 'round',
|
|
191
|
-
lineJoin: 'round',
|
|
192
|
-
strokeOpacity: CHART_STYLE_DEFAULTS.lineOpacity
|
|
193
|
-
},
|
|
204
|
+
style: lineMark,
|
|
194
205
|
state: hasMultipleSeries ? getLineHighlightState(lineWidth) : undefined,
|
|
195
206
|
legend: legend === false ? false : {
|
|
196
207
|
color: _objectSpread(_objectSpread({}, legend.color), {}, {
|
|
@@ -200,10 +211,7 @@ export var Radar = function Radar(options) {
|
|
|
200
211
|
interaction: _objectSpread({
|
|
201
212
|
tooltip: true
|
|
202
213
|
}, hasMultipleSeries ? getSeriesHighlightByColorInteraction() : {}),
|
|
203
|
-
|
|
204
|
-
viewFill: style.backgroundColor
|
|
205
|
-
} : undefined,
|
|
206
|
-
theme: getThemeObject(theme)
|
|
214
|
+
theme: rendererTheme
|
|
207
215
|
};
|
|
208
216
|
chart.options(chartOptions);
|
|
209
217
|
chart.render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* SankeyDataItem is the type for each data item in the sankey chart.
|
|
4
4
|
*/
|
|
@@ -14,12 +14,10 @@ export interface SankeyConfig {
|
|
|
14
14
|
type?: 'sankey';
|
|
15
15
|
data: SankeyDataItem[];
|
|
16
16
|
nodeAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
17
|
-
theme?:
|
|
17
|
+
theme?: VisualizationTheme;
|
|
18
18
|
title?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
palette?: string[];
|
|
22
|
-
};
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
style?: ThemeStyle;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* SankeyInstance represents a sankey chart instance with render and destroy methods.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
import { Chart } from '@antv/g2';
|
|
2
|
-
import { getThemeObject
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* SankeyDataItem is the type for each data item in the sankey chart.
|
|
@@ -57,8 +63,9 @@ export var Sankey = function Sankey(options) {
|
|
|
57
63
|
_config$theme = config.theme,
|
|
58
64
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
59
65
|
title = config.title,
|
|
66
|
+
subtitle = config.subtitle,
|
|
60
67
|
_config$style = config.style,
|
|
61
|
-
|
|
68
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
62
69
|
|
|
63
70
|
// Clean up previous chart if exists
|
|
64
71
|
if (chart) {
|
|
@@ -66,7 +73,10 @@ export var Sankey = function Sankey(options) {
|
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
// Get colors from style.palette or theme defaults
|
|
69
|
-
var
|
|
76
|
+
var appearance = getThemeObject('sankey', theme, localStyle);
|
|
77
|
+
var rendererTheme = appearance.theme;
|
|
78
|
+
var colors = rendererTheme.category10;
|
|
79
|
+
var sankeyStyle = appearance.mark.sankey;
|
|
70
80
|
|
|
71
81
|
// Create chart
|
|
72
82
|
chart = new Chart({
|
|
@@ -97,21 +107,21 @@ export var Sankey = function Sankey(options) {
|
|
|
97
107
|
nodeAlign: nodeAlign,
|
|
98
108
|
nodePadding: 0.01
|
|
99
109
|
},
|
|
100
|
-
title: title
|
|
110
|
+
title: title ? {
|
|
111
|
+
title: title,
|
|
112
|
+
subtitle: subtitle
|
|
113
|
+
} : '',
|
|
101
114
|
scale: {
|
|
102
115
|
color: {
|
|
103
116
|
range: colors
|
|
104
117
|
}
|
|
105
118
|
},
|
|
106
|
-
style: {
|
|
119
|
+
style: _objectSpread({
|
|
107
120
|
labelSpacing: 2,
|
|
108
121
|
nodeLineWidth: 1,
|
|
109
122
|
linkFillOpacity: 0.3
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
viewFill: style.backgroundColor
|
|
113
|
-
} : undefined,
|
|
114
|
-
theme: getThemeObject(theme),
|
|
123
|
+
}, sankeyStyle),
|
|
124
|
+
theme: rendererTheme,
|
|
115
125
|
legend: false,
|
|
116
126
|
tooltip: false
|
|
117
127
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
4
4
|
*/
|
|
@@ -14,13 +14,11 @@ export interface ScatterConfig {
|
|
|
14
14
|
type?: 'scatter';
|
|
15
15
|
data: ScatterDataItem[];
|
|
16
16
|
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
17
18
|
axisXTitle?: string;
|
|
18
19
|
axisYTitle?: string;
|
|
19
20
|
theme?: VisualizationTheme;
|
|
20
|
-
style?:
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
23
|
-
};
|
|
21
|
+
style?: ThemeStyle;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* ScatterInstance represents a scatter chart instance with render and destroy methods.
|
|
@@ -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 { getCartesianAxis, getChartAnimation, getPointHighlightState } from "../../util";
|
|
13
|
+
import { getColorLegend } from "../../util/components";
|
|
14
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* ScatterDataItem is the type for each data item in the scatter chart.
|
|
@@ -62,10 +68,11 @@ export var Scatter = function Scatter(options) {
|
|
|
62
68
|
_config$theme = config.theme,
|
|
63
69
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
64
70
|
title = config.title,
|
|
71
|
+
subtitle = config.subtitle,
|
|
65
72
|
axisXTitle = config.axisXTitle,
|
|
66
73
|
axisYTitle = config.axisYTitle,
|
|
67
74
|
_config$style = config.style,
|
|
68
|
-
|
|
75
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
69
76
|
|
|
70
77
|
// Clean up previous chart if exists
|
|
71
78
|
if (chart) {
|
|
@@ -73,11 +80,19 @@ export var Scatter = function Scatter(options) {
|
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
// Get colors from style.palette or theme defaults
|
|
76
|
-
var colors = normalizePalette(style.palette, theme);
|
|
77
|
-
var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
|
|
78
|
-
|
|
79
|
-
// Check if data has group field
|
|
80
83
|
var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
|
|
84
|
+
var appearance = getThemeObject('scatter', theme, localStyle);
|
|
85
|
+
var rendererTheme = appearance.theme;
|
|
86
|
+
var pointStyle = _objectSpread({
|
|
87
|
+
shape: 'point',
|
|
88
|
+
size: CHART_STYLE_DEFAULTS.scatterPointSize,
|
|
89
|
+
lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
90
|
+
fillOpacity: 0.88,
|
|
91
|
+
stroke: rendererTheme.view.viewFill
|
|
92
|
+
}, appearance.mark.point);
|
|
93
|
+
var colors = rendererTheme.category10;
|
|
94
|
+
var pointSize = pointStyle.size,
|
|
95
|
+
pointMark = _objectWithoutProperties(pointStyle, _excluded);
|
|
81
96
|
|
|
82
97
|
// Create chart
|
|
83
98
|
chart = new Chart({
|
|
@@ -102,8 +117,7 @@ export var Scatter = function Scatter(options) {
|
|
|
102
117
|
x: 'x',
|
|
103
118
|
y: 'y',
|
|
104
119
|
color: 'group',
|
|
105
|
-
|
|
106
|
-
size: CHART_STYLE_DEFAULTS.scatterPointSize
|
|
120
|
+
size: pointSize
|
|
107
121
|
};
|
|
108
122
|
scaleConfig.color = {
|
|
109
123
|
range: colors
|
|
@@ -112,8 +126,7 @@ export var Scatter = function Scatter(options) {
|
|
|
112
126
|
encode = {
|
|
113
127
|
x: 'x',
|
|
114
128
|
y: 'y',
|
|
115
|
-
|
|
116
|
-
size: CHART_STYLE_DEFAULTS.scatterPointSize
|
|
129
|
+
size: pointSize
|
|
117
130
|
};
|
|
118
131
|
}
|
|
119
132
|
|
|
@@ -124,7 +137,10 @@ export var Scatter = function Scatter(options) {
|
|
|
124
137
|
animate: getChartAnimation(hasRendered, 'fadeIn'),
|
|
125
138
|
type: 'point',
|
|
126
139
|
data: data,
|
|
127
|
-
title: title
|
|
140
|
+
title: title ? {
|
|
141
|
+
title: title,
|
|
142
|
+
subtitle: subtitle
|
|
143
|
+
} : '',
|
|
128
144
|
encode: encode,
|
|
129
145
|
legend: getColorLegend(hasGroupField),
|
|
130
146
|
scale: scaleConfig,
|
|
@@ -132,11 +148,7 @@ export var Scatter = function Scatter(options) {
|
|
|
132
148
|
axisXTitle: axisXTitle,
|
|
133
149
|
axisYTitle: axisYTitle
|
|
134
150
|
}),
|
|
135
|
-
style: _objectSpread({
|
|
136
|
-
lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
137
|
-
fillOpacity: 0.88,
|
|
138
|
-
stroke: backgroundColor
|
|
139
|
-
}, !hasGroupField ? {
|
|
151
|
+
style: _objectSpread(_objectSpread({}, pointMark), !hasGroupField ? {
|
|
140
152
|
fill: colors[0]
|
|
141
153
|
} : {}),
|
|
142
154
|
// A same-color stroke enlarges the rendered path without changing its transform or
|
|
@@ -156,12 +168,11 @@ export var Scatter = function Scatter(options) {
|
|
|
156
168
|
},
|
|
157
169
|
interaction: {
|
|
158
170
|
tooltip: true,
|
|
159
|
-
elementHighlight:
|
|
171
|
+
elementHighlight: {
|
|
172
|
+
delay: CHART_STYLE_DEFAULTS.interactionDelay
|
|
173
|
+
}
|
|
160
174
|
},
|
|
161
|
-
|
|
162
|
-
viewFill: backgroundColor
|
|
163
|
-
} : undefined,
|
|
164
|
-
theme: getThemeObject(theme)
|
|
175
|
+
theme: rendererTheme
|
|
165
176
|
};
|
|
166
177
|
chart.options(chartOptions);
|
|
167
178
|
chart.render();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Text } from '@antv/t8';
|
|
2
|
-
import {
|
|
2
|
+
import { getThemeObject } from "../../theme/summary";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* SummaryConfig is a T8 Syntax string for narrative text visualization.
|
|
@@ -38,10 +38,8 @@ import { getBackgroundColor } from "../../util/theme";
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export var Summary = function Summary(options) {
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
theme = _options$theme === void 0 ? 'light' : _options$theme;
|
|
44
|
-
if (theme === 'academy' || theme === 'default') theme = 'light';
|
|
41
|
+
var appearance = getThemeObject('summary', options.theme);
|
|
42
|
+
var theme = appearance.theme;
|
|
45
43
|
var container = typeof options.container === 'string' ? document.querySelector(options.container) : options.container;
|
|
46
44
|
if (!container) {
|
|
47
45
|
throw new Error('Container not found');
|
|
@@ -74,11 +72,11 @@ export var Summary = function Summary(options) {
|
|
|
74
72
|
text = new Text(wrapper);
|
|
75
73
|
|
|
76
74
|
// Set background color and padding on the wrapper
|
|
77
|
-
wrapper.style.backgroundColor = activeTheme
|
|
75
|
+
wrapper.style.backgroundColor = appearance.backgrounds[activeTheme];
|
|
78
76
|
wrapper.style.padding = '16px';
|
|
79
77
|
|
|
80
78
|
// Set theme and render syntax
|
|
81
|
-
text.theme(activeTheme);
|
|
79
|
+
text.theme(activeTheme, appearance.summary);
|
|
82
80
|
text.render(cleanedSyntax.trim());
|
|
83
81
|
};
|
|
84
82
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* TableConfig defines the configuration for rendering the table.
|
|
4
4
|
*/
|
|
@@ -6,7 +6,9 @@ export interface TableConfig {
|
|
|
6
6
|
type?: 'table';
|
|
7
7
|
data: Record<string, any>[];
|
|
8
8
|
title?: string;
|
|
9
|
-
|
|
9
|
+
subtitle?: string;
|
|
10
|
+
theme?: VisualizationTheme;
|
|
11
|
+
style?: ThemeStyle;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* TableInstance represents a table instance with render and destroy methods.
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
1
4
|
import { measureText } from 'measury';
|
|
5
|
+
import { getThemeObject } from "../../theme/table";
|
|
6
|
+
import { escapeHtml } from "../../util/html";
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* TableConfig defines the configuration for rendering the table.
|
|
@@ -14,7 +19,7 @@ var CELL_PADDING = 16; // 8px * 2
|
|
|
14
19
|
var MIN_WIDTH_MULTIPLIER = 1.1;
|
|
15
20
|
|
|
16
21
|
// CSS styles for the table component
|
|
17
|
-
var TABLE_STYLES = "\n .".concat(SCOPE_ID, " {\n font-family: ").concat(FONT_FAMILY, ";\n overflow: auto;\n height: 100%;\n padding: 16px;\n }\n\n .").concat(SCOPE_ID, " .table-title {\n font-size: 16px;\n font-weight: 500;\n margin-
|
|
22
|
+
var TABLE_STYLES = "\n .".concat(SCOPE_ID, " {\n font-family: ").concat(FONT_FAMILY, ";\n overflow: auto;\n height: 100%;\n padding: 16px;\n }\n\n .").concat(SCOPE_ID, " .table-heading {\n margin-bottom: 12px;\n }\n\n .").concat(SCOPE_ID, " .table-title {\n font-size: 16px;\n font-weight: 500;\n color: #1d2129;\n }\n\n .").concat(SCOPE_ID, " .table-subtitle {\n margin-top: 4px;\n font-size: 12px;\n color: #667085;\n }\n\n .").concat(SCOPE_ID, " .table-empty {\n padding: 20px;\n text-align: center;\n color: #999;\n }\n\n .").concat(SCOPE_ID, " table {\n border-collapse: separate;\n border-spacing: 0;\n background: #fff;\n border-radius: 8px;\n overflow: hidden;\n }\n\n .").concat(SCOPE_ID, " th,\n .").concat(SCOPE_ID, " td {\n border-bottom: 1px solid #f0f0f0;\n padding: 8px;\n text-align: left;\n font-size: 14px;\n color: #333;\n white-space: nowrap;\n }\n\n .").concat(SCOPE_ID, " th {\n background: #f5f5f5;\n font-weight: 600;\n color: #000000e0;\n position: relative;\n }\n\n .").concat(SCOPE_ID, " th:not(:last-child)::after {\n content: '';\n position: absolute;\n top: 25%;\n right: 0;\n width: 1px;\n height: 50%;\n background: #e0e0e0;\n }\n\n .").concat(SCOPE_ID, " tr {\n transition: background 0.2s;\n }\n\n .").concat(SCOPE_ID, " tbody tr:hover {\n background: #f5f5f5;\n cursor: pointer;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] {\n background: #000;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] .table-title {\n color: #ffffffd9;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] .table-subtitle {\n color: #ffffffa6;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] table {\n background: #141414;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th,\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] td {\n border-bottom: 1px solid #303030;\n color: #ffffffd9;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th {\n background: #1f1f1f;\n color: #ffffffa6;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th:not(:last-child)::after {\n background: #303030;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] tbody tr:hover {\n background: #1f1f1f;\n }\n");
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Calculate the minimum width needed for a table based on its data.
|
|
@@ -65,6 +70,31 @@ var injectStyles = function injectStyles() {
|
|
|
65
70
|
styleElement.textContent = TABLE_STYLES;
|
|
66
71
|
document.head.appendChild(styleElement);
|
|
67
72
|
};
|
|
73
|
+
var applyDomStyle = function applyDomStyle(elements, style) {
|
|
74
|
+
if (!elements) return;
|
|
75
|
+
var targets = elements instanceof Element ? [elements] : elements;
|
|
76
|
+
var _iterator = _createForOfIteratorHelper(targets),
|
|
77
|
+
_step;
|
|
78
|
+
try {
|
|
79
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
80
|
+
var target = _step.value;
|
|
81
|
+
Object.assign(target.style, style);
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
_iterator.e(err);
|
|
85
|
+
} finally {
|
|
86
|
+
_iterator.f();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var applyResolvedTableStyle = function applyResolvedTableStyle(wrapper, style) {
|
|
90
|
+
applyDomStyle(wrapper.querySelector('.table-title'), style.title);
|
|
91
|
+
applyDomStyle(wrapper.querySelector('.table-subtitle'), style.subtitle);
|
|
92
|
+
applyDomStyle(wrapper.querySelectorAll('th'), style.header);
|
|
93
|
+
applyDomStyle(wrapper.querySelectorAll('td'), style.cell);
|
|
94
|
+
var borderStyle = style.border;
|
|
95
|
+
applyDomStyle(wrapper.querySelector('table'), borderStyle.table);
|
|
96
|
+
applyDomStyle(wrapper.querySelectorAll('th, td'), borderStyle.cell);
|
|
97
|
+
};
|
|
68
98
|
|
|
69
99
|
/**
|
|
70
100
|
* Table component using pure JavaScript.
|
|
@@ -105,8 +135,13 @@ export var Table = function Table(options) {
|
|
|
105
135
|
var _config$data = config.data,
|
|
106
136
|
data = _config$data === void 0 ? [] : _config$data,
|
|
107
137
|
title = config.title,
|
|
138
|
+
subtitle = config.subtitle,
|
|
108
139
|
_config$theme = config.theme,
|
|
109
|
-
theme = _config$theme === void 0 ? chartTheme : _config$theme
|
|
140
|
+
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
141
|
+
_config$style = config.style,
|
|
142
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
143
|
+
var style = getThemeObject('table', theme, localStyle);
|
|
144
|
+
var rendererTheme = style.theme;
|
|
110
145
|
|
|
111
146
|
// Inject styles if not already present
|
|
112
147
|
injectStyles();
|
|
@@ -119,13 +154,16 @@ export var Table = function Table(options) {
|
|
|
119
154
|
// Create wrapper element
|
|
120
155
|
tableWrapper = document.createElement('div');
|
|
121
156
|
tableWrapper.className = SCOPE_ID;
|
|
122
|
-
if (
|
|
157
|
+
if (rendererTheme === 'dark') {
|
|
123
158
|
tableWrapper.setAttribute('data-theme', 'dark');
|
|
124
159
|
}
|
|
160
|
+
if (style.backgroundColor) tableWrapper.style.backgroundColor = style.backgroundColor;
|
|
161
|
+
var titleHTML = title || subtitle ? "<div class=\"table-heading\">\n ".concat(title ? "<div class=\"table-title\">".concat(escapeHtml(title), "</div>") : '', "\n ").concat(subtitle ? "<div class=\"table-subtitle\">".concat(escapeHtml(subtitle), "</div>") : '', "\n </div>") : '';
|
|
125
162
|
|
|
126
163
|
// Handle empty data case
|
|
127
164
|
if (data.length === 0) {
|
|
128
|
-
tableWrapper.innerHTML = "\n ".concat(
|
|
165
|
+
tableWrapper.innerHTML = "\n ".concat(titleHTML, "\n <div class=\"table-empty\">No data available</div>\n ");
|
|
166
|
+
applyResolvedTableStyle(tableWrapper, style);
|
|
129
167
|
container.appendChild(tableWrapper);
|
|
130
168
|
return;
|
|
131
169
|
}
|
|
@@ -137,17 +175,16 @@ export var Table = function Table(options) {
|
|
|
137
175
|
var minWidth = calculateTableMinWidth(data, columns);
|
|
138
176
|
// Ensure a minimum width for columns
|
|
139
177
|
minWidth = Math.max(minWidth, columns.length * 100);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var headerHTML = columns.map(function (col) {
|
|
143
|
-
return "<th>".concat(col, "</th>");
|
|
178
|
+
var headerHTML = columns.map(function (column) {
|
|
179
|
+
return "<th>".concat(escapeHtml(column), "</th>");
|
|
144
180
|
}).join('');
|
|
145
181
|
var bodyHTML = data.map(function (row) {
|
|
146
|
-
return "<tr>".concat(columns.map(function (
|
|
147
|
-
return "<td>".concat(row[
|
|
182
|
+
return "<tr>".concat(columns.map(function (column) {
|
|
183
|
+
return "<td>".concat(escapeHtml(row[column]), "</td>");
|
|
148
184
|
}).join(''), "</tr>");
|
|
149
185
|
}).join('');
|
|
150
|
-
tableWrapper.innerHTML = "\n ".concat(
|
|
186
|
+
tableWrapper.innerHTML = "\n ".concat(titleHTML, "\n <table style=\"min-width: ").concat(minWidth, "px;\">\n <thead><tr>").concat(headerHTML, "</tr></thead>\n <tbody>").concat(bodyHTML, "</tbody>\n </table>\n ");
|
|
187
|
+
applyResolvedTableStyle(tableWrapper, style);
|
|
151
188
|
container.appendChild(tableWrapper);
|
|
152
189
|
};
|
|
153
190
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* TreemapDataItem is the type for each data item in the treemap chart.
|
|
4
4
|
*/
|
|
@@ -13,12 +13,10 @@ export type TreemapDataItem = {
|
|
|
13
13
|
export interface TreemapConfig {
|
|
14
14
|
type?: 'treemap';
|
|
15
15
|
data: TreemapDataItem[];
|
|
16
|
-
theme?:
|
|
16
|
+
theme?: VisualizationTheme;
|
|
17
17
|
title?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
palette?: string[];
|
|
21
|
-
};
|
|
18
|
+
subtitle?: string;
|
|
19
|
+
style?: ThemeStyle;
|
|
22
20
|
}
|
|
23
21
|
/**
|
|
24
22
|
* TreemapInstance represents a treemap chart instance with render and destroy methods.
|
|
@@ -5,7 +5,7 @@ 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
9
|
|
|
10
10
|
/**
|
|
11
11
|
* TreemapDataItem is the type for each data item in the treemap chart.
|
|
@@ -74,8 +74,9 @@ export var Treemap = function Treemap(options) {
|
|
|
74
74
|
_config$theme = config.theme,
|
|
75
75
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
76
76
|
title = config.title,
|
|
77
|
+
subtitle = config.subtitle,
|
|
77
78
|
_config$style = config.style,
|
|
78
|
-
|
|
79
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
79
80
|
|
|
80
81
|
// Clean up previous chart if exists
|
|
81
82
|
if (chart) {
|
|
@@ -83,7 +84,10 @@ export var Treemap = function Treemap(options) {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
// Get colors from style.palette or theme defaults
|
|
86
|
-
var
|
|
87
|
+
var appearance = getThemeObject('treemap', theme, localStyle);
|
|
88
|
+
var rendererTheme = appearance.theme;
|
|
89
|
+
var colors = rendererTheme.category10;
|
|
90
|
+
var treemapStyle = appearance.mark.treemap;
|
|
87
91
|
|
|
88
92
|
// Create chart
|
|
89
93
|
chart = new Chart({
|
|
@@ -106,7 +110,10 @@ export var Treemap = function Treemap(options) {
|
|
|
106
110
|
children: data
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
|
-
title: title
|
|
113
|
+
title: title ? {
|
|
114
|
+
title: title,
|
|
115
|
+
subtitle: subtitle
|
|
116
|
+
} : '',
|
|
110
117
|
layout: {
|
|
111
118
|
tile: 'treemapBinary',
|
|
112
119
|
paddingInner: 2
|
|
@@ -114,10 +121,11 @@ export var Treemap = function Treemap(options) {
|
|
|
114
121
|
encode: {
|
|
115
122
|
value: 'value'
|
|
116
123
|
},
|
|
117
|
-
style: {
|
|
124
|
+
style: _objectSpread({
|
|
118
125
|
fillOpacity: 0.8,
|
|
119
|
-
labelFontSize: 10
|
|
120
|
-
|
|
126
|
+
labelFontSize: 10,
|
|
127
|
+
labelFill: rendererTheme.label.fill
|
|
128
|
+
}, treemapStyle),
|
|
121
129
|
legend: false,
|
|
122
130
|
tooltip: {
|
|
123
131
|
items: [function (d) {
|
|
@@ -128,10 +136,7 @@ export var Treemap = function Treemap(options) {
|
|
|
128
136
|
};
|
|
129
137
|
}]
|
|
130
138
|
},
|
|
131
|
-
|
|
132
|
-
viewFill: style.backgroundColor
|
|
133
|
-
} : undefined,
|
|
134
|
-
theme: getThemeObject(theme),
|
|
139
|
+
theme: rendererTheme,
|
|
135
140
|
scale: _objectSpread({}, colors.length > 0 ? {
|
|
136
141
|
color: {
|
|
137
142
|
range: colors
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* VennDataItem is the type for each data item in the venn chart.
|
|
4
4
|
*/
|
|
@@ -14,12 +14,10 @@ export type VennDataItem = {
|
|
|
14
14
|
export interface VennConfig {
|
|
15
15
|
type?: 'venn';
|
|
16
16
|
data: VennDataItem[];
|
|
17
|
-
theme?:
|
|
17
|
+
theme?: VisualizationTheme;
|
|
18
18
|
title?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
palette?: string[];
|
|
22
|
-
};
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
style?: ThemeStyle;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* VennInstance represents a venn chart instance with render and destroy methods.
|