sea-chart 2.0.1 → 2.0.2-alpha.3
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/dist/components/cell-factory/SimpleCellFormatter.js +1 -1
- package/dist/components/cell-factory/link-content.js +4 -4
- package/dist/components/color-picker/index.js +1 -1
- package/dist/components/color-popover/color-rules/color-rule.js +1 -1
- package/dist/components/color-popover/color-rules/index.js +1 -1
- package/dist/components/color-popover/color-rules-popover.js +6 -6
- package/dist/components/color-popover/color-selector-popover.js +2 -2
- package/dist/components/color-setting/color-group-selector.js +1 -1
- package/dist/components/common-add-tool/index.js +2 -2
- package/dist/components/data-process-setter/hide-column-setter.js +1 -1
- package/dist/components/data-process-setter/sort-setter.js +2 -2
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +4 -4
- package/dist/components/icon/index.js +2 -2
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +1 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +1 -1
- package/dist/components/popover/sort-popover/sort-popover.js +1 -1
- package/dist/components/row-card/row-card-header-cell.js +2 -2
- package/dist/components/row-card/row-card-header.js +1 -1
- package/dist/components/row-card/row-card-item.js +2 -2
- package/dist/components/row-card/row-card.js +2 -2
- package/dist/components/statistic-record-dialog/index.js +1 -1
- package/dist/components/types-dialog/index.js +7 -7
- package/dist/context.js +2 -2
- package/dist/services/map-json.js +4 -4
- package/dist/settings/basic-number-card/style-settings.js +1 -1
- package/dist/settings/index.js +3 -3
- package/dist/settings/map-settings/map-style-settings.js +1 -1
- package/dist/settings/stacks-settings/index.js +1 -1
- package/dist/settings/style-settings.js +1 -1
- package/dist/settings/table-settings/data-settings.js +1 -1
- package/dist/settings/trend-settings/style-setting.js +2 -2
- package/dist/settings/widgets/chart-type/index.js +3 -3
- package/dist/settings/widgets/date-summary-item.js +2 -2
- package/dist/settings/widgets/numeric-summary-item.js +2 -2
- package/dist/settings/widgets/summary-settings.js +2 -2
- package/dist/settings/widgets/switch/index.js +1 -1
- package/dist/settings/widgets/y-axis-group-settings.js +1 -1
- package/dist/utils/chart-utils/base-utils.js +7 -7
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +1 -1
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +1 -1
- package/dist/utils/chart-utils/sql-statistics-utils.js +9 -9
- package/dist/utils/collaborator-utils.js +1 -1
- package/dist/utils/collaborator.js +2 -2
- package/dist/utils/column-utils.js +12 -12
- package/dist/utils/common-utils.js +1 -1
- package/dist/utils/date-translate.js +1 -1
- package/dist/utils/object-utils.js +1 -1
- package/dist/utils/options-utils.js +2 -2
- package/dist/utils/row-record-utils.js +2 -2
- package/dist/utils/sql/chart-data-sql.js +58 -58
- package/dist/utils/sql/column-2-sql-column.js +18 -18
- package/dist/view/index.js +2 -5
- package/dist/view/title/index.js +2 -2
- package/dist/view/wrapper/bar-group.js +22 -31
- package/dist/view/wrapper/bar.js +168 -95
- package/dist/view/wrapper/basic-number-card.js +8 -8
- package/dist/view/wrapper/chart-component.js +17 -54
- package/dist/view/wrapper/index.js +2 -231
- package/dist/view/wrapper/table/index.js +1 -1
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +3 -3
- package/dist/view/wrapper/table/pivot-table-display-name.js +1 -1
- package/dist/view/wrapper/table/two-dimension-table.js +8 -8
- package/dist/view/wrapper/table-element/components/formatter.js +2 -2
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +1 -1
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +17 -17
- package/dist/view/wrapper/table-element/components/link-formatter.js +17 -17
- package/dist/view/wrapper/table-element/components/record.js +3 -3
- package/dist/view/wrapper/table-element/components/records.js +4 -4
- package/dist/view/wrapper/table-element/components/utils.js +1 -1
- package/dist/view/wrapper/trend.js +18 -18
- package/package.json +5 -11
- package/dist/utils/custom-g2.js +0 -684
- package/dist/view/wrapper/area.js +0 -282
- package/dist/view/wrapper/bar-custom.js +0 -239
- package/dist/view/wrapper/combination.js +0 -728
- package/dist/view/wrapper/compare.js +0 -383
- package/dist/view/wrapper/completeness.js +0 -174
- package/dist/view/wrapper/dashboard.js +0 -179
- package/dist/view/wrapper/funnel.js +0 -206
- package/dist/view/wrapper/heat-map.js +0 -434
- package/dist/view/wrapper/horizontal-bar-group.js +0 -226
- package/dist/view/wrapper/horizontal-bar.js +0 -175
- package/dist/view/wrapper/horizontal-component.js +0 -89
- package/dist/view/wrapper/line-group.js +0 -219
- package/dist/view/wrapper/line.js +0 -222
- package/dist/view/wrapper/map.js +0 -368
- package/dist/view/wrapper/mirror.js +0 -218
- package/dist/view/wrapper/pie.js +0 -253
- package/dist/view/wrapper/ring.js +0 -328
- package/dist/view/wrapper/scatter.js +0 -140
- package/dist/view/wrapper/treemap.js +0 -206
- package/dist/view/wrapper/world-map.js +0 -413
- package/dist/view/wrapper/wrappers-d3/bar.js +0 -262
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _constants = require("../../constants");
|
|
11
|
-
var _utils = require("../../utils");
|
|
12
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
13
|
-
var _colorRules = require("../../constants/color-rules");
|
|
14
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
15
|
-
class Ring extends _chartComponent.default {
|
|
16
|
-
constructor(props) {
|
|
17
|
-
var _this;
|
|
18
|
-
super(props);
|
|
19
|
-
_this = this;
|
|
20
|
-
this.createChart = () => {
|
|
21
|
-
const {
|
|
22
|
-
canvasStyle
|
|
23
|
-
} = this.props;
|
|
24
|
-
this.initChart(this.container, canvasStyle, 0);
|
|
25
|
-
};
|
|
26
|
-
this.destroyChart = () => {
|
|
27
|
-
this.chart.destroy();
|
|
28
|
-
this.chart = null;
|
|
29
|
-
};
|
|
30
|
-
this.clearChart = () => {
|
|
31
|
-
this.chart.annotation().clear(true);
|
|
32
|
-
this.chart.clear(true);
|
|
33
|
-
};
|
|
34
|
-
this.drawChart = () => {
|
|
35
|
-
let {
|
|
36
|
-
result: data,
|
|
37
|
-
chart,
|
|
38
|
-
tables,
|
|
39
|
-
globalTheme,
|
|
40
|
-
chartColorTheme,
|
|
41
|
-
summaryColumn,
|
|
42
|
-
customRender
|
|
43
|
-
} = this.props;
|
|
44
|
-
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
45
|
-
const radius = 0.7;
|
|
46
|
-
const innerRadius = 0.8;
|
|
47
|
-
if (data.length === 0) return;
|
|
48
|
-
this.sum = data.total;
|
|
49
|
-
this.chart.coordinate('theta', {
|
|
50
|
-
radius,
|
|
51
|
-
innerRadius
|
|
52
|
-
});
|
|
53
|
-
const {
|
|
54
|
-
show_legend,
|
|
55
|
-
display_label,
|
|
56
|
-
label_position,
|
|
57
|
-
label_font_size,
|
|
58
|
-
summary_method,
|
|
59
|
-
label_format,
|
|
60
|
-
color_theme
|
|
61
|
-
} = chart.config;
|
|
62
|
-
const colorTheme = _utils.BaseUtils.getCurrentTheme(chartColorTheme);
|
|
63
|
-
const useSingleSelectColumnColor = color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
64
|
-
const {
|
|
65
|
-
data: newData,
|
|
66
|
-
colorMap,
|
|
67
|
-
total
|
|
68
|
-
} = _utils.BaseUtils.formatPieChartData(data, chart, tables, colorTheme, useSingleSelectColumnColor);
|
|
69
|
-
if (!Array.isArray(newData)) return;
|
|
70
|
-
this.sum = total;
|
|
71
|
-
this.loadData(newData);
|
|
72
|
-
this.chart.on('interval:click', e => {
|
|
73
|
-
this.props.toggleRecords(e.data.data);
|
|
74
|
-
});
|
|
75
|
-
if (show_legend) {
|
|
76
|
-
this.setLegendForTheta('name', theme, 'right');
|
|
77
|
-
} else {
|
|
78
|
-
this.chart.legend(false);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
82
|
-
this.chart.scale({
|
|
83
|
-
value: {
|
|
84
|
-
nice: false
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
const labelWidthMap = {
|
|
88
|
-
[_constants.CHART_LABEL_FORMATS[0]]: 30,
|
|
89
|
-
[_constants.CHART_LABEL_FORMATS[1]]: 20,
|
|
90
|
-
[_constants.CHART_LABEL_FORMATS[2]]: 40
|
|
91
|
-
};
|
|
92
|
-
const currntLabelWidth = labelWidthMap[label_format];
|
|
93
|
-
let elementWidth = this.chart.height * radius * (1 - innerRadius) / 2;
|
|
94
|
-
const isInnerLabel = !label_position || label_position === _constants.CHART_LABEL_POSITIONS[0];
|
|
95
|
-
this.isInnerLabel = isInnerLabel;
|
|
96
|
-
let innerLabelOffset;
|
|
97
|
-
let outerLabelOffset = 20;
|
|
98
|
-
if (elementWidth < currntLabelWidth) {
|
|
99
|
-
innerLabelOffset = '0%';
|
|
100
|
-
} else {
|
|
101
|
-
// label position: elementWidth - labelWith / 2
|
|
102
|
-
innerLabelOffset = -(elementWidth - currntLabelWidth) / 2;
|
|
103
|
-
}
|
|
104
|
-
this.innerLabelOffset = innerLabelOffset;
|
|
105
|
-
this.outerLabelOffset = outerLabelOffset;
|
|
106
|
-
this.currentChart = this.chart.interval().adjust('stack').position('value').color('name', name => {
|
|
107
|
-
return colorMap[name.trim()];
|
|
108
|
-
}).label('value*percent', (value, percent) => {
|
|
109
|
-
const displayValue = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
110
|
-
return {
|
|
111
|
-
content: this.getLabel(displayValue, percent)
|
|
112
|
-
};
|
|
113
|
-
}, {
|
|
114
|
-
offset: isInnerLabel ? innerLabelOffset : 20,
|
|
115
|
-
style: {
|
|
116
|
-
fill: theme.ringLabelColor,
|
|
117
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
118
|
-
...this.labelStroke
|
|
119
|
-
}
|
|
120
|
-
}).tooltip('name*value*percent', (name, value, percent) => {
|
|
121
|
-
let title = name;
|
|
122
|
-
if (!name || name === 'undefined' || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
123
|
-
title = _intl.default.get('Empty');
|
|
124
|
-
} else if (name === '_Others') {
|
|
125
|
-
title = _intl.default.get('Others');
|
|
126
|
-
}
|
|
127
|
-
const displayValue = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
128
|
-
return {
|
|
129
|
-
name: title,
|
|
130
|
-
value: display_label ? this.getLabel(displayValue, percent) : displayValue
|
|
131
|
-
};
|
|
132
|
-
}).state({
|
|
133
|
-
active: {
|
|
134
|
-
style: {
|
|
135
|
-
fillOpacity: 0.7,
|
|
136
|
-
border: 'none',
|
|
137
|
-
stroke: 0
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
// .shape('withGap')
|
|
142
|
-
.style('value', value => {
|
|
143
|
-
return {
|
|
144
|
-
lineWidth: 2,
|
|
145
|
-
stroke: '#fff'
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
this.setToolTipForTheta();
|
|
149
|
-
this.setAnnotation({
|
|
150
|
-
name: _intl.default.get('Total'),
|
|
151
|
-
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, this.sum, summary_method)
|
|
152
|
-
}, '', theme);
|
|
153
|
-
this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, {
|
|
154
|
-
summaryColumn,
|
|
155
|
-
summaryMethod: summary_method
|
|
156
|
-
}));
|
|
157
|
-
this.chart.on('interval:mouseleave', evt => this.onLeaveRingChart(evt, {
|
|
158
|
-
summaryColumn,
|
|
159
|
-
summaryMethod: summary_method
|
|
160
|
-
}));
|
|
161
|
-
this.chart.interaction('element-highlight');
|
|
162
|
-
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
163
|
-
requestAnimationFrame(() => {
|
|
164
|
-
this.chart.render();
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
this.getLabel = (value, percent) => {
|
|
168
|
-
const {
|
|
169
|
-
display_label,
|
|
170
|
-
label_format
|
|
171
|
-
} = this.props.chart.config;
|
|
172
|
-
if (!display_label || !value) {
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
switch (label_format) {
|
|
176
|
-
case _constants.CHART_LABEL_FORMATS[0]:
|
|
177
|
-
return percent;
|
|
178
|
-
case _constants.CHART_LABEL_FORMATS[1]:
|
|
179
|
-
return value;
|
|
180
|
-
case _constants.CHART_LABEL_FORMATS[2]:
|
|
181
|
-
return `${value} (${percent})`;
|
|
182
|
-
default:
|
|
183
|
-
return percent;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
this.setAnnotation = function (content) {
|
|
187
|
-
let {
|
|
188
|
-
summaryColumn,
|
|
189
|
-
summaryMethod
|
|
190
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
191
|
-
let theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants.CHART_THEME_COLOR['light'];
|
|
192
|
-
let name = content.name;
|
|
193
|
-
if (!name || name === 'undefined') {
|
|
194
|
-
name = _intl.default.get('Empty');
|
|
195
|
-
} else if (name === '_Others') {
|
|
196
|
-
name = _intl.default.get('Others');
|
|
197
|
-
}
|
|
198
|
-
_this.chart.annotation().text({
|
|
199
|
-
content: name,
|
|
200
|
-
position: ['50%', '50%'],
|
|
201
|
-
style: {
|
|
202
|
-
fontSize: theme.annotationFontSize,
|
|
203
|
-
fill: theme.annotationTitleFontColor,
|
|
204
|
-
fontWeight: '300',
|
|
205
|
-
textAlign: 'center'
|
|
206
|
-
},
|
|
207
|
-
offsetY: -10
|
|
208
|
-
}).text({
|
|
209
|
-
position: ['50%', '50%'],
|
|
210
|
-
content: summaryColumn ? _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, content.value, summaryMethod) : content.value,
|
|
211
|
-
style: {
|
|
212
|
-
fontSize: theme.annotationFontSize,
|
|
213
|
-
fill: theme.annotationValueFontColor,
|
|
214
|
-
textAlign: 'center'
|
|
215
|
-
},
|
|
216
|
-
offsetY: 20
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
this.onEnterRingChart = (evt, _ref) => {
|
|
220
|
-
let {
|
|
221
|
-
summaryColumn,
|
|
222
|
-
summaryMethod
|
|
223
|
-
} = _ref;
|
|
224
|
-
const {
|
|
225
|
-
label_font_size
|
|
226
|
-
} = this.props.chart.config;
|
|
227
|
-
const {
|
|
228
|
-
globalTheme
|
|
229
|
-
} = this.props;
|
|
230
|
-
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
231
|
-
const item = evt.data.data;
|
|
232
|
-
this.chart.annotation().clear(true);
|
|
233
|
-
this.currentChart.label('name*value*percent', (name, value, percent) => {
|
|
234
|
-
let displayValue;
|
|
235
|
-
displayValue = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summaryMethod);
|
|
236
|
-
return {
|
|
237
|
-
content: this.getLabel(displayValue, percent)
|
|
238
|
-
};
|
|
239
|
-
}, {
|
|
240
|
-
offset: this.isInnerLabel ? this.innerLabelOffset : this.outerLabelOffset,
|
|
241
|
-
style: {
|
|
242
|
-
fill: theme.ringLabelColor,
|
|
243
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
244
|
-
...this.labelStroke
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
this.setAnnotation(item, {
|
|
248
|
-
summaryColumn,
|
|
249
|
-
summaryMethod
|
|
250
|
-
}, theme);
|
|
251
|
-
this.chart.render(true);
|
|
252
|
-
};
|
|
253
|
-
this.onLeaveRingChart = (evt, _ref2) => {
|
|
254
|
-
let {
|
|
255
|
-
summaryColumn,
|
|
256
|
-
summaryMethod
|
|
257
|
-
} = _ref2;
|
|
258
|
-
const {
|
|
259
|
-
summary_method,
|
|
260
|
-
label_font_size
|
|
261
|
-
} = this.props.chart.config;
|
|
262
|
-
const {
|
|
263
|
-
globalTheme
|
|
264
|
-
} = this.props;
|
|
265
|
-
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
266
|
-
this.chart.annotation().clear(true);
|
|
267
|
-
this.currentChart.label('value*percent', (value, percent) => {
|
|
268
|
-
let displayValue = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
269
|
-
return {
|
|
270
|
-
content: this.getLabel(displayValue, percent)
|
|
271
|
-
};
|
|
272
|
-
}, {
|
|
273
|
-
offset: this.isInnerLabel ? this.innerLabelOffset : this.outerLabelOffset,
|
|
274
|
-
style: {
|
|
275
|
-
fill: theme.ringLabelColor,
|
|
276
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
277
|
-
...this.labelStroke
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
this.setAnnotation({
|
|
281
|
-
name: _intl.default.get('Total'),
|
|
282
|
-
value: this.sum
|
|
283
|
-
}, {
|
|
284
|
-
summaryColumn,
|
|
285
|
-
summaryMethod
|
|
286
|
-
}, theme);
|
|
287
|
-
this.chart.render(true);
|
|
288
|
-
};
|
|
289
|
-
this.sum = 0;
|
|
290
|
-
this.chart = null;
|
|
291
|
-
}
|
|
292
|
-
componentDidMount() {
|
|
293
|
-
this.createChart();
|
|
294
|
-
this.drawChart();
|
|
295
|
-
}
|
|
296
|
-
componentDidUpdate(prevProps) {
|
|
297
|
-
super.componentDidUpdate(prevProps);
|
|
298
|
-
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
299
|
-
this.chart && this.destroyChart();
|
|
300
|
-
this.sum = 0;
|
|
301
|
-
this.createChart();
|
|
302
|
-
this.drawChart();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
componentWillUnmount() {
|
|
306
|
-
this.chart && this.destroyChart();
|
|
307
|
-
}
|
|
308
|
-
render() {
|
|
309
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
310
|
-
className: "sea-chart-container",
|
|
311
|
-
ref: ref => this.container = ref
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
Ring.propTypes = {
|
|
316
|
-
canvasStyle: _propTypes.default.object,
|
|
317
|
-
chart: _propTypes.default.object,
|
|
318
|
-
groupbyColumn: _propTypes.default.object,
|
|
319
|
-
columnGroupbyColumn: _propTypes.default.object,
|
|
320
|
-
summaryColumn: _propTypes.default.object,
|
|
321
|
-
result: _propTypes.default.array,
|
|
322
|
-
tables: _propTypes.default.array,
|
|
323
|
-
globalTheme: _propTypes.default.string,
|
|
324
|
-
chartColorTheme: _propTypes.default.string,
|
|
325
|
-
toggleRecords: _propTypes.default.func,
|
|
326
|
-
customRender: _propTypes.default.func
|
|
327
|
-
};
|
|
328
|
-
var _default = exports.default = Ring;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Scatter = Scatter;
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _dtableUtils = require("dtable-utils");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
16
|
-
const chartComponent = new _chartComponent.default({});
|
|
17
|
-
function Scatter(_ref) {
|
|
18
|
-
let {
|
|
19
|
-
toggleRecords,
|
|
20
|
-
result: data,
|
|
21
|
-
chart,
|
|
22
|
-
tables,
|
|
23
|
-
globalTheme,
|
|
24
|
-
chartColorTheme
|
|
25
|
-
} = _ref;
|
|
26
|
-
const chartRef = (0, _react.useRef)(chartComponent);
|
|
27
|
-
chartRef.current.initLabelStroke(globalTheme);
|
|
28
|
-
const chartContainerRef = (0, _react.useRef)(null);
|
|
29
|
-
(0, _react.useEffect)(() => {
|
|
30
|
-
const currentChart = chartRef.current;
|
|
31
|
-
currentChart.isDestoryed = false;
|
|
32
|
-
|
|
33
|
-
// avoid closure trap
|
|
34
|
-
function createChart() {
|
|
35
|
-
const appendPadding = [0, 0, 0, 0];
|
|
36
|
-
currentChart.initChart(chartContainerRef.current, {
|
|
37
|
-
appendPadding
|
|
38
|
-
});
|
|
39
|
-
currentChart.chart.on('element:click', e => {
|
|
40
|
-
toggleRecords(e.data.data.original_value);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function drawChart() {
|
|
44
|
-
const newData = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
45
|
-
if (!Array.isArray(newData)) return;
|
|
46
|
-
currentChart.loadData(newData);
|
|
47
|
-
draw(newData);
|
|
48
|
-
currentChart.chart.render();
|
|
49
|
-
currentChart.renderAxisLabel(chart, tables);
|
|
50
|
-
}
|
|
51
|
-
function draw(data) {
|
|
52
|
-
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
53
|
-
const {
|
|
54
|
-
label_font_size,
|
|
55
|
-
x_axis_column_key,
|
|
56
|
-
y_axis_column_key,
|
|
57
|
-
table_id,
|
|
58
|
-
y_axis_show_value
|
|
59
|
-
} = chart.config;
|
|
60
|
-
const selectedTable = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
61
|
-
const selectedXAxisColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
|
|
62
|
-
const selectedYAxisColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, y_axis_column_key);
|
|
63
|
-
currentChart.drawLabels(data);
|
|
64
|
-
let currentIdx = 0;
|
|
65
|
-
let colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
66
|
-
const colorMap = data.reduce((acc, cur) => {
|
|
67
|
-
if (cur.groupby && !acc[cur.groupby]) {
|
|
68
|
-
acc[cur.groupby] = colors[currentIdx++ % colors.length];
|
|
69
|
-
}
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
72
|
-
|
|
73
|
-
// set Coord type
|
|
74
|
-
currentChart.chart.coordinate('rect');
|
|
75
|
-
currentChart.autoAdjustDataOptions(chart, data);
|
|
76
|
-
|
|
77
|
-
// need to set name as nice too , otherwise chart value will be wrong
|
|
78
|
-
currentChart.chart.scale({
|
|
79
|
-
name: {
|
|
80
|
-
nice: true
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// tooltip template
|
|
85
|
-
currentChart.chart.tooltip({
|
|
86
|
-
showTitle: false,
|
|
87
|
-
showCrosshairs: true,
|
|
88
|
-
crosshairs: {
|
|
89
|
-
type: 'xy'
|
|
90
|
-
},
|
|
91
|
-
itemTpl: '<li class="g2-tooltip-list-item" data-index={index} style="margin-bottom:4px;">' + '<span style="background-color:{color};" class="g2-tooltip-marker"></span>' + '{name}<br/>' + '{valueX}<br/>' + '{valueY}' + '</li>'
|
|
92
|
-
});
|
|
93
|
-
currentChart.chart.point().position('name*value').label(y_axis_show_value ? 'value' : false, {
|
|
94
|
-
style: {
|
|
95
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
96
|
-
fill: theme.labelColor,
|
|
97
|
-
...currentChart.labelStroke
|
|
98
|
-
}
|
|
99
|
-
}).color('groupby', groupby => {
|
|
100
|
-
if (groupby && groupby[0] === 'groupby') {
|
|
101
|
-
return colors[0];
|
|
102
|
-
}
|
|
103
|
-
return colorMap[groupby];
|
|
104
|
-
}).shape('circle').tooltip('groupby*name*value', (groupby, name, value) => {
|
|
105
|
-
return {
|
|
106
|
-
name: groupby || groupby === 0 ? groupby : _intl.default.get('Empty'),
|
|
107
|
-
valueX: `${selectedXAxisColumn === null || selectedXAxisColumn === void 0 ? void 0 : selectedXAxisColumn.name}: ${name}`,
|
|
108
|
-
valueY: `${selectedYAxisColumn === null || selectedYAxisColumn === void 0 ? void 0 : selectedYAxisColumn.name}: ${value}`
|
|
109
|
-
};
|
|
110
|
-
}).style({
|
|
111
|
-
fillOpacity: 0.85
|
|
112
|
-
}).state({
|
|
113
|
-
active: {
|
|
114
|
-
style: {
|
|
115
|
-
stroke: null
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
currentChart.setNameLabelAndTooltip(theme, currentChart.labelCount);
|
|
120
|
-
currentChart.setValueLabel(theme);
|
|
121
|
-
currentChart.chart.interaction('active-region');
|
|
122
|
-
}
|
|
123
|
-
createChart();
|
|
124
|
-
drawChart();
|
|
125
|
-
return () => {
|
|
126
|
-
if (currentChart.isDestoryed) return;
|
|
127
|
-
currentChart.chart.destroy();
|
|
128
|
-
currentChart.isDestoryed = true;
|
|
129
|
-
};
|
|
130
|
-
}, [chart, chartColorTheme, data, globalTheme, tables, toggleRecords]);
|
|
131
|
-
const showXLabel = chartRef.current.isShowXAxisLabel(chart);
|
|
132
|
-
const showYLabel = chartRef.current.isShowYAxisLabel(chart);
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
134
|
-
className: (0, _classnames.default)('sea-chart-container', {
|
|
135
|
-
'show-x-axis-label': showXLabel,
|
|
136
|
-
'show-y-axis-label': showYLabel
|
|
137
|
-
}),
|
|
138
|
-
ref: chartContainerRef
|
|
139
|
-
});
|
|
140
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _dataSet = _interopRequireDefault(require("@antv/data-set"));
|
|
11
|
-
var _util = require("@antv/util");
|
|
12
|
-
var _text = require("@antv/g2/esm/util/text");
|
|
13
|
-
var _constants = require("../../constants");
|
|
14
|
-
var _utils = require("../../utils");
|
|
15
|
-
var _customG = require("../../utils/custom-g2");
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
18
|
-
class Treemap extends _chartComponent.default {
|
|
19
|
-
constructor(props) {
|
|
20
|
-
super(props);
|
|
21
|
-
// customize label layout: show ellipsis for long labels
|
|
22
|
-
this.limitInShape = (items, labels, shapes, region) => {
|
|
23
|
-
(0, _util.each)(labels, (label, index) => {
|
|
24
|
-
const labelBBox = label.getCanvasBBox();
|
|
25
|
-
const shapeBBox = shapes[index].getBBox();
|
|
26
|
-
if (labelBBox.minX < shapeBBox.minX || labelBBox.minY < shapeBBox.minY || labelBBox.maxX > shapeBBox.maxX || labelBBox.maxY > shapeBBox.maxY) {
|
|
27
|
-
const translateX = labelBBox.width - shapeBBox.width + 20;
|
|
28
|
-
const textShapes = label.findAll(shape => shape.get('type') === 'text');
|
|
29
|
-
textShapes.forEach(textShape => {
|
|
30
|
-
const style = (0, _util.pick)(textShape.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
|
|
31
|
-
const textBox = textShape.getCanvasBBox();
|
|
32
|
-
const text = (0, _text.getEllipsisText)(textShape.attr('text'), textBox.width - Math.abs(translateX), style);
|
|
33
|
-
textShape.attr('text', text);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
this.createChart = () => {
|
|
39
|
-
const {
|
|
40
|
-
canvasStyle
|
|
41
|
-
} = this.props;
|
|
42
|
-
this.initChart(this.container, canvasStyle, 0);
|
|
43
|
-
};
|
|
44
|
-
this.destroyChart = () => {
|
|
45
|
-
this.chart.destroy();
|
|
46
|
-
this.chart = null;
|
|
47
|
-
};
|
|
48
|
-
this.clearChart = () => {
|
|
49
|
-
this.chart.annotation().clear(true);
|
|
50
|
-
this.chart.clear(true);
|
|
51
|
-
};
|
|
52
|
-
this.drawChart = () => {
|
|
53
|
-
let {
|
|
54
|
-
result: data,
|
|
55
|
-
chart,
|
|
56
|
-
tables,
|
|
57
|
-
chartColorTheme,
|
|
58
|
-
summaryColumn,
|
|
59
|
-
customRender
|
|
60
|
-
} = this.props;
|
|
61
|
-
const {
|
|
62
|
-
summary_type,
|
|
63
|
-
summary_method
|
|
64
|
-
} = chart.config;
|
|
65
|
-
let colorsTheme = _utils.BaseUtils.getCurrentTheme(chartColorTheme);
|
|
66
|
-
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
67
|
-
const {
|
|
68
|
-
data: newData,
|
|
69
|
-
colorMap
|
|
70
|
-
} = _utils.BaseUtils.formatPieChartData(data, chart, tables, colorsTheme);
|
|
71
|
-
if (!Array.isArray(newData)) return;
|
|
72
|
-
const {
|
|
73
|
-
DataView
|
|
74
|
-
} = _dataSet.default;
|
|
75
|
-
const dv = new DataView();
|
|
76
|
-
const fullData = {
|
|
77
|
-
name: 'root',
|
|
78
|
-
children: newData.map(item => {
|
|
79
|
-
let name = item.name;
|
|
80
|
-
item.name = name || name === 0 ? name : _intl.default.get(_constants.EMPTY_NAME);
|
|
81
|
-
if (name === '_Others') {
|
|
82
|
-
item.name = _intl.default.get('Others');
|
|
83
|
-
}
|
|
84
|
-
return item;
|
|
85
|
-
})
|
|
86
|
-
};
|
|
87
|
-
dv.source(fullData, {
|
|
88
|
-
type: 'hierarchy'
|
|
89
|
-
}).transform({
|
|
90
|
-
field: 'value',
|
|
91
|
-
type: 'hierarchy.treemap',
|
|
92
|
-
tile: 'treemapResquarify',
|
|
93
|
-
as: ['x', 'y']
|
|
94
|
-
});
|
|
95
|
-
const nodes = [];
|
|
96
|
-
for (const node of dv.getAllNodes()) {
|
|
97
|
-
if (node.data.name === 'root') {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const eachNode = {
|
|
101
|
-
name: node.data.name,
|
|
102
|
-
x: node.x,
|
|
103
|
-
y: node.y,
|
|
104
|
-
value: node.data.value,
|
|
105
|
-
percent: node.data.percent,
|
|
106
|
-
original_name: node.data.original_name,
|
|
107
|
-
rows: node.data.rows || null
|
|
108
|
-
};
|
|
109
|
-
nodes.push(eachNode);
|
|
110
|
-
}
|
|
111
|
-
this.chart.on('element:click', e => {
|
|
112
|
-
this.props.toggleRecords(e.data.data);
|
|
113
|
-
});
|
|
114
|
-
this.chart.data(nodes);
|
|
115
|
-
this.chart.scale({
|
|
116
|
-
x: {
|
|
117
|
-
nice: true
|
|
118
|
-
},
|
|
119
|
-
y: {
|
|
120
|
-
nice: true
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
this.chart.axis(false);
|
|
124
|
-
this.chart.legend(false);
|
|
125
|
-
this.chart.tooltip({
|
|
126
|
-
showTitle: false,
|
|
127
|
-
showMarkers: false,
|
|
128
|
-
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
129
|
-
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">{info}<div></div>',
|
|
130
|
-
domStyles: {
|
|
131
|
-
'g2-tooltip': {
|
|
132
|
-
borderRadius: '2px',
|
|
133
|
-
backgroundColor: '#fff',
|
|
134
|
-
padding: '10px'
|
|
135
|
-
},
|
|
136
|
-
'tooltip-item': {
|
|
137
|
-
marginTop: '5px'
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
this.chart.polygon().position('x*y').color('name', name => {
|
|
142
|
-
return colorMap[name.trim()];
|
|
143
|
-
}).tooltip('name*value*percent', (name, value, percent) => {
|
|
144
|
-
const displayValue = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
145
|
-
return {
|
|
146
|
-
name,
|
|
147
|
-
info: summary_type === _constants.CHART_SUMMARY_TYPE.COUNT ? `${value}` : `${summaryColumn.name}: ${displayValue} (${percent})`
|
|
148
|
-
};
|
|
149
|
-
}).style({
|
|
150
|
-
lineWidth: 1,
|
|
151
|
-
stroke: '#fff'
|
|
152
|
-
}).label('name', {
|
|
153
|
-
offset: 0,
|
|
154
|
-
style: {
|
|
155
|
-
textBaseline: 'middle'
|
|
156
|
-
},
|
|
157
|
-
content: obj => {
|
|
158
|
-
if (obj.name !== 'root') {
|
|
159
|
-
return obj.name;
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
layout: {
|
|
163
|
-
type: 'custom-limit-in-shape'
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this.chart.interaction('chart-active');
|
|
167
|
-
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
168
|
-
this.chart.render();
|
|
169
|
-
};
|
|
170
|
-
this.chart = null;
|
|
171
|
-
(0, _customG.registerGeometryLabelLayout)('custom-limit-in-shape', this.limitInShape);
|
|
172
|
-
}
|
|
173
|
-
componentDidMount() {
|
|
174
|
-
this.createChart();
|
|
175
|
-
this.drawChart();
|
|
176
|
-
}
|
|
177
|
-
componentDidUpdate(prevProps) {
|
|
178
|
-
super.componentDidUpdate(prevProps);
|
|
179
|
-
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
180
|
-
this.chart && this.destroyChart();
|
|
181
|
-
this.createChart();
|
|
182
|
-
this.drawChart();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
componentWillUnmount() {
|
|
186
|
-
this.chart && this.destroyChart();
|
|
187
|
-
}
|
|
188
|
-
render() {
|
|
189
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
190
|
-
className: "sea-chart-container ",
|
|
191
|
-
ref: ref => this.container = ref
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
Treemap.propTypes = {
|
|
196
|
-
canvasStyle: _propTypes.default.object,
|
|
197
|
-
chart: _propTypes.default.object,
|
|
198
|
-
groupbyColumn: _propTypes.default.object,
|
|
199
|
-
summaryColumn: _propTypes.default.object,
|
|
200
|
-
result: _propTypes.default.array,
|
|
201
|
-
tables: _propTypes.default.array,
|
|
202
|
-
globalTheme: _propTypes.default.string,
|
|
203
|
-
chartColorTheme: _propTypes.default.string,
|
|
204
|
-
customRender: _propTypes.default.func
|
|
205
|
-
};
|
|
206
|
-
var _default = exports.default = Treemap;
|