dtable-statistic 4.0.7 → 4.0.9
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/model/ring.js +3 -2
- 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/pivot-table-settings.js +4 -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 +81 -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 +207 -231
- 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/pivot-table/two-dimension-table.js +98 -31
- 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 +29 -12
- package/es/utils/sql-utils.js +10 -9
- package/es/utils/stat-utils.js +23 -15
- package/es/utils/trend-utils.js +1 -1
- package/package.json +1 -1
package/es/stat-view/mirror.js
CHANGED
|
@@ -5,11 +5,10 @@ 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 { DEFAULT_NUMBER_FORMAT_OBJECT, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
11
|
+
import { DEFAULT_NUMBER_FORMAT_OBJECT, STATISTICS_COUNT_SHOW, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
13
12
|
var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
14
13
|
_inherits(Mirror, _BaseChart);
|
|
15
14
|
var _super = _createSuper(Mirror);
|
|
@@ -17,49 +16,94 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
17
16
|
var _this;
|
|
18
17
|
_classCallCheck(this, Mirror);
|
|
19
18
|
_this = _super.call(this, props);
|
|
19
|
+
_this.destroyChart = function () {
|
|
20
|
+
_this.chart.destroy();
|
|
21
|
+
_this.chart = null;
|
|
22
|
+
};
|
|
20
23
|
_this.drawChart = function (_ref) {
|
|
21
24
|
var data = _ref.data,
|
|
22
25
|
colorSet = _ref.colorSet;
|
|
23
26
|
var _this$props = _this.props,
|
|
24
27
|
getTableById = _this$props.getTableById,
|
|
25
|
-
|
|
26
|
-
statItem = _this$props.statItem,
|
|
27
|
-
isEnlarge = _this$props.isEnlarge,
|
|
28
|
-
theme = _this$props.theme;
|
|
28
|
+
statItem = _this$props.statItem;
|
|
29
29
|
var table_id = statItem.table_id,
|
|
30
30
|
summary_type = statItem.summary_type,
|
|
31
31
|
summary_method = statItem.summary_method,
|
|
32
|
-
is_transpose = statItem.is_transpose,
|
|
33
32
|
summary_column = statItem.summary_column;
|
|
34
|
-
|
|
35
|
-
_this.chart = new Chart({
|
|
36
|
-
container: _this.container,
|
|
37
|
-
autoFit: true,
|
|
38
|
-
padding: is_transpose ? [35, 10, 30, 10] : [10, 100, 30, 10]
|
|
39
|
-
});
|
|
40
|
-
} else {
|
|
41
|
-
_this.chart = new Chart({
|
|
42
|
-
container: _this.container,
|
|
43
|
-
autoFit: true,
|
|
44
|
-
height: 520,
|
|
45
|
-
width: 800,
|
|
46
|
-
padding: is_transpose ? [35, 30, 30, 30] : [30, 100, 30, 30]
|
|
47
|
-
});
|
|
48
|
-
}
|
|
33
|
+
_this.initChartHandler();
|
|
49
34
|
_this.chart.on('element:click', function (e) {
|
|
50
35
|
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
51
36
|
});
|
|
52
|
-
var themeColors =
|
|
53
|
-
|
|
54
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
55
|
-
}
|
|
56
|
-
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
37
|
+
var themeColors = _this.getThemeColors();
|
|
38
|
+
var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
57
39
|
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
58
40
|
var table = getTableById(table_id);
|
|
59
41
|
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
60
|
-
|
|
42
|
+
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
61
43
|
}
|
|
62
44
|
_this.chart.data(data);
|
|
45
|
+
_this.setAxis(themeColors);
|
|
46
|
+
_this.setScale(summaryColumnData);
|
|
47
|
+
_this.setTooltip();
|
|
48
|
+
_this.chart.facet('mirror', {
|
|
49
|
+
fields: ['group_name'],
|
|
50
|
+
transpose: statItem.is_transpose,
|
|
51
|
+
padding: 'auto',
|
|
52
|
+
title: {
|
|
53
|
+
style: {
|
|
54
|
+
fill: themeColors.textColor
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
eachView: function eachView(view, facet) {
|
|
58
|
+
if (facet.rowValue && facet.rowValue.length > 5) {
|
|
59
|
+
facet.rowValue = facet.rowValue.slice(0, 5) + '...';
|
|
60
|
+
}
|
|
61
|
+
view.interval().position('name*value').color('group_name', colorSet).tooltip('name*formatted_value', function (name, value) {
|
|
62
|
+
return {
|
|
63
|
+
title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method]),
|
|
64
|
+
name: name,
|
|
65
|
+
value: value
|
|
66
|
+
};
|
|
67
|
+
}).state({
|
|
68
|
+
active: {
|
|
69
|
+
style: function style(element) {
|
|
70
|
+
return {
|
|
71
|
+
fillOpacity: 0.6
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
view.interaction('active-region');
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
_this.chart.legend({
|
|
80
|
+
itemName: {
|
|
81
|
+
style: {
|
|
82
|
+
fill: themeColors.textColor
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
_this.chart.render();
|
|
87
|
+
};
|
|
88
|
+
_this.initChartHandler = function () {
|
|
89
|
+
var _this$props2 = _this.props,
|
|
90
|
+
isPreview = _this$props2.isPreview,
|
|
91
|
+
statItem = _this$props2.statItem;
|
|
92
|
+
var is_transpose = statItem.is_transpose;
|
|
93
|
+
var config = {
|
|
94
|
+
container: _this.container,
|
|
95
|
+
autoFit: true
|
|
96
|
+
};
|
|
97
|
+
if (isPreview) {
|
|
98
|
+
config.padding = is_transpose ? [35, 10, 30, 10] : [10, 100, 30, 10];
|
|
99
|
+
} else {
|
|
100
|
+
config.height = 520;
|
|
101
|
+
config.width = 800;
|
|
102
|
+
config.padding = is_transpose ? [35, 30, 30, 30] : [30, 100, 30, 30];
|
|
103
|
+
}
|
|
104
|
+
_this.chart = new Chart(config);
|
|
105
|
+
};
|
|
106
|
+
_this.setAxis = function (themeColors) {
|
|
63
107
|
_this.chart.axis('name', {
|
|
64
108
|
line: {
|
|
65
109
|
style: themeColors.gridColor
|
|
@@ -91,6 +135,9 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
91
135
|
}
|
|
92
136
|
}
|
|
93
137
|
});
|
|
138
|
+
};
|
|
139
|
+
_this.setScale = function (summaryColumnData) {
|
|
140
|
+
var summary_method = _this.props.statItem.summary_method;
|
|
94
141
|
_this.chart.scale({
|
|
95
142
|
name: {
|
|
96
143
|
sync: true
|
|
@@ -98,7 +145,7 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
98
145
|
value: {
|
|
99
146
|
sync: true,
|
|
100
147
|
formatter: function formatter(value) {
|
|
101
|
-
return getNumberDisplayString(value,
|
|
148
|
+
return _this.getNumberDisplayString(value, summaryColumnData, summary_method);
|
|
102
149
|
}
|
|
103
150
|
},
|
|
104
151
|
group_name: {
|
|
@@ -108,65 +155,18 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
108
155
|
sync: true
|
|
109
156
|
}
|
|
110
157
|
});
|
|
158
|
+
};
|
|
159
|
+
_this.setTooltip = function () {
|
|
111
160
|
_this.chart.tooltip({
|
|
112
161
|
showTitle: true,
|
|
113
162
|
showMarkers: false,
|
|
114
163
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
115
164
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
116
165
|
domStyles: {
|
|
117
|
-
'g2-tooltip':
|
|
118
|
-
|
|
119
|
-
backgroundColor: '#fff',
|
|
120
|
-
padding: '10px'
|
|
121
|
-
},
|
|
122
|
-
'tooltip-item': {
|
|
123
|
-
marginTop: '5px'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
_this.chart.facet('mirror', {
|
|
128
|
-
fields: ['group_name'],
|
|
129
|
-
transpose: statItem.is_transpose,
|
|
130
|
-
padding: 'auto',
|
|
131
|
-
title: {
|
|
132
|
-
style: {
|
|
133
|
-
fill: themeColors.textColor
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
eachView: function eachView(view, facet) {
|
|
137
|
-
if (facet.rowValue && facet.rowValue.length > 5) {
|
|
138
|
-
facet.rowValue = facet.rowValue.slice(0, 5) + '...';
|
|
139
|
-
}
|
|
140
|
-
view.interval().position('name*value').color('group_name', colorSet).tooltip('name*value', function (name, value) {
|
|
141
|
-
return {
|
|
142
|
-
title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method]),
|
|
143
|
-
value: getNumberDisplayString(value, columnData),
|
|
144
|
-
name: name
|
|
145
|
-
};
|
|
146
|
-
}).state({
|
|
147
|
-
active: {
|
|
148
|
-
style: function style(element) {
|
|
149
|
-
return {
|
|
150
|
-
fillOpacity: 0.6
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
view.interaction('active-region');
|
|
166
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
167
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
156
168
|
}
|
|
157
169
|
});
|
|
158
|
-
_this.chart.legend({
|
|
159
|
-
itemName: {
|
|
160
|
-
style: {
|
|
161
|
-
fill: themeColors.textColor
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
_this.chart.render();
|
|
166
|
-
};
|
|
167
|
-
_this.destroyChart = function () {
|
|
168
|
-
_this.chart.destroy();
|
|
169
|
-
_this.chart = null;
|
|
170
170
|
};
|
|
171
171
|
_this.state = {
|
|
172
172
|
isCalculatingData: true,
|
|
@@ -179,9 +179,9 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
179
179
|
key: "componentDidMount",
|
|
180
180
|
value: function componentDidMount() {
|
|
181
181
|
var _this2 = this;
|
|
182
|
-
var _this$
|
|
183
|
-
statItem = _this$
|
|
184
|
-
chartCalculator = _this$
|
|
182
|
+
var _this$props3 = this.props,
|
|
183
|
+
statItem = _this$props3.statItem,
|
|
184
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
185
185
|
if (this.container) {
|
|
186
186
|
chartCalculator.calculate(statItem).then(function (data) {
|
|
187
187
|
var showResultDescription = data.colorSet && data.colorSet.length > 0 ? false : true;
|
|
@@ -212,9 +212,9 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
212
212
|
key: "componentDidUpdate",
|
|
213
213
|
value: function componentDidUpdate(preProps, preState) {
|
|
214
214
|
var _this3 = this;
|
|
215
|
-
var _this$
|
|
216
|
-
statItem = _this$
|
|
217
|
-
chartCalculator = _this$
|
|
215
|
+
var _this$props4 = this.props,
|
|
216
|
+
statItem = _this$props4.statItem,
|
|
217
|
+
chartCalculator = _this$props4.chartCalculator;
|
|
218
218
|
var isCalculatingData = this.state.isCalculatingData;
|
|
219
219
|
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
220
220
|
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
@@ -259,11 +259,7 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
259
259
|
var _this$state = this.state,
|
|
260
260
|
isCalculatingData = _this$state.isCalculatingData,
|
|
261
261
|
showResultDescription = _this$state.showResultDescription;
|
|
262
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
263
|
-
className: 'statistic-chart-loading-container'
|
|
264
|
-
}, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
265
|
-
className: 'statistic-chart-text'
|
|
266
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
262
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
267
263
|
ref: function ref(_ref2) {
|
|
268
264
|
return _this4.container = _ref2;
|
|
269
265
|
},
|
|
@@ -275,8 +271,6 @@ var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
|
275
271
|
}(BaseChart);
|
|
276
272
|
Mirror.propTypes = {
|
|
277
273
|
isPreview: PropTypes.bool,
|
|
278
|
-
isEnlarge: PropTypes.bool,
|
|
279
|
-
theme: PropTypes.string,
|
|
280
274
|
statItem: PropTypes.object,
|
|
281
275
|
chartCalculator: PropTypes.object,
|
|
282
276
|
getTableById: PropTypes.func,
|
|
@@ -5,17 +5,13 @@ 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, getNumberDisplayString } from 'dtable-store';
|
|
9
8
|
import BaseChart from './base-chart';
|
|
10
9
|
import { Chart } from '../custom-g2';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS, NO_STATISTIC_RESULTS, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE } from '../constants';
|
|
10
|
+
import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
|
|
11
|
+
import { EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS } from '../constants';
|
|
14
12
|
import chartStyles from '../assets/css/statistic-chart.module.css';
|
|
15
13
|
var propTypes = {
|
|
16
14
|
isPreview: PropTypes.bool,
|
|
17
|
-
isEnlarge: PropTypes.bool,
|
|
18
|
-
theme: PropTypes.string,
|
|
19
15
|
colorThemeName: PropTypes.string,
|
|
20
16
|
statItem: PropTypes.object,
|
|
21
17
|
chartCalculator: PropTypes.object,
|
|
@@ -52,32 +48,19 @@ var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
52
48
|
if (data.length === 0) return;
|
|
53
49
|
var _this$props = _this.props,
|
|
54
50
|
getTableById = _this$props.getTableById,
|
|
55
|
-
theme = _this$props.theme,
|
|
56
|
-
isEnlarge = _this$props.isEnlarge,
|
|
57
|
-
isPreview = _this$props.isPreview,
|
|
58
51
|
statItem = _this$props.statItem,
|
|
59
52
|
colorThemeName = _this$props.colorThemeName;
|
|
60
53
|
_this.chart.coordinate('theta', {
|
|
61
54
|
radius: isCreating ? 0.75 : 0.95
|
|
62
55
|
});
|
|
63
|
-
var
|
|
64
|
-
summary_column_key = statItem.summary_column_key,
|
|
65
|
-
table_id = statItem.table_id,
|
|
56
|
+
var table_id = statItem.table_id,
|
|
66
57
|
show_legend = statItem.show_legend,
|
|
67
58
|
show_percent = statItem.show_percent,
|
|
68
59
|
display_label = statItem.display_label,
|
|
69
60
|
label_position = statItem.label_position;
|
|
70
|
-
var currentTheme = getCurrentTheme(colorThemeName);
|
|
71
|
-
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
72
61
|
var table = getTableById(table_id);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
76
|
-
}
|
|
77
|
-
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
78
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
79
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
80
|
-
}
|
|
62
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
63
|
+
var themeColors = _this.getThemeColors();
|
|
81
64
|
var newData = formatPieChartData(data, statItem, table, currentTheme);
|
|
82
65
|
_this.chart.data(newData, {
|
|
83
66
|
'name': {
|
|
@@ -130,10 +113,9 @@ var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
130
113
|
nice: false
|
|
131
114
|
}
|
|
132
115
|
});
|
|
133
|
-
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('
|
|
134
|
-
var displayedValue = getNumberDisplayString(value, columnData);
|
|
116
|
+
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('formatted_value*percent', function (value, percent) {
|
|
135
117
|
return {
|
|
136
|
-
content: _this.getLabel(
|
|
118
|
+
content: _this.getLabel(value, percent)
|
|
137
119
|
};
|
|
138
120
|
}, {
|
|
139
121
|
offset: !label_position || label_position == LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
|
|
@@ -143,20 +125,19 @@ var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
143
125
|
shadowBlur: 2,
|
|
144
126
|
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
145
127
|
}
|
|
146
|
-
}).tooltip('name*
|
|
128
|
+
}).tooltip('name*formatted_value*percent', function (name, value, percent) {
|
|
147
129
|
var title = name;
|
|
148
130
|
if (!name || name === 'undefined') {
|
|
149
131
|
title = intl.get(EMPTY_NAME);
|
|
150
132
|
} else if (name === 'Others') {
|
|
151
133
|
title = intl.get('Others');
|
|
152
134
|
}
|
|
153
|
-
var displayedValue = getNumberDisplayString(value, columnData);
|
|
154
135
|
return show_percent || display_label ? {
|
|
155
136
|
name: title,
|
|
156
|
-
value: _this.getLabel(
|
|
137
|
+
value: _this.getLabel(value, percent)
|
|
157
138
|
} : {
|
|
158
139
|
name: title,
|
|
159
|
-
value:
|
|
140
|
+
value: value
|
|
160
141
|
};
|
|
161
142
|
}).state({
|
|
162
143
|
active: {
|
|
@@ -208,11 +189,6 @@ var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
208
189
|
_this.chart.destroy();
|
|
209
190
|
_this.chart = null;
|
|
210
191
|
};
|
|
211
|
-
_this.getLabelFontSize = function () {
|
|
212
|
-
var statItem = _this.props.statItem;
|
|
213
|
-
var label_font_size = statItem.label_font_size;
|
|
214
|
-
return getLabelFontSize(label_font_size);
|
|
215
|
-
};
|
|
216
192
|
_this.state = {
|
|
217
193
|
isCalculatingData: true,
|
|
218
194
|
showResultDescription: true
|
|
@@ -308,11 +284,7 @@ var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
308
284
|
var _this$state = this.state,
|
|
309
285
|
isCalculatingData = _this$state.isCalculatingData,
|
|
310
286
|
showResultDescription = _this$state.showResultDescription;
|
|
311
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
312
|
-
className: 'statistic-chart-loading-container'
|
|
313
|
-
}, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
314
|
-
className: 'statistic-chart-text'
|
|
315
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
287
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
316
288
|
ref: function ref(_ref) {
|
|
317
289
|
return _this4.container = _ref;
|
|
318
290
|
},
|
|
@@ -10,8 +10,7 @@ import BaseChart from '../base-chart';
|
|
|
10
10
|
import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
|
|
11
11
|
import TwoDimensionTable from './two-dimension-table';
|
|
12
12
|
import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
|
|
13
|
-
import {
|
|
14
|
-
import { TIME_COLUMN_LIST, STAT_ITEM_THEME_COLORS, DEFAULT_NUMBER_FORMAT_OBJECT, SUMMARY_TYPE, NO_STATISTIC_RESULTS, TOO_MANY_STATISTIC_ENTRIES } from '../../constants';
|
|
13
|
+
import { TIME_COLUMN_LIST, DEFAULT_NUMBER_FORMAT_OBJECT, SUMMARY_TYPE, TOO_MANY_STATISTIC_ENTRIES } from '../../constants';
|
|
15
14
|
import styles from './statistic-pivot-table.module.css';
|
|
16
15
|
var PivotTable = /*#__PURE__*/function (_BaseChart) {
|
|
17
16
|
_inherits(PivotTable, _BaseChart);
|
|
@@ -28,17 +27,12 @@ var PivotTable = /*#__PURE__*/function (_BaseChart) {
|
|
|
28
27
|
var _this$props = _this.props,
|
|
29
28
|
statItem = _this$props.statItem,
|
|
30
29
|
isPreview = _this$props.isPreview,
|
|
31
|
-
theme = _this$props.theme,
|
|
32
|
-
isEnlarge = _this$props.isEnlarge,
|
|
33
30
|
getTableById = _this$props.getTableById;
|
|
34
31
|
var statData = _this.state.statData;
|
|
35
32
|
if (!Object.keys(statData).length > 0) return '';
|
|
36
33
|
var pivot_columns = statData.pivot_columns;
|
|
37
34
|
var column_groupby_column_key = statItem.column_groupby_column_key;
|
|
38
|
-
var themeColors = '#212529';
|
|
39
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
40
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
41
|
-
}
|
|
35
|
+
var themeColors = _this.getThemeColors('#212529');
|
|
42
36
|
if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
|
|
43
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
38
|
className: 'statistic-chart-text'
|
|
@@ -176,9 +170,7 @@ var PivotTable = /*#__PURE__*/function (_BaseChart) {
|
|
|
176
170
|
var _this$state = this.state,
|
|
177
171
|
isCalculatingData = _this$state.isCalculatingData,
|
|
178
172
|
showResultDescription = _this$state.showResultDescription;
|
|
179
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData
|
|
180
|
-
className: 'statistic-chart-loading-container'
|
|
181
|
-
}, /*#__PURE__*/React.createElement(Loading, null)) : /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), !isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
182
174
|
ref: function ref(_ref2) {
|
|
183
175
|
return _this4.container = _ref2;
|
|
184
176
|
},
|
|
@@ -186,18 +178,14 @@ var PivotTable = /*#__PURE__*/function (_BaseChart) {
|
|
|
186
178
|
padding: '15px 30px'
|
|
187
179
|
} : null,
|
|
188
180
|
className: "statistic-chart-container ".concat(styles['pivot-table-container'])
|
|
189
|
-
}, this.renderPivotTable()), showResultDescription &&
|
|
190
|
-
className: 'statistic-chart-text'
|
|
191
|
-
}, intl.get(NO_STATISTIC_RESULTS)));
|
|
181
|
+
}, this.renderPivotTable()), showResultDescription && this.renderEmpty());
|
|
192
182
|
}
|
|
193
183
|
}]);
|
|
194
184
|
return PivotTable;
|
|
195
185
|
}(BaseChart);
|
|
196
186
|
PivotTable.propTypes = {
|
|
197
187
|
isPreview: PropTypes.bool,
|
|
198
|
-
isEnlarge: PropTypes.bool,
|
|
199
188
|
isEdit: PropTypes.bool,
|
|
200
|
-
theme: PropTypes.string,
|
|
201
189
|
statItem: PropTypes.object,
|
|
202
190
|
chartCalculator: PropTypes.object,
|
|
203
191
|
getTableById: PropTypes.func,
|
|
@@ -20,46 +20,51 @@ var OneDimensionTableNoNumericColumns = /*#__PURE__*/function (_PureComponent) {
|
|
|
20
20
|
}
|
|
21
21
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
22
|
_this.toggleRecords = function (cell) {
|
|
23
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
24
|
+
_ref$isColumn = _ref.isColumn,
|
|
25
|
+
isColumn = _ref$isColumn === void 0 ? false : _ref$isColumn,
|
|
26
|
+
_ref$isRow = _ref.isRow,
|
|
27
|
+
isRow = _ref$isRow === void 0 ? false : _ref$isRow;
|
|
23
28
|
if (isMobile) return;
|
|
24
|
-
_this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem
|
|
29
|
+
_this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem, {
|
|
30
|
+
isColumn: isColumn,
|
|
31
|
+
isRow: isRow
|
|
32
|
+
});
|
|
25
33
|
};
|
|
26
34
|
_this.onClickTotals = function (recordsList) {
|
|
27
|
-
var
|
|
28
|
-
isCurrentView =
|
|
35
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
36
|
+
isCurrentView = _ref2.isCurrentView;
|
|
29
37
|
if (isMobile) return;
|
|
30
38
|
var _this$props = _this.props,
|
|
31
39
|
getTableById = _this$props.getTableById,
|
|
32
40
|
statItem = _this$props.statItem;
|
|
33
|
-
var rows = [];
|
|
34
41
|
var table_id = statItem.table_id,
|
|
35
42
|
view_id = statItem.view_id;
|
|
36
43
|
var table = getTableById(table_id);
|
|
37
44
|
var view = Views.getViewById(table.views, view_id);
|
|
38
|
-
|
|
39
|
-
rows = recordsList.flat();
|
|
40
|
-
}
|
|
45
|
+
var rows = !Views.isArchiveView(view) ? recordsList.flat() : [];
|
|
41
46
|
_this.props.toggleStatisticRecordsDialog({
|
|
42
47
|
rows: rows
|
|
43
48
|
}, _this.props.statItem, {
|
|
44
49
|
isCurrentView: isCurrentView
|
|
45
50
|
});
|
|
46
51
|
};
|
|
47
|
-
_this.renderHeader = function (
|
|
48
|
-
var groupByColumn =
|
|
52
|
+
_this.renderHeader = function (_ref3) {
|
|
53
|
+
var groupByColumn = _ref3.groupByColumn;
|
|
49
54
|
var statItem = _this.props.statItem;
|
|
50
55
|
var _statItem$display_tot = statItem.display_total,
|
|
51
56
|
display_total = _statItem$display_tot === void 0 ? true : _statItem$display_tot;
|
|
52
|
-
var
|
|
53
|
-
groupName =
|
|
57
|
+
var _ref4 = groupByColumn || {},
|
|
58
|
+
groupName = _ref4.name;
|
|
54
59
|
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
55
60
|
className: "pivot-table-header"
|
|
56
61
|
}, /*#__PURE__*/React.createElement("div", null, groupName)), display_total && /*#__PURE__*/React.createElement("th", {
|
|
57
62
|
className: 'pivot-table-header'
|
|
58
63
|
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL)))));
|
|
59
64
|
};
|
|
60
|
-
_this.renderRows = function (
|
|
61
|
-
var table =
|
|
62
|
-
groupByColumn =
|
|
65
|
+
_this.renderRows = function (_ref5) {
|
|
66
|
+
var table = _ref5.table,
|
|
67
|
+
groupByColumn = _ref5.groupByColumn;
|
|
63
68
|
var _this$props2 = _this.props,
|
|
64
69
|
pivotResult = _this$props2.pivotResult,
|
|
65
70
|
statItem = _this$props2.statItem,
|
|
@@ -92,7 +97,9 @@ var OneDimensionTableNoNumericColumns = /*#__PURE__*/function (_PureComponent) {
|
|
|
92
97
|
className: "".concat(styles['pivot-cell'], " ").concat(isValidTotalDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
93
98
|
title: isValidTotalDisplayValue ? totalDisplayValue : '',
|
|
94
99
|
onClick: function onClick() {
|
|
95
|
-
return _this.toggleRecords(rowItem
|
|
100
|
+
return _this.toggleRecords(rowItem, {
|
|
101
|
+
isRow: true
|
|
102
|
+
});
|
|
96
103
|
}
|
|
97
104
|
}, isValidTotalDisplayValue ? /*#__PURE__*/React.createElement("div", null, totalDisplayValue) : /*#__PURE__*/React.createElement("i", null)));
|
|
98
105
|
}), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|