dtable-statistic 4.0.7 → 4.0.8
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/es/calculator/basic-chart-calculator.js +27 -18
- package/es/calculator/combination-calculator.js +34 -9
- package/es/calculator/compare-bar-calculator.js +37 -30
- package/es/calculator/heat-map-calculator.js +25 -14
- package/es/calculator/map-calculator.js +25 -14
- package/es/calculator/mirror-calculator.js +29 -14
- package/es/calculator/pivot-table-calculator.js +78 -51
- package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
- package/es/calculator/workers/combination-calculator-worker.js +20 -5
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
- package/es/calculator/workers/mirror-calculator-worker.js +15 -6
- package/es/calculator/workers/pivot-table-calculator-worker.js +87 -41
- package/es/calculator/world-map-calculator.js +25 -14
- package/es/components/dialog/enlarged-chart-dialog.js +2 -2
- package/es/components/dialog/statistic-record-dialog/index.js +71 -41
- package/es/constants/index.js +30 -29
- package/es/dashboard.js +57 -43
- package/es/desktop-dashboard.js +16 -51
- package/es/index.js +34 -2
- package/es/locale/lang/de.js +2 -0
- package/es/locale/lang/en.js +2 -0
- package/es/locale/lang/fr.js +2 -0
- package/es/locale/lang/zh_CN.js +2 -0
- package/es/mobile-dashboard.js +5 -5
- package/es/model/horizontal-bar-group.js +2 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
- package/es/stat-list/chart-preview.js +3 -4
- package/es/stat-list/index.js +10 -4
- package/es/stat-view/area-chart.js +177 -162
- package/es/stat-view/bar-chart.js +221 -222
- package/es/stat-view/base-chart.js +79 -7
- package/es/stat-view/basic-number-card.js +11 -19
- package/es/stat-view/combination-chart.js +100 -83
- package/es/stat-view/compare-chart.js +133 -144
- package/es/stat-view/completeness-chart.js +108 -102
- package/es/stat-view/custom-bar.js +79 -99
- package/es/stat-view/dashboard-chart.js +57 -57
- package/es/stat-view/heat-map.js +13 -32
- package/es/stat-view/horizontal-bar-chart.js +200 -230
- package/es/stat-view/index.js +2 -2
- package/es/stat-view/line-chart.js +162 -158
- package/es/stat-view/map.js +26 -40
- package/es/stat-view/mirror.js +88 -94
- package/es/stat-view/pie-chart.js +11 -39
- package/es/stat-view/pivot-table/index.js +4 -16
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +22 -15
- package/es/stat-view/ring-chart.js +24 -42
- package/es/stat-view/scatter-chart.js +4 -21
- package/es/stat-view/treemap-chart.js +3 -12
- package/es/stat-view/trend-chart.js +6 -17
- package/es/stat-view/world-map.js +39 -50
- package/es/tabs/tab.js +2 -1
- package/es/utils/common-utils.js +24 -6
- package/es/utils/sql-utils.js +10 -9
- package/es/utils/stat-utils.js +8 -5
- package/package.json +1 -1
|
@@ -5,17 +5,14 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import intl from 'react-intl-universal';
|
|
8
|
-
import { TableUtils
|
|
8
|
+
import { TableUtils } from 'dtable-store';
|
|
9
9
|
import BaseChart from './base-chart';
|
|
10
10
|
import { Chart } from '../custom-g2';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { EMPTY_NAME, NO_STATISTIC_RESULTS, STAT_ITEM_THEME_COLORS, STAT_TYPE } from '../constants';
|
|
11
|
+
import { getCurrentTheme } from '../utils/common-utils';
|
|
12
|
+
import { EMPTY_NAME, STAT_TYPE } from '../constants';
|
|
14
13
|
var propTypes = {
|
|
15
14
|
isPreview: PropTypes.bool,
|
|
16
|
-
isEnlarge: PropTypes.bool,
|
|
17
15
|
isEdit: PropTypes.bool,
|
|
18
|
-
theme: PropTypes.string,
|
|
19
16
|
colorThemeName: PropTypes.string,
|
|
20
17
|
statItem: PropTypes.object,
|
|
21
18
|
chartCalculator: PropTypes.object,
|
|
@@ -29,10 +26,9 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
29
26
|
var _this;
|
|
30
27
|
_classCallCheck(this, CompletenessChart);
|
|
31
28
|
_this = _super.call(this, props);
|
|
32
|
-
_this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return getLabelFontSize(label_font_size);
|
|
29
|
+
_this.destroyChart = function () {
|
|
30
|
+
_this.chart.destroy();
|
|
31
|
+
_this.chart = null;
|
|
36
32
|
};
|
|
37
33
|
_this.sortData = function (data, sortType) {
|
|
38
34
|
var compareCompleteness = sortType == 'ascending' ? function (a, b) {
|
|
@@ -53,16 +49,18 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
53
49
|
_this.drawChart = function (data) {
|
|
54
50
|
var _this$props = _this.props,
|
|
55
51
|
getTableById = _this$props.getTableById,
|
|
56
|
-
isPreview = _this$props.isPreview,
|
|
57
52
|
statItem = _this$props.statItem,
|
|
58
|
-
theme = _this$props.theme,
|
|
59
|
-
isEnlarge = _this$props.isEnlarge,
|
|
60
53
|
colorThemeName = _this$props.colorThemeName;
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
var sort_type = statItem.sort_type,
|
|
55
|
+
completed_column = statItem.completed_column,
|
|
56
|
+
target_column = statItem.target_column,
|
|
57
|
+
table_id = statItem.table_id;
|
|
64
58
|
var isGroupChart = statItem.type === STAT_TYPE.GROUP_COMPLETENESS_CHART;
|
|
65
59
|
var currentTheme = getCurrentTheme(colorThemeName);
|
|
60
|
+
_this.initChartHandler();
|
|
61
|
+
var selectedTable = getTableById(table_id);
|
|
62
|
+
var completedColumn = TableUtils.getTableColumnByKey(selectedTable, completed_column);
|
|
63
|
+
var targetColumn = TableUtils.getTableColumnByKey(selectedTable, target_column);
|
|
66
64
|
|
|
67
65
|
// 数据颜色映射value设置当前主题色
|
|
68
66
|
if (isGroupChart) {
|
|
@@ -75,21 +73,6 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
75
73
|
if (sort_type && !isGroupChart) {
|
|
76
74
|
_this.sortData(data, sort_type);
|
|
77
75
|
}
|
|
78
|
-
if (isPreview) {
|
|
79
|
-
_this.chart = new Chart({
|
|
80
|
-
container: _this.container,
|
|
81
|
-
autoFit: true,
|
|
82
|
-
appendPadding: [0, display_percentage ? 30 : 0, 0, 0]
|
|
83
|
-
});
|
|
84
|
-
} else {
|
|
85
|
-
_this.chart = new Chart({
|
|
86
|
-
container: _this.container,
|
|
87
|
-
autoFit: true,
|
|
88
|
-
height: 400,
|
|
89
|
-
width: 700,
|
|
90
|
-
appendPadding: [0, display_percentage ? 30 : 0, 0, 0]
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
76
|
_this.chart.on('element:click', function (e) {
|
|
94
77
|
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
95
78
|
});
|
|
@@ -100,26 +83,57 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
100
83
|
}
|
|
101
84
|
});
|
|
102
85
|
_this.chart.coordinate('rect');
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
_this.handleAutoRange(targetColumn);
|
|
87
|
+
var themeColors = _this.getThemeColors();
|
|
88
|
+
_this.drawBar({
|
|
89
|
+
data: data,
|
|
90
|
+
currentTheme: currentTheme,
|
|
91
|
+
themeColors: themeColors,
|
|
92
|
+
isGroupChart: isGroupChart,
|
|
93
|
+
completedColumn: completedColumn,
|
|
94
|
+
targetColumn: targetColumn
|
|
95
|
+
});
|
|
96
|
+
_this.setTooltip();
|
|
97
|
+
_this.setAxis(themeColors);
|
|
98
|
+
_this.chart.interaction('active-region');
|
|
99
|
+
_this.chart.coordinate().transpose();
|
|
100
|
+
if (isGroupChart) {
|
|
101
|
+
_this.setLegendGroup(themeColors);
|
|
102
|
+
}
|
|
103
|
+
_this.chart.render();
|
|
104
|
+
};
|
|
105
|
+
_this.initChartHandler = function () {
|
|
106
|
+
var _this$props2 = _this.props,
|
|
107
|
+
isPreview = _this$props2.isPreview,
|
|
108
|
+
statItem = _this$props2.statItem;
|
|
109
|
+
var display_percentage = statItem.display_percentage;
|
|
110
|
+
var config = {
|
|
111
|
+
container: _this.container,
|
|
112
|
+
autoFit: true,
|
|
113
|
+
appendPadding: [0, display_percentage ? 30 : 0, 0, 0]
|
|
114
|
+
};
|
|
115
|
+
if (!isPreview) {
|
|
116
|
+
config.height = 400;
|
|
117
|
+
config.width = 700;
|
|
118
|
+
}
|
|
119
|
+
_this.chart = new Chart(config);
|
|
120
|
+
};
|
|
121
|
+
_this.handleAutoRange = function (targetColumn) {
|
|
122
|
+
var _this$props$statItem = _this.props.statItem,
|
|
123
|
+
_this$props$statItem$ = _this$props$statItem.y_axis_auto_range,
|
|
124
|
+
y_axis_auto_range = _this$props$statItem$ === void 0 ? true : _this$props$statItem$,
|
|
125
|
+
_this$props$statItem$2 = _this$props$statItem.y_axis_min,
|
|
126
|
+
y_axis_min = _this$props$statItem$2 === void 0 ? 0 : _this$props$statItem$2,
|
|
127
|
+
_this$props$statItem$3 = _this$props$statItem.y_axis_max,
|
|
128
|
+
y_axis_max = _this$props$statItem$3 === void 0 ? 0 : _this$props$statItem$3;
|
|
115
129
|
var valueScaleOptions = {
|
|
116
130
|
nice: true,
|
|
117
131
|
formatter: function formatter(value) {
|
|
118
|
-
return getNumberDisplayString(value, targetColumn.data);
|
|
132
|
+
return _this.getNumberDisplayString(value, targetColumn.data);
|
|
119
133
|
}
|
|
120
134
|
};
|
|
121
135
|
if (!y_axis_auto_range) {
|
|
122
|
-
valueScaleOptions = Object.assign(
|
|
136
|
+
valueScaleOptions = Object.assign(valueScaleOptions, {
|
|
123
137
|
min: y_axis_min,
|
|
124
138
|
max: y_axis_max
|
|
125
139
|
});
|
|
@@ -131,17 +145,24 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
131
145
|
// Automatic adjustment of maximum and minimum values
|
|
132
146
|
value: valueScaleOptions
|
|
133
147
|
});
|
|
148
|
+
};
|
|
149
|
+
_this.drawBar = function (_ref) {
|
|
150
|
+
var data = _ref.data,
|
|
151
|
+
themeColors = _ref.themeColors,
|
|
152
|
+
currentTheme = _ref.currentTheme,
|
|
153
|
+
isGroupChart = _ref.isGroupChart,
|
|
154
|
+
completedColumn = _ref.completedColumn,
|
|
155
|
+
targetColumn = _ref.targetColumn;
|
|
156
|
+
var _this$props$statItem2 = _this.props.statItem,
|
|
157
|
+
group_column = _this$props$statItem2.group_column,
|
|
158
|
+
display_percentage = _this$props$statItem2.display_percentage;
|
|
134
159
|
var adjustType = isGroupChart ? [{
|
|
135
160
|
type: 'dodge',
|
|
136
161
|
dodgeBy: 'group_label'
|
|
137
162
|
}, {
|
|
138
163
|
type: 'stack'
|
|
139
164
|
}] : 'stack';
|
|
140
|
-
|
|
141
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
142
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
143
|
-
}
|
|
144
|
-
_this.chart.interval().label(statItem.display_percentage ? 'current_value*target_value' : false, {
|
|
165
|
+
_this.chart.interval().label(display_percentage ? 'current_value*target_value' : false, {
|
|
145
166
|
position: 'right',
|
|
146
167
|
offset: 3,
|
|
147
168
|
style: {
|
|
@@ -172,9 +193,9 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
172
193
|
var value;
|
|
173
194
|
if (type === 'uncompleted') {
|
|
174
195
|
tooltipName = intl.get('Uncompleted');
|
|
175
|
-
value = getNumberDisplayString(target_value - current_value, targetColumn.data);
|
|
196
|
+
value = _this.getNumberDisplayString(target_value - current_value, targetColumn.data);
|
|
176
197
|
} else {
|
|
177
|
-
value = getNumberDisplayString(current_value, completedColumn.data);
|
|
198
|
+
value = _this.getNumberDisplayString(current_value, completedColumn.data);
|
|
178
199
|
}
|
|
179
200
|
var tooltipTitle = name;
|
|
180
201
|
if (!tooltipTitle && typeof tooltipTitle !== 'number') {
|
|
@@ -192,24 +213,20 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
192
213
|
}
|
|
193
214
|
}
|
|
194
215
|
});
|
|
216
|
+
};
|
|
217
|
+
_this.setTooltip = function () {
|
|
195
218
|
_this.chart.tooltip({
|
|
196
219
|
showTitle: true,
|
|
197
220
|
showMarkers: false,
|
|
198
221
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
199
222
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
200
223
|
domStyles: {
|
|
201
|
-
'g2-tooltip':
|
|
202
|
-
|
|
203
|
-
backgroundColor: '#fff',
|
|
204
|
-
padding: '10px'
|
|
205
|
-
},
|
|
206
|
-
'tooltip-item': {
|
|
207
|
-
marginTop: '5px'
|
|
208
|
-
}
|
|
224
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
225
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
209
226
|
}
|
|
210
227
|
});
|
|
211
|
-
|
|
212
|
-
|
|
228
|
+
};
|
|
229
|
+
_this.setAxis = function (themeColors) {
|
|
213
230
|
_this.chart.axis('name', {
|
|
214
231
|
label: {
|
|
215
232
|
formatter: function formatter(name) {
|
|
@@ -241,39 +258,32 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
241
258
|
}
|
|
242
259
|
}
|
|
243
260
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
261
|
+
};
|
|
262
|
+
_this.setLegendGroup = function (themeColors) {
|
|
263
|
+
_this.chart.legend('group_label', {
|
|
264
|
+
itemName: {
|
|
265
|
+
style: {
|
|
266
|
+
fill: themeColors.textColor
|
|
267
|
+
},
|
|
268
|
+
formatter: function formatter(name) {
|
|
269
|
+
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
pageNavigator: {
|
|
273
|
+
text: {
|
|
249
274
|
style: {
|
|
250
275
|
fill: themeColors.textColor
|
|
251
|
-
},
|
|
252
|
-
formatter: function formatter(name) {
|
|
253
|
-
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
254
276
|
}
|
|
255
277
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
},
|
|
262
|
-
marker: {
|
|
263
|
-
style: {
|
|
264
|
-
fill: themeColors.legendPageNavigatorMarkerColor,
|
|
265
|
-
inactiveFill: themeColors.legendPageNavigatorMarkerColor,
|
|
266
|
-
inactiveOpacity: 0.45
|
|
267
|
-
}
|
|
278
|
+
marker: {
|
|
279
|
+
style: {
|
|
280
|
+
fill: themeColors.legendPageNavigatorMarkerColor,
|
|
281
|
+
inactiveFill: themeColors.legendPageNavigatorMarkerColor,
|
|
282
|
+
inactiveOpacity: 0.45
|
|
268
283
|
}
|
|
269
284
|
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
_this.chart.render();
|
|
273
|
-
};
|
|
274
|
-
_this.destroyChart = function () {
|
|
275
|
-
_this.chart.destroy();
|
|
276
|
-
_this.chart = null;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
277
287
|
};
|
|
278
288
|
_this.state = {
|
|
279
289
|
isCalculatingData: true,
|
|
@@ -286,9 +296,9 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
286
296
|
key: "componentDidMount",
|
|
287
297
|
value: function componentDidMount() {
|
|
288
298
|
var _this2 = this;
|
|
289
|
-
var _this$
|
|
290
|
-
statItem = _this$
|
|
291
|
-
chartCalculator = _this$
|
|
299
|
+
var _this$props3 = this.props,
|
|
300
|
+
statItem = _this$props3.statItem,
|
|
301
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
292
302
|
if (this.container) {
|
|
293
303
|
chartCalculator.calculate(statItem).then(function (data) {
|
|
294
304
|
var showResultDescription = data.length > 0 ? false : true;
|
|
@@ -323,9 +333,9 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
323
333
|
key: "componentDidUpdate",
|
|
324
334
|
value: function componentDidUpdate(preProps, preState) {
|
|
325
335
|
var _this3 = this;
|
|
326
|
-
var _this$
|
|
327
|
-
statItem = _this$
|
|
328
|
-
chartCalculator = _this$
|
|
336
|
+
var _this$props4 = this.props,
|
|
337
|
+
statItem = _this$props4.statItem,
|
|
338
|
+
chartCalculator = _this$props4.chartCalculator;
|
|
329
339
|
var isCalculatingData = this.state.isCalculatingData;
|
|
330
340
|
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
331
341
|
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
@@ -368,13 +378,9 @@ var CompletenessChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
368
378
|
var _this$state = this.state,
|
|
369
379
|
isCalculatingData = _this$state.isCalculatingData,
|
|
370
380
|
showResultDescription = _this$state.showResultDescription;
|
|
371
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
className: 'statistic-chart-text'
|
|
375
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
376
|
-
ref: function ref(_ref) {
|
|
377
|
-
return _this4.container = _ref;
|
|
381
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
382
|
+
ref: function ref(_ref2) {
|
|
383
|
+
return _this4.container = _ref2;
|
|
378
384
|
},
|
|
379
385
|
style: {
|
|
380
386
|
padding: 20
|
|
@@ -9,19 +9,16 @@ import intl from 'react-intl-universal';
|
|
|
9
9
|
import { TableUtils } from 'dtable-store';
|
|
10
10
|
import { Chart } from '../custom-g2';
|
|
11
11
|
import BaseChart from './base-chart';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { EMPTY_NAME, STAT_ITEM_THEME_COLORS, LABEL_CONFIG_CHANGED, TITLE_AMOUNT, NO_STATISTIC_RESULTS } from '../constants';
|
|
12
|
+
import { getChartGroups } from '../utils/basic-chart-utils';
|
|
13
|
+
import { getCurrentTheme } from '../utils/common-utils';
|
|
14
|
+
import { EMPTY_NAME, LABEL_CONFIG_CHANGED, TITLE_AMOUNT } from '../constants';
|
|
16
15
|
var propTypes = {
|
|
17
16
|
isPreview: PropTypes.bool,
|
|
18
|
-
isEnlarge: PropTypes.bool,
|
|
19
17
|
isEdit: PropTypes.bool,
|
|
20
18
|
statItem: PropTypes.object,
|
|
21
19
|
labelColorConfigs: PropTypes.array,
|
|
22
20
|
chartCalculator: PropTypes.object,
|
|
23
21
|
eventBus: PropTypes.object,
|
|
24
|
-
theme: PropTypes.string,
|
|
25
22
|
colorThemeName: PropTypes.string,
|
|
26
23
|
toggleStatisticRecordsDialog: PropTypes.func
|
|
27
24
|
};
|
|
@@ -35,24 +32,10 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
35
32
|
_this.drawChart = function (originalData) {
|
|
36
33
|
// just support custom stack-bar
|
|
37
34
|
var _this$props = _this.props,
|
|
38
|
-
isPreview = _this$props.isPreview,
|
|
39
35
|
statItem = _this$props.statItem,
|
|
40
|
-
isEnlarge = _this$props.isEnlarge,
|
|
41
|
-
theme = _this$props.theme,
|
|
42
36
|
colorThemeName = _this$props.colorThemeName;
|
|
43
|
-
|
|
44
|
-
var currentTheme = getCurrentTheme(colorThemeName);
|
|
37
|
+
_this.initChartHandler();
|
|
45
38
|
var data = originalData;
|
|
46
|
-
var viewConfig = {
|
|
47
|
-
container: _this.container,
|
|
48
|
-
autoFit: true,
|
|
49
|
-
appendPadding: [display_data ? 17 : 0, 0, 0, 0]
|
|
50
|
-
};
|
|
51
|
-
if (!isPreview) {
|
|
52
|
-
viewConfig.height = 400;
|
|
53
|
-
viewConfig.width = 700;
|
|
54
|
-
}
|
|
55
|
-
_this.chart = new Chart(viewConfig);
|
|
56
39
|
_this.chart.on('interval:click', function (e) {
|
|
57
40
|
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
58
41
|
});
|
|
@@ -66,17 +49,11 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
66
49
|
}
|
|
67
50
|
});
|
|
68
51
|
var width = _this.chart.coordinateBBox.width;
|
|
69
|
-
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
70
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
71
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
72
|
-
}
|
|
73
52
|
var chartData = getChartGroups(data);
|
|
74
|
-
var
|
|
75
|
-
if (
|
|
76
|
-
var displayLabels = getChartDisplayLabels(width, 20, chartData);
|
|
77
|
-
labelCount = displayLabels.length;
|
|
53
|
+
var ticks = _this.getTicks(chartData, width);
|
|
54
|
+
if (ticks.length > 0) {
|
|
78
55
|
_this.chart.scale('name', {
|
|
79
|
-
ticks:
|
|
56
|
+
ticks: ticks
|
|
80
57
|
});
|
|
81
58
|
}
|
|
82
59
|
|
|
@@ -88,17 +65,6 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
88
65
|
type: 'cat'
|
|
89
66
|
}
|
|
90
67
|
});
|
|
91
|
-
var labelCfg = {
|
|
92
|
-
style: {
|
|
93
|
-
fontSize: _this.getLabelFontSize(),
|
|
94
|
-
fill: themeColors.textColor
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var display_each_block_data = statItem.display_each_block_data;
|
|
98
|
-
var displayData = display_each_block_data;
|
|
99
|
-
if (displayData) {
|
|
100
|
-
labelCfg.position = 'middle';
|
|
101
|
-
}
|
|
102
68
|
|
|
103
69
|
// get the total value of each stack
|
|
104
70
|
var dv = new DataSet.DataView().source(data);
|
|
@@ -109,21 +75,64 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
109
75
|
as: ['value_sum'],
|
|
110
76
|
groupBy: ['name', 'y_axis_type']
|
|
111
77
|
});
|
|
112
|
-
var groupColorCallback = currentTheme && currentTheme.colors;
|
|
113
78
|
_this.chart.scale({
|
|
114
79
|
group_name: {
|
|
115
80
|
type: 'cat'
|
|
116
81
|
}
|
|
117
82
|
});
|
|
118
|
-
|
|
83
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
84
|
+
var themeColors = _this.getThemeColors();
|
|
85
|
+
_this.drawBar({
|
|
86
|
+
themeColors: themeColors,
|
|
87
|
+
currentTheme: currentTheme
|
|
88
|
+
});
|
|
89
|
+
_this.setTooltip();
|
|
90
|
+
_this.setAxis(themeColors);
|
|
91
|
+
_this.setLegend(themeColors);
|
|
92
|
+
_this.chart.interaction('active-region');
|
|
93
|
+
_this.chart.render();
|
|
94
|
+
_this.renderAxisLabel();
|
|
95
|
+
};
|
|
96
|
+
_this.initChartHandler = function () {
|
|
97
|
+
var _this$props2 = _this.props,
|
|
98
|
+
isPreview = _this$props2.isPreview,
|
|
99
|
+
statItem = _this$props2.statItem;
|
|
100
|
+
var display_data = statItem.display_data;
|
|
101
|
+
var config = {
|
|
102
|
+
container: _this.container,
|
|
103
|
+
autoFit: true,
|
|
104
|
+
appendPadding: [display_data ? 17 : 0, 0, 0, 0]
|
|
105
|
+
};
|
|
106
|
+
if (!isPreview) {
|
|
107
|
+
config.height = 400;
|
|
108
|
+
config.width = 700;
|
|
109
|
+
}
|
|
110
|
+
_this.chart = new Chart(config);
|
|
111
|
+
};
|
|
112
|
+
_this.drawBar = function (_ref) {
|
|
113
|
+
var themeColors = _ref.themeColors,
|
|
114
|
+
currentTheme = _ref.currentTheme;
|
|
115
|
+
var display_each_block_data = _this.props.statItem.display_each_block_data;
|
|
116
|
+
var displayData = display_each_block_data;
|
|
117
|
+
var labelCfg = {
|
|
118
|
+
style: {
|
|
119
|
+
fontSize: _this.getLabelFontSize(),
|
|
120
|
+
fill: themeColors.textColor
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
if (displayData) {
|
|
124
|
+
labelCfg.position = 'middle';
|
|
125
|
+
}
|
|
126
|
+
var groupColorCallback = currentTheme && currentTheme.colors;
|
|
127
|
+
_this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name*raw_name', function (name, value, group_name, raw_name) {
|
|
119
128
|
var nameContent = group_name;
|
|
120
129
|
if (!group_name && typeof group_name !== 'number') {
|
|
121
130
|
nameContent = intl.get(EMPTY_NAME);
|
|
122
131
|
}
|
|
123
132
|
var title = !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
124
133
|
return {
|
|
134
|
+
value: value,
|
|
125
135
|
title: title,
|
|
126
|
-
value: formatted_value,
|
|
127
136
|
name: nameContent
|
|
128
137
|
};
|
|
129
138
|
}).adjust([{
|
|
@@ -139,24 +148,20 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
});
|
|
151
|
+
};
|
|
152
|
+
_this.setTooltip = function () {
|
|
142
153
|
_this.chart.tooltip({
|
|
143
154
|
showTitle: true,
|
|
144
155
|
showMarkers: false,
|
|
145
156
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
146
157
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
147
158
|
domStyles: {
|
|
148
|
-
'g2-tooltip':
|
|
149
|
-
|
|
150
|
-
backgroundColor: '#fff',
|
|
151
|
-
padding: '10px'
|
|
152
|
-
},
|
|
153
|
-
'tooltip-item': {
|
|
154
|
-
marginTop: '5px'
|
|
155
|
-
}
|
|
159
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
160
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
156
161
|
}
|
|
157
162
|
});
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
};
|
|
164
|
+
_this.setAxis = function (themeColors) {
|
|
160
165
|
_this.chart.axis('name', {
|
|
161
166
|
line: {
|
|
162
167
|
style: themeColors.gridColor
|
|
@@ -166,16 +171,7 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
166
171
|
style: {
|
|
167
172
|
fill: themeColors.textColor
|
|
168
173
|
},
|
|
169
|
-
formatter:
|
|
170
|
-
var label = name;
|
|
171
|
-
if (name.length > 10) {
|
|
172
|
-
label = "".concat(name.slice(0, 10), "...");
|
|
173
|
-
}
|
|
174
|
-
if (name === '' || name === 'undefined') {
|
|
175
|
-
label = intl.get(EMPTY_NAME);
|
|
176
|
-
}
|
|
177
|
-
return label;
|
|
178
|
-
}
|
|
174
|
+
formatter: _this.labelFormatter
|
|
179
175
|
}
|
|
180
176
|
});
|
|
181
177
|
_this.chart.axis('value', {
|
|
@@ -192,6 +188,8 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
192
188
|
}
|
|
193
189
|
}
|
|
194
190
|
});
|
|
191
|
+
};
|
|
192
|
+
_this.setLegend = function (themeColors) {
|
|
195
193
|
var legendPosition = 'bottom';
|
|
196
194
|
_this.chart.legend('group_name', {
|
|
197
195
|
position: legendPosition,
|
|
@@ -221,17 +219,11 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
});
|
|
224
|
-
_this.chart.interaction('active-region');
|
|
225
|
-
_this.chart.render();
|
|
226
|
-
_this.renderAxisLabel();
|
|
227
222
|
};
|
|
228
223
|
_this.renderAxisLabel = function (newStatItem) {
|
|
229
|
-
var _this$
|
|
230
|
-
getTableById = _this$
|
|
231
|
-
statItem = _this$
|
|
232
|
-
isEnlarge = _this$props2.isEnlarge,
|
|
233
|
-
isPreview = _this$props2.isPreview,
|
|
234
|
-
theme = _this$props2.theme;
|
|
224
|
+
var _this$props3 = _this.props,
|
|
225
|
+
getTableById = _this$props3.getTableById,
|
|
226
|
+
statItem = _this$props3.statItem;
|
|
235
227
|
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
236
228
|
return;
|
|
237
229
|
}
|
|
@@ -247,10 +239,7 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
247
239
|
title_name = _statItem.title_name;
|
|
248
240
|
var table = getTableById(table_id);
|
|
249
241
|
var autoPadding = _this.chart.autoPadding;
|
|
250
|
-
var textColor =
|
|
251
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
252
|
-
textColor = '#ffffff';
|
|
253
|
-
}
|
|
242
|
+
var textColor = _this.getAxisLabelColor();
|
|
254
243
|
var xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
255
244
|
var chartContainer = _this.chart.getCanvas().get('container');
|
|
256
245
|
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
@@ -299,11 +288,6 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
299
288
|
_this.chart.destroy();
|
|
300
289
|
_this.chart = null;
|
|
301
290
|
};
|
|
302
|
-
_this.getLabelFontSize = function () {
|
|
303
|
-
var statItem = _this.props.statItem;
|
|
304
|
-
var label_font_size = statItem.label_font_size;
|
|
305
|
-
return getLabelFontSize(label_font_size);
|
|
306
|
-
};
|
|
307
291
|
_this.state = {
|
|
308
292
|
isCalculatingData: true,
|
|
309
293
|
showResultDescription: true
|
|
@@ -315,10 +299,10 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
315
299
|
key: "componentDidMount",
|
|
316
300
|
value: function componentDidMount() {
|
|
317
301
|
var _this2 = this;
|
|
318
|
-
var _this$
|
|
319
|
-
statItem = _this$
|
|
320
|
-
chartCalculator = _this$
|
|
321
|
-
eventBus = _this$
|
|
302
|
+
var _this$props4 = this.props,
|
|
303
|
+
statItem = _this$props4.statItem,
|
|
304
|
+
chartCalculator = _this$props4.chartCalculator,
|
|
305
|
+
eventBus = _this$props4.eventBus;
|
|
322
306
|
this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
|
|
323
307
|
_this2.renderAxisLabel(newStatItem);
|
|
324
308
|
});
|
|
@@ -339,9 +323,9 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
339
323
|
}, {
|
|
340
324
|
key: "shouldComponentUpdate",
|
|
341
325
|
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
342
|
-
var _this$
|
|
343
|
-
statItem = _this$
|
|
344
|
-
colorThemeName = _this$
|
|
326
|
+
var _this$props5 = this.props,
|
|
327
|
+
statItem = _this$props5.statItem,
|
|
328
|
+
colorThemeName = _this$props5.colorThemeName;
|
|
345
329
|
var nextStatItem = nextProps.statItem;
|
|
346
330
|
if (this.canUpdate(this.props, nextProps) || statItem.y_axises !== nextStatItem.y_axises) {
|
|
347
331
|
return true;
|
|
@@ -358,9 +342,9 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
358
342
|
key: "componentDidUpdate",
|
|
359
343
|
value: function componentDidUpdate(preProps, preState) {
|
|
360
344
|
var _this3 = this;
|
|
361
|
-
var _this$
|
|
362
|
-
statItem = _this$
|
|
363
|
-
chartCalculator = _this$
|
|
345
|
+
var _this$props6 = this.props,
|
|
346
|
+
statItem = _this$props6.statItem,
|
|
347
|
+
chartCalculator = _this$props6.chartCalculator;
|
|
364
348
|
var isCalculatingData = this.state.isCalculatingData;
|
|
365
349
|
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
366
350
|
if (this.shouldCalculateStatItem(preProps, this.props) || preProps.statItem.y_axises !== statItem.y_axises) {
|
|
@@ -412,13 +396,9 @@ var CustomBar = /*#__PURE__*/function (_BaseChart) {
|
|
|
412
396
|
showResultDescription = _this$state.showResultDescription;
|
|
413
397
|
var show_y_axis_label = statItem.show_y_axis_label,
|
|
414
398
|
show_x_axis_label = statItem.show_x_axis_label;
|
|
415
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
className: 'statistic-chart-text'
|
|
419
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
420
|
-
ref: function ref(_ref) {
|
|
421
|
-
return _this4.container = _ref;
|
|
399
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
400
|
+
ref: function ref(_ref2) {
|
|
401
|
+
return _this4.container = _ref2;
|
|
422
402
|
},
|
|
423
403
|
style: {
|
|
424
404
|
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|