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
|
@@ -6,11 +6,10 @@ import React from 'react';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import DataSet from '@antv/data-set/lib/index';
|
|
8
8
|
import intl from 'react-intl-universal';
|
|
9
|
-
import { TableUtils
|
|
9
|
+
import { TableUtils } from 'dtable-store';
|
|
10
10
|
import BaseChart from './base-chart';
|
|
11
11
|
import { Chart } from '../custom-g2';
|
|
12
|
-
import {
|
|
13
|
-
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_ITEM_THEME_COLORS, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
12
|
+
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
14
13
|
var WIDTH = 798;
|
|
15
14
|
var HEIGHT = 394;
|
|
16
15
|
var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
@@ -44,7 +43,8 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
44
43
|
name_cn: name_cn,
|
|
45
44
|
name: name,
|
|
46
45
|
nameType: nameType,
|
|
47
|
-
value: value || 0
|
|
46
|
+
value: value || 0,
|
|
47
|
+
formatted_value: item.formatted_value
|
|
48
48
|
});
|
|
49
49
|
if (type === STAT_TYPE.WORLD_MAP_BUBBLE) {
|
|
50
50
|
sum += item.value;
|
|
@@ -60,10 +60,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
60
60
|
_this.renderCommonMap = function (data) {
|
|
61
61
|
var _this$props = _this.props,
|
|
62
62
|
getTableById = _this$props.getTableById,
|
|
63
|
-
statItem = _this$props.statItem
|
|
64
|
-
theme = _this$props.theme,
|
|
65
|
-
isEnlarge = _this$props.isEnlarge,
|
|
66
|
-
isPreview = _this$props.isPreview;
|
|
63
|
+
statItem = _this$props.statItem;
|
|
67
64
|
var userDataView = _this.dataSet.getView('statisticViewModel').source(data).transform({
|
|
68
65
|
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
69
66
|
field: 'name',
|
|
@@ -74,17 +71,18 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
74
71
|
table_id = _this$props$statItem.table_id,
|
|
75
72
|
data_color = _this$props$statItem.data_color,
|
|
76
73
|
summary_type = _this$props$statItem.summary_type,
|
|
74
|
+
summary_method = _this$props$statItem.summary_method,
|
|
77
75
|
summary_column = _this$props$statItem.summary_column;
|
|
78
76
|
var currentColorOption = COLOR_OPTIONS.filter(function (item) {
|
|
79
77
|
return item.name == data_color;
|
|
80
78
|
})[0] || COLOR_OPTIONS[0];
|
|
81
79
|
var exampleColors = currentColorOption.exampleColors,
|
|
82
80
|
highlightedBorderColor = currentColorOption.highlightedBorderColor;
|
|
83
|
-
var
|
|
81
|
+
var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
84
82
|
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
85
83
|
var table = getTableById(table_id);
|
|
86
84
|
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
87
|
-
|
|
85
|
+
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
88
86
|
}
|
|
89
87
|
_this.statisticView = _this.chart.createView();
|
|
90
88
|
_this.statisticView.data(userDataView.rows);
|
|
@@ -99,17 +97,14 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
99
97
|
stroke: highlightedBorderColor
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
}).tooltip('name*
|
|
100
|
+
}).tooltip('name*formatted_value*color*nameType*name_cn', function (name, value, color, nameType, name_cn) {
|
|
103
101
|
return {
|
|
104
102
|
name: nameType === 'en' ? name : name_cn,
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
color: color,
|
|
104
|
+
value: value
|
|
107
105
|
};
|
|
108
106
|
});
|
|
109
|
-
var themeColors =
|
|
110
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
111
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
112
|
-
}
|
|
107
|
+
var themeColors = _this.getThemeColors();
|
|
113
108
|
var legendDirection = statItem.legend_direction || 'vertical';
|
|
114
109
|
var size = statItem.legend_size || 1;
|
|
115
110
|
_this.chart.legend({
|
|
@@ -126,7 +121,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
126
121
|
},
|
|
127
122
|
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
128
123
|
formatter: function formatter(value) {
|
|
129
|
-
return getNumberDisplayString(value,
|
|
124
|
+
return _this.getNumberDisplayString(value, summaryColumnData, summary_method);
|
|
130
125
|
}
|
|
131
126
|
},
|
|
132
127
|
handler: {
|
|
@@ -142,9 +137,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
142
137
|
var _this$props2 = _this.props,
|
|
143
138
|
getTableById = _this$props2.getTableById,
|
|
144
139
|
statItem = _this$props2.statItem,
|
|
145
|
-
isPreview = _this$props2.isPreview
|
|
146
|
-
isEnlarge = _this$props2.isEnlarge,
|
|
147
|
-
theme = _this$props2.theme;
|
|
140
|
+
isPreview = _this$props2.isPreview;
|
|
148
141
|
var userDv = _this.dataSet.createView().source(data).transform({
|
|
149
142
|
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
150
143
|
field: 'name',
|
|
@@ -154,12 +147,13 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
154
147
|
var _this$props$statItem2 = _this.props.statItem,
|
|
155
148
|
table_id = _this$props$statItem2.table_id,
|
|
156
149
|
summary_type = _this$props$statItem2.summary_type,
|
|
150
|
+
summary_method = _this$props$statItem2.summary_method,
|
|
157
151
|
summary_column = _this$props$statItem2.summary_column;
|
|
158
|
-
var
|
|
152
|
+
var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
159
153
|
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
160
154
|
var table = getTableById(table_id);
|
|
161
155
|
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
162
|
-
|
|
156
|
+
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
163
157
|
}
|
|
164
158
|
_this.statisticView = _this.chart.createView();
|
|
165
159
|
_this.statisticView.data(userDv.rows);
|
|
@@ -170,11 +164,11 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
170
164
|
size = 60;
|
|
171
165
|
}
|
|
172
166
|
return size;
|
|
173
|
-
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*
|
|
167
|
+
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*formatted_value*color', function (name, value, color) {
|
|
174
168
|
return {
|
|
175
169
|
name: name,
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
color: color,
|
|
171
|
+
value: value
|
|
178
172
|
};
|
|
179
173
|
}).style({
|
|
180
174
|
fillOpacity: 0.6,
|
|
@@ -188,10 +182,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
188
182
|
}
|
|
189
183
|
}
|
|
190
184
|
});
|
|
191
|
-
var themeColors =
|
|
192
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
193
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
194
|
-
}
|
|
185
|
+
var themeColors = _this.getThemeColors();
|
|
195
186
|
var legendDirection = statItem.legend_direction || 'vertical';
|
|
196
187
|
var size = statItem.legend_size || 1;
|
|
197
188
|
_this.chart.legend({
|
|
@@ -207,7 +198,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
207
198
|
},
|
|
208
199
|
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
209
200
|
formatter: function formatter(value) {
|
|
210
|
-
return getNumberDisplayString(value,
|
|
201
|
+
return _this.getNumberDisplayString(value, summaryColumnData, summary_method);
|
|
211
202
|
}
|
|
212
203
|
},
|
|
213
204
|
handler: {
|
|
@@ -286,14 +277,8 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
286
277
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
287
278
|
itemTpl: "<div class=\"g2-tooltip-content\"><div class=\"tooltip-name\">{name}<div><div class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
|
|
288
279
|
domStyles: {
|
|
289
|
-
'g2-tooltip':
|
|
290
|
-
|
|
291
|
-
backgroundColor: '#fff',
|
|
292
|
-
padding: '10px'
|
|
293
|
-
},
|
|
294
|
-
'tooltip-item': {
|
|
295
|
-
marginTop: '5px'
|
|
296
|
-
}
|
|
280
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
281
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
297
282
|
}
|
|
298
283
|
});
|
|
299
284
|
_this.chart.scale({
|
|
@@ -351,14 +336,15 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
351
336
|
isDataLoaded: true
|
|
352
337
|
});
|
|
353
338
|
if (!data) return;
|
|
339
|
+
_this2.geoData = data;
|
|
354
340
|
_this2.initStatisticContext(data);
|
|
355
341
|
if (_this2.container) {
|
|
356
|
-
chartCalculator.calculate(statItem).then(function (
|
|
342
|
+
chartCalculator.calculate(statItem).then(function (calculation) {
|
|
357
343
|
_this2.setState({
|
|
358
344
|
isCalculatingData: false
|
|
359
345
|
});
|
|
360
|
-
_this2.calculateData =
|
|
361
|
-
_this2.updateStatisticData(_this2.fixData(
|
|
346
|
+
_this2.calculateData = calculation;
|
|
347
|
+
_this2.updateStatisticData(_this2.fixData(calculation));
|
|
362
348
|
});
|
|
363
349
|
}
|
|
364
350
|
});
|
|
@@ -389,9 +375,16 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
389
375
|
isCalculatingData: true
|
|
390
376
|
});
|
|
391
377
|
if (this.container) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
378
|
+
if (this.chart) {
|
|
379
|
+
this.chart.destroy();
|
|
380
|
+
this.initStatisticContext(this.geoData);
|
|
381
|
+
}
|
|
382
|
+
chartCalculator.calculate(statItem).then(function (calculation) {
|
|
383
|
+
_this3.setState({
|
|
384
|
+
isCalculatingData: false
|
|
385
|
+
});
|
|
386
|
+
_this3.calculateData = calculation;
|
|
387
|
+
_this3.updateStatisticData(_this3.fixData(calculation));
|
|
395
388
|
if (_this3.props.isPreview) {
|
|
396
389
|
var canvasSize = _this3.getCanvasSize();
|
|
397
390
|
_this3.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
@@ -419,9 +412,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
419
412
|
var _this$state = this.state,
|
|
420
413
|
isDataLoaded = _this$state.isDataLoaded,
|
|
421
414
|
isCalculatingData = _this$state.isCalculatingData;
|
|
422
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, !isDataLoaded
|
|
423
|
-
className: 'statistic-chart-loading-container'
|
|
424
|
-
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
415
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (!isDataLoaded || isCalculatingData) && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
|
|
425
416
|
ref: function ref(_ref) {
|
|
426
417
|
return _this4.container = _ref;
|
|
427
418
|
},
|
|
@@ -433,8 +424,6 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
433
424
|
}(BaseChart);
|
|
434
425
|
WorldMap.propTypes = {
|
|
435
426
|
isPreview: PropTypes.bool,
|
|
436
|
-
isEnlarge: PropTypes.bool,
|
|
437
|
-
theme: PropTypes.string,
|
|
438
427
|
statItem: PropTypes.object,
|
|
439
428
|
chartCalculator: PropTypes.object,
|
|
440
429
|
getTableById: PropTypes.func,
|
package/es/tabs/tab.js
CHANGED
|
@@ -7,6 +7,7 @@ import React, { Component } from 'react';
|
|
|
7
7
|
import intl from 'react-intl-universal';
|
|
8
8
|
import { ModalPortal } from '../components';
|
|
9
9
|
import { isMobile } from '../utils';
|
|
10
|
+
import { THEME_NAME_MAP } from '../constants';
|
|
10
11
|
import styles from './statistic-tabs.module.css';
|
|
11
12
|
var DashBoardTab = /*#__PURE__*/function (_Component) {
|
|
12
13
|
_inherits(DashBoardTab, _Component);
|
|
@@ -141,7 +142,7 @@ var DashBoardTab = /*#__PURE__*/function (_Component) {
|
|
|
141
142
|
}, /*#__PURE__*/React.createElement("i", {
|
|
142
143
|
className: "".concat(styles['icon'], " dtable-font dtable-icon-drop-down")
|
|
143
144
|
}), isShowViewDropdown && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
className: "".concat(theme ===
|
|
145
|
+
className: "".concat(theme === THEME_NAME_MAP.DARK ? 'statistic-tabs-dropdown-dark' : 'statistic-tabs-dropdown-light', " statistic-dropdown-menu dropdown-menu large show"),
|
|
145
146
|
style: _objectSpread(_objectSpread({}, dropdownMenuPosition), {}, {
|
|
146
147
|
zIndex: 1500
|
|
147
148
|
})
|
package/es/utils/common-utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, generatorBase64Code, isNumber, TableUtils } from 'dtable-store';
|
|
2
2
|
import { STAT_TYPE, DEFAULT_LABEL_FONT_SIZE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, CHART_STYLE_COLORS, PIE_COLOR_OPTIONS, SUMMARY_METHOD_MAP } from '../constants';
|
|
3
|
+
import StatUtils from './stat-utils';
|
|
3
4
|
export var generatorUniqueId = function generatorUniqueId(list) {
|
|
4
5
|
var uniqueId;
|
|
5
6
|
var isUnique = false;
|
|
@@ -134,27 +135,45 @@ export var isArrayCellValue = function isArrayCellValue(column) {
|
|
|
134
135
|
|
|
135
136
|
export var getSummaryResult = function getSummaryResult(results, summaryMethod) {
|
|
136
137
|
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
138
|
+
var numericResults = Array.isArray(results) && results.length > 0 ? results.filter(function (res) {
|
|
139
|
+
return isNumber(res);
|
|
140
|
+
}) : [];
|
|
137
141
|
switch (summaryMethod) {
|
|
138
142
|
case SUMMARY_METHOD_MAP.Max:
|
|
139
143
|
{
|
|
140
|
-
return getMax(
|
|
144
|
+
return getMax(numericResults);
|
|
141
145
|
}
|
|
142
146
|
case SUMMARY_METHOD_MAP.Min:
|
|
143
147
|
{
|
|
144
|
-
return getMin(
|
|
148
|
+
return getMin(numericResults);
|
|
145
149
|
}
|
|
146
150
|
case SUMMARY_METHOD_MAP.Sum:
|
|
147
151
|
{
|
|
148
|
-
return getSum(
|
|
152
|
+
return getSum(numericResults, precision);
|
|
149
153
|
}
|
|
150
154
|
case SUMMARY_METHOD_MAP.Mean:
|
|
151
155
|
{
|
|
152
|
-
return getMean(
|
|
156
|
+
return getMean(numericResults, precision);
|
|
153
157
|
}
|
|
154
158
|
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
155
159
|
{
|
|
156
|
-
var
|
|
157
|
-
|
|
160
|
+
var count = 0;
|
|
161
|
+
var existMap = {};
|
|
162
|
+
Array.isArray(results) && results.forEach(function (resNum) {
|
|
163
|
+
var num = resNum;
|
|
164
|
+
if (!num) {
|
|
165
|
+
if (num === 0) {
|
|
166
|
+
num = '0';
|
|
167
|
+
} else {
|
|
168
|
+
num = !!num;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!existMap[num]) {
|
|
172
|
+
existMap[num] = true;
|
|
173
|
+
count++;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return count;
|
|
158
177
|
}
|
|
159
178
|
default:
|
|
160
179
|
{
|
|
@@ -292,12 +311,10 @@ export var sortDataByGroupSum = function sortDataByGroupSum(data, sortType) {
|
|
|
292
311
|
});
|
|
293
312
|
}
|
|
294
313
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
};
|
|
300
|
-
return nameSumMap.sort(sortSum).reduce(function (accumulator, currentItem) {
|
|
314
|
+
|
|
315
|
+
// sort group
|
|
316
|
+
StatUtils.sortDataByKey(nameSumMap, 'valueSum', sortType);
|
|
317
|
+
return nameSumMap.reduce(function (accumulator, currentItem) {
|
|
301
318
|
return accumulator.concat(currentItem.items);
|
|
302
319
|
}, []);
|
|
303
320
|
};
|
package/es/utils/sql-utils.js
CHANGED
|
@@ -101,7 +101,8 @@ export var getSqlString = function getSqlString(statItem, statisticRecord, _ref)
|
|
|
101
101
|
return sqlString;
|
|
102
102
|
};
|
|
103
103
|
var getSqlGroupName = function getSqlGroupName(name, original_name, column) {
|
|
104
|
-
var
|
|
104
|
+
var _ref2 = column || {},
|
|
105
|
+
type = _ref2.type;
|
|
105
106
|
if (type === CellType.SINGLE_SELECT || type === CellType.MULTIPLE_SELECT) {
|
|
106
107
|
return "'".concat(name, "'");
|
|
107
108
|
}
|
|
@@ -111,9 +112,9 @@ var getSqlGroupName = function getSqlGroupName(name, original_name, column) {
|
|
|
111
112
|
}
|
|
112
113
|
return "'".concat(newName, "'");
|
|
113
114
|
};
|
|
114
|
-
var getGroupName = function getGroupName(selectedColumn,
|
|
115
|
-
var groupby_date_granularity =
|
|
116
|
-
groupby_geolocation_granularity =
|
|
115
|
+
var getGroupName = function getGroupName(selectedColumn, _ref3) {
|
|
116
|
+
var groupby_date_granularity = _ref3.groupby_date_granularity,
|
|
117
|
+
groupby_geolocation_granularity = _ref3.groupby_geolocation_granularity;
|
|
117
118
|
var groupName = "`".concat(selectedColumn.name, "`");
|
|
118
119
|
var isTimeColumn = TIME_COLUMN_LIST.includes(selectedColumn.type);
|
|
119
120
|
if (isTimeColumn) {
|
|
@@ -123,11 +124,11 @@ var getGroupName = function getGroupName(selectedColumn, _ref2) {
|
|
|
123
124
|
}
|
|
124
125
|
return groupName;
|
|
125
126
|
};
|
|
126
|
-
var getDatabaseGroupName = function getDatabaseGroupName(statItem, selectedTable,
|
|
127
|
-
var
|
|
128
|
-
isColumn =
|
|
129
|
-
|
|
130
|
-
isCurrentView =
|
|
127
|
+
var getDatabaseGroupName = function getDatabaseGroupName(statItem, selectedTable, _ref4) {
|
|
128
|
+
var _ref4$isColumn = _ref4.isColumn,
|
|
129
|
+
isColumn = _ref4$isColumn === void 0 ? false : _ref4$isColumn,
|
|
130
|
+
_ref4$isCurrentView = _ref4.isCurrentView,
|
|
131
|
+
isCurrentView = _ref4$isCurrentView === void 0 ? false : _ref4$isCurrentView;
|
|
131
132
|
if (isCurrentView) return '';
|
|
132
133
|
var type = statItem.type;
|
|
133
134
|
var groupName, selectedColumn, columnGroupName, columnSelectedColumn;
|
package/es/utils/stat-utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
import { DateUtils, isNumber, isNumericColumn, CellType, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, sortText, sortNumber, sortDate, sortSingleSelect, getPrecisionNumber, getFormulaDisplayString, getGeolocationDisplayString, getDateDisplayString, getNumberDisplayString } from 'dtable-store';
|
|
4
4
|
import { getClientFormulaDisplayString } from '../utils';
|
|
5
|
-
import { STATISTICS_COUNT_TYPE } from '../constants';
|
|
5
|
+
import { DATA_SORT_TYPE, STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP } from '../constants';
|
|
6
6
|
var SUPPORT_SORT_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.SINGLE_SELECT, CellType.FORMULA, CellType.LINK_FORMULA, CellType.CTIME, CellType.MTIME, CellType.RATE];
|
|
7
7
|
var getValidCollaborators = function getValidCollaborators(collaborators, emails) {
|
|
8
8
|
if (!Array.isArray(emails)) {
|
|
@@ -207,24 +207,29 @@ var StatUtils = /*#__PURE__*/function () {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
}, {
|
|
210
|
-
key: "
|
|
211
|
-
value: function
|
|
212
|
-
|
|
213
|
-
var
|
|
214
|
-
var
|
|
215
|
-
if (!
|
|
210
|
+
key: "sortDataByKey",
|
|
211
|
+
value: function sortDataByKey(data, key, sortType) {
|
|
212
|
+
data.sort(function (curr, next) {
|
|
213
|
+
var currentVal = curr[key];
|
|
214
|
+
var nextVal = next[key];
|
|
215
|
+
if (!currentVal && currentVal !== 0) {
|
|
216
216
|
return -1;
|
|
217
217
|
}
|
|
218
|
-
if (!
|
|
218
|
+
if (!nextVal && nextVal !== 0) {
|
|
219
219
|
return 1;
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
222
|
-
return
|
|
221
|
+
if (sortType === DATA_SORT_TYPE.ASCENDING) {
|
|
222
|
+
return currentVal > nextVal ? 1 : -1;
|
|
223
223
|
} else {
|
|
224
|
-
return
|
|
224
|
+
return currentVal > nextVal ? -1 : 1;
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "sortStatisticData",
|
|
230
|
+
value: function sortStatisticData(statistics, sort_type) {
|
|
231
|
+
this.sortDataByKey(statistics, 'value', sort_type);
|
|
232
|
+
}
|
|
228
233
|
}, {
|
|
229
234
|
key: "getTotal",
|
|
230
235
|
value: function getTotal(summary_column_key, summary_column_type, summary_type, summary_method) {
|
|
@@ -337,18 +342,21 @@ var StatUtils = /*#__PURE__*/function () {
|
|
|
337
342
|
}
|
|
338
343
|
}, {
|
|
339
344
|
key: "getFormattedValue",
|
|
340
|
-
value: function getFormattedValue(value, column) {
|
|
345
|
+
value: function getFormattedValue(value, column, summaryMethod) {
|
|
341
346
|
if (!column) {
|
|
342
347
|
return value;
|
|
343
348
|
}
|
|
349
|
+
if (summaryMethod === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
350
|
+
return value;
|
|
351
|
+
}
|
|
344
352
|
var type = column.type,
|
|
345
353
|
data = column.data;
|
|
346
|
-
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
347
|
-
return getClientFormulaDisplayString(value, data);
|
|
348
|
-
}
|
|
349
354
|
if (isNumericColumn(column)) {
|
|
350
355
|
return getNumberDisplayString(value, data);
|
|
351
356
|
}
|
|
357
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
358
|
+
return getClientFormulaDisplayString(value, data);
|
|
359
|
+
}
|
|
352
360
|
return value;
|
|
353
361
|
}
|
|
354
362
|
}]);
|
package/es/utils/trend-utils.js
CHANGED
|
@@ -78,7 +78,7 @@ export function summaryDurationResult(result, duration, summaryType, summaryMeth
|
|
|
78
78
|
var days = duration === 'days_30' ? 30 : 7;
|
|
79
79
|
var endDate = currentTime.format('YYYY-MM-DD');
|
|
80
80
|
var middleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
81
|
-
var startDate =
|
|
81
|
+
var startDate = dayjs(middleDate).subtract(days, 'days').format('YYYY-MM-DD');
|
|
82
82
|
var compareValue = [];
|
|
83
83
|
var comparedValue = [];
|
|
84
84
|
if (useDataDb) {
|