dtable-statistic 4.3.6 → 4.3.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/base-calculator.js +16 -5
- package/es/calculator/basic-chart-calculator.js +17 -31
- package/es/calculator/combination-calculator.js +20 -34
- package/es/calculator/compare-bar-calculator.js +9 -20
- package/es/calculator/completeness-calculator.js +10 -24
- package/es/calculator/dashboard-calculator.js +6 -20
- package/es/calculator/heat-map-calculator.js +6 -20
- package/es/calculator/horizontal-bar-calculator.js +2 -13
- package/es/calculator/index.js +2 -0
- package/es/calculator/map-calculator.js +7 -21
- package/es/calculator/mirror-calculator.js +8 -22
- package/es/calculator/number-card-calculator.js +4 -18
- package/es/calculator/pivot-table-calculator.js +40 -54
- package/es/calculator/scatter-calculator.js +6 -20
- package/es/calculator/thread-manager.js +41 -41
- package/es/calculator/trend-calculator.js +6 -20
- package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
- package/es/calculator/workers/calculator.worker.js +5 -2
- package/es/calculator/workers/card-calculator-worker.js +13 -9
- package/es/calculator/workers/combination-calculator-worker.js +20 -16
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
- package/es/calculator/workers/completeness-calculator-worker.js +21 -17
- package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
- package/es/calculator/workers/mirror-calculator-worker.js +14 -10
- package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
- package/es/calculator/workers/scatter-calculator-worker.js +15 -11
- package/es/calculator/workers/trend-calculator-worker.js +14 -10
- package/es/calculator/world-map-calculator.js +6 -20
- package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
- package/es/components/dialog/statistic-record-dialog/index.js +21 -11
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
- package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
- package/es/components/popover/color-rules-popover.js +2 -2
- package/es/components/select/select.js +3 -3
- package/es/components/toast/alert.js +2 -0
- package/es/components/toast/toastManager.js +1 -0
- package/es/constants/color-rules.js +3 -3
- package/es/constants/index.js +9 -9
- package/es/dashboard.js +7 -13
- package/es/desktop-dashboard.js +1 -1
- package/es/locale/lang/de.js +10 -10
- package/es/locale/lang/en.js +8 -8
- package/es/locale/lang/fr.js +10 -10
- package/es/locale/lang/zh_CN.js +8 -8
- package/es/model/basic-number-card.js +3 -3
- package/es/model/compare-bar.js +2 -2
- package/es/model/generic-model.js +11 -11
- package/es/model/heat-map.js +2 -2
- package/es/model/horizontal-bar.js +2 -2
- package/es/model/index.js +3 -2
- package/es/model/map.js +3 -3
- package/es/model/mirror.js +2 -2
- package/es/model/trend.js +2 -2
- package/es/model/world-map.js +3 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +4 -18
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +1 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
- package/es/stat-view/area-chart.js +4 -4
- package/es/stat-view/bar-chart.js +4 -4
- package/es/stat-view/base-chart.js +2 -2
- package/es/stat-view/basic-number-card.js +49 -49
- package/es/stat-view/combination-chart.js +69 -69
- package/es/stat-view/compare-chart.js +4 -4
- package/es/stat-view/completeness-chart.js +3 -3
- package/es/stat-view/custom-bar.js +2 -2
- package/es/stat-view/dashboard-chart.js +50 -50
- package/es/stat-view/heat-map.js +2 -2
- package/es/stat-view/horizontal-bar-chart.js +4 -4
- package/es/stat-view/line-chart.js +4 -4
- package/es/stat-view/map.js +3 -3
- package/es/stat-view/mirror.js +2 -2
- package/es/stat-view/pivot-table/index.js +6 -6
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
- package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
- package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
- package/es/stat-view/ring-chart.js +2 -2
- package/es/stat-view/scatter-chart.js +56 -56
- package/es/stat-view/treemap-chart.js +50 -49
- package/es/stat-view/trend-chart.js +52 -52
- package/es/stat-view/world-map.js +3 -3
- package/es/utils/cell-format.js +16 -16
- package/es/utils/cell-value.js +3 -3
- package/es/utils/color-utils.js +3 -3
- package/es/utils/column-utils.js +10 -10
- package/es/utils/column.js +2 -2
- package/es/utils/common-utils.js +10 -8
- package/es/utils/export-table-utils.js +38 -38
- package/es/utils/object.js +3 -3
- package/es/utils/pivot-table.js +3 -3
- package/es/utils/row-utils.js +17 -17
- package/es/utils/search.js +14 -14
- package/es/utils/sql-utils.js +23 -20
- package/es/utils/stat-utils.js +52 -52
- package/es/utils/trend-utils.js +1 -0
- package/package.json +6 -3
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _constants = require("../constants");
|
|
@@ -18,56 +18,9 @@ const propTypes = {
|
|
|
18
18
|
chartCalculator: _propTypes.default.object,
|
|
19
19
|
getTableById: _propTypes.default.func
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class TrendChart extends _baseChart.default {
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props);
|
|
24
|
-
this.componentDidMount = async () => {
|
|
25
|
-
const {
|
|
26
|
-
statItem,
|
|
27
|
-
chartCalculator
|
|
28
|
-
} = this.props;
|
|
29
|
-
if (this.container) {
|
|
30
|
-
const data = await chartCalculator.calculate(statItem);
|
|
31
|
-
this.setState({
|
|
32
|
-
isCalculatingData: false
|
|
33
|
-
});
|
|
34
|
-
this.drawChart(data);
|
|
35
|
-
this.calculateData = data;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
this.componentDidUpdate = async (preProps, preState) => {
|
|
39
|
-
const {
|
|
40
|
-
statItem,
|
|
41
|
-
chartCalculator
|
|
42
|
-
} = this.props;
|
|
43
|
-
const {
|
|
44
|
-
isCalculatingData
|
|
45
|
-
} = this.state;
|
|
46
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
47
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
48
|
-
this.setState({
|
|
49
|
-
isCalculatingData: true
|
|
50
|
-
});
|
|
51
|
-
if (this.container) {
|
|
52
|
-
const data = await chartCalculator.calculate(statItem);
|
|
53
|
-
this.calculateData = data;
|
|
54
|
-
this.setState({
|
|
55
|
-
isCalculatingData: false
|
|
56
|
-
});
|
|
57
|
-
this.chart && this.chart.destroy();
|
|
58
|
-
this.drawChart(data);
|
|
59
|
-
if (this.props.isPreview) {
|
|
60
|
-
this.chart.forceFit();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
this.chart && this.chart.destroy();
|
|
65
|
-
this.drawChart(this.calculateData);
|
|
66
|
-
if (this.props.isPreview) {
|
|
67
|
-
this.chart.forceFit();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
24
|
this.drawChart = data => {
|
|
72
25
|
const {
|
|
73
26
|
isPreview,
|
|
@@ -114,7 +67,7 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
114
67
|
} = statItem;
|
|
115
68
|
if (summary_type !== _constants.STATISTICS_COUNT_TYPE.COUNT) {
|
|
116
69
|
const table = getTableById(table_id);
|
|
117
|
-
const selectedColumn =
|
|
70
|
+
const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column);
|
|
118
71
|
return this.getNumberDisplayString(data, selectedColumn.data || {});
|
|
119
72
|
}
|
|
120
73
|
let string = data + '';
|
|
@@ -223,6 +176,20 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
223
176
|
};
|
|
224
177
|
this.calculateData = null;
|
|
225
178
|
}
|
|
179
|
+
async componentDidMount() {
|
|
180
|
+
const {
|
|
181
|
+
statItem,
|
|
182
|
+
chartCalculator
|
|
183
|
+
} = this.props;
|
|
184
|
+
if (this.container) {
|
|
185
|
+
const data = await chartCalculator.calculate(statItem);
|
|
186
|
+
this.setState({
|
|
187
|
+
isCalculatingData: false
|
|
188
|
+
});
|
|
189
|
+
this.drawChart(data);
|
|
190
|
+
this.calculateData = data;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
226
193
|
shouldComponentUpdate(nextProps, nextState) {
|
|
227
194
|
if (this.canUpdate(this.props, nextProps)) {
|
|
228
195
|
return true;
|
|
@@ -232,6 +199,39 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
232
199
|
}
|
|
233
200
|
return false;
|
|
234
201
|
}
|
|
202
|
+
async componentDidUpdate(preProps, preState) {
|
|
203
|
+
const {
|
|
204
|
+
statItem,
|
|
205
|
+
chartCalculator
|
|
206
|
+
} = this.props;
|
|
207
|
+
const {
|
|
208
|
+
isCalculatingData
|
|
209
|
+
} = this.state;
|
|
210
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
211
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
212
|
+
this.setState({
|
|
213
|
+
isCalculatingData: true
|
|
214
|
+
});
|
|
215
|
+
if (this.container) {
|
|
216
|
+
const data = await chartCalculator.calculate(statItem);
|
|
217
|
+
this.calculateData = data;
|
|
218
|
+
this.setState({
|
|
219
|
+
isCalculatingData: false
|
|
220
|
+
});
|
|
221
|
+
this.chart && this.chart.destroy();
|
|
222
|
+
this.drawChart(data);
|
|
223
|
+
if (this.props.isPreview) {
|
|
224
|
+
this.chart.forceFit();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
this.chart && this.chart.destroy();
|
|
229
|
+
this.drawChart(this.calculateData);
|
|
230
|
+
if (this.props.isPreview) {
|
|
231
|
+
this.chart.forceFit();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
235
|
componentWillUnmount() {
|
|
236
236
|
this.container = null;
|
|
237
237
|
}
|
|
@@ -245,5 +245,5 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
245
245
|
}));
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
|
|
249
|
-
var _default = exports.default =
|
|
248
|
+
TrendChart.propTypes = propTypes;
|
|
249
|
+
var _default = exports.default = TrendChart;
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _index = _interopRequireDefault(require("@antv/data-set/lib/index"));
|
|
11
11
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
12
|
-
var
|
|
12
|
+
var _dtableUtils = require("dtable-utils");
|
|
13
13
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
14
14
|
var _customG = require("../custom-g2");
|
|
15
15
|
var _constants = require("../constants");
|
|
@@ -90,7 +90,7 @@ class WorldMap extends _baseChart.default {
|
|
|
90
90
|
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
91
91
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
92
92
|
const table = getTableById(table_id);
|
|
93
|
-
const summaryColumn =
|
|
93
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
94
94
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
95
95
|
}
|
|
96
96
|
this.statisticView = this.chart.createView();
|
|
@@ -159,7 +159,7 @@ class WorldMap extends _baseChart.default {
|
|
|
159
159
|
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
160
160
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
161
161
|
const table = getTableById(table_id);
|
|
162
|
-
const summaryColumn =
|
|
162
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
163
163
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
164
164
|
}
|
|
165
165
|
this.statisticView = this.chart.createView();
|
package/es/utils/cell-format.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getClientFormulaDisplayString = exports.getClientCellValueDisplayString = void 0;
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
var
|
|
9
|
+
var _dtableUtils = require("dtable-utils");
|
|
10
|
+
var _object = require("./object");
|
|
10
11
|
const getClientFormulaDisplayString = function (value, columnData) {
|
|
11
12
|
let {
|
|
12
|
-
tables = [],
|
|
13
13
|
collaborators = []
|
|
14
14
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
15
15
|
if (!columnData || !value && value !== 0) return '';
|
|
@@ -17,19 +17,16 @@ const getClientFormulaDisplayString = function (value, columnData) {
|
|
|
17
17
|
result_type,
|
|
18
18
|
array_type
|
|
19
19
|
} = columnData;
|
|
20
|
-
if (result_type ===
|
|
21
|
-
if (
|
|
20
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
21
|
+
if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
22
22
|
if (!value) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
const collaboratorList = Array.isArray(value) ? value : [value];
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, _dtableUtils.getCollaboratorsName)(collaborators, collaboratorList);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
return (0,
|
|
30
|
-
tables,
|
|
31
|
-
collaborators
|
|
32
|
-
});
|
|
29
|
+
return (0, _dtableUtils.getFormulaDisplayString)(value, columnData);
|
|
33
30
|
};
|
|
34
31
|
|
|
35
32
|
/**
|
|
@@ -52,8 +49,8 @@ const getClientLinkDisplayString = function (links, columnData) {
|
|
|
52
49
|
let formulaData = {
|
|
53
50
|
...columnData
|
|
54
51
|
};
|
|
55
|
-
if (!
|
|
56
|
-
formulaData.result_type =
|
|
52
|
+
if (!(0, _object.hasOwnProperty)(columnData, 'result_type')) {
|
|
53
|
+
formulaData.result_type = _dtableUtils.FORMULA_RESULT_TYPE.ARRAY;
|
|
57
54
|
}
|
|
58
55
|
const displayValue = links.map(link => link.display_value);
|
|
59
56
|
return getClientFormulaDisplayString(displayValue, formulaData, {
|
|
@@ -88,24 +85,27 @@ const getClientCellValueDisplayString = function (row, type, key) {
|
|
|
88
85
|
collaborators = [],
|
|
89
86
|
tables = []
|
|
90
87
|
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
91
|
-
if (
|
|
88
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
92
89
|
const formulaRow = formulaRows[row._id] || {};
|
|
93
90
|
return getClientFormulaDisplayString(formulaRow[key], data, {
|
|
94
91
|
tables,
|
|
95
92
|
collaborators
|
|
96
93
|
});
|
|
97
|
-
}
|
|
94
|
+
}
|
|
95
|
+
if (type === _dtableUtils.CellType.LINK) {
|
|
98
96
|
const formulaRow = formulaRows[row._id] || {};
|
|
99
97
|
return getClientLinkDisplayString(formulaRow[key], data, {
|
|
100
98
|
tables,
|
|
101
99
|
collaborators
|
|
102
100
|
});
|
|
103
|
-
}
|
|
101
|
+
}
|
|
102
|
+
if (type === _dtableUtils.CellType.CTIME || type === _dtableUtils.CellType.MTIME) {
|
|
104
103
|
return getAutoTimeDisplayString(row, key);
|
|
105
|
-
}
|
|
104
|
+
}
|
|
105
|
+
if (type === _dtableUtils.CellType.FILE) {
|
|
106
106
|
return getFileDisplayString(row, key);
|
|
107
107
|
}
|
|
108
|
-
return (0,
|
|
108
|
+
return (0, _dtableUtils.getCellValueDisplayString)(row, type, key, {
|
|
109
109
|
formulaRows,
|
|
110
110
|
data,
|
|
111
111
|
collaborators,
|
package/es/utils/cell-value.js
CHANGED
|
@@ -4,17 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isCellValueChanged = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _object = require("./object");
|
|
9
9
|
const isCellValueChanged = (oldVal, newVal, columnType) => {
|
|
10
10
|
if (oldVal === newVal) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
if (oldVal === undefined || oldVal === null) {
|
|
14
|
-
if ((columnType ===
|
|
14
|
+
if ((columnType === _dtableUtils.CellType.GEOLOCATION || columnType === _dtableUtils.CellType.DIGITAL_SIGN) && (0, _object.isEmptyObject)(newVal)) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
-
if ((columnType ===
|
|
17
|
+
if ((columnType === _dtableUtils.CellType.DATE || columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.DURATION) && newVal === null) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
if (Array.isArray(newVal)) {
|
package/es/utils/color-utils.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getValidColorRules = exports.getLabelColorFromSpecificColor = exports.getLabelColorFromColorRules = exports.getLabelColor = exports.getConvertedColorRules = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
var _colorRules = require("../constants/color-rules");
|
|
10
10
|
const getValidColorRules = colorRules => {
|
|
@@ -36,7 +36,7 @@ const getValidColorRules = colorRules => {
|
|
|
36
36
|
column_key: filter.filter_type
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
|
-
const validFilters = (0,
|
|
39
|
+
const validFilters = (0, _dtableUtils.getValidFilters)(convertedFilters, columns);
|
|
40
40
|
if (validFilters.length === 0) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
@@ -102,7 +102,7 @@ const getLabelColorFromColorRules = (colorRules, value) => {
|
|
|
102
102
|
filter_conjunction,
|
|
103
103
|
filters
|
|
104
104
|
} = colorRule;
|
|
105
|
-
if ((0,
|
|
105
|
+
if ((0, _dtableUtils.filterRow)(row, filter_conjunction, filters)) {
|
|
106
106
|
matchedRuleColor = color;
|
|
107
107
|
break;
|
|
108
108
|
}
|
package/es/utils/column-utils.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getColorFromSingleSelectColumn = getColorFromSingleSelectColumn;
|
|
7
7
|
exports.isWorldMapColumn = exports.isStatisticDateColumn = exports.isMirrorColumn = exports.isMapColumn = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
9
|
var _constants = require("../constants");
|
|
10
10
|
function getColorFromSingleSelectColumn(column, target) {
|
|
11
11
|
let {
|
|
12
12
|
type: columnType,
|
|
13
13
|
data: columnData
|
|
14
14
|
} = column;
|
|
15
|
-
if (columnType !==
|
|
15
|
+
if (columnType !== _dtableUtils.CellType.SINGLE_SELECT) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
const options = columnData ? columnData.options : [];
|
|
@@ -28,7 +28,7 @@ function getColorFromSingleSelectColumn(column, target) {
|
|
|
28
28
|
}
|
|
29
29
|
const isStatisticDateColumn = column => {
|
|
30
30
|
if (!column) return false;
|
|
31
|
-
return (0,
|
|
31
|
+
return (0, _dtableUtils.isDateColumn)(column);
|
|
32
32
|
};
|
|
33
33
|
exports.isStatisticDateColumn = isStatisticDateColumn;
|
|
34
34
|
const isMapColumn = column => {
|
|
@@ -37,7 +37,7 @@ const isMapColumn = column => {
|
|
|
37
37
|
type,
|
|
38
38
|
data
|
|
39
39
|
} = column;
|
|
40
|
-
if (type ===
|
|
40
|
+
if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
41
41
|
const {
|
|
42
42
|
geo_format
|
|
43
43
|
} = data || {};
|
|
@@ -46,13 +46,13 @@ const isMapColumn = column => {
|
|
|
46
46
|
}
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
50
50
|
const {
|
|
51
51
|
result_type,
|
|
52
52
|
array_type,
|
|
53
53
|
array_data
|
|
54
54
|
} = data || {};
|
|
55
|
-
if (result_type !==
|
|
55
|
+
if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
const {
|
|
@@ -77,8 +77,8 @@ const isWorldMapColumn = column => {
|
|
|
77
77
|
type,
|
|
78
78
|
data
|
|
79
79
|
} = column;
|
|
80
|
-
if (type ===
|
|
81
|
-
if (type ===
|
|
80
|
+
if (type === _dtableUtils.CellType.TEXT) return true;
|
|
81
|
+
if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
82
82
|
const {
|
|
83
83
|
geo_format
|
|
84
84
|
} = data || {};
|
|
@@ -86,7 +86,7 @@ const isWorldMapColumn = column => {
|
|
|
86
86
|
return true;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
89
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
90
90
|
const {
|
|
91
91
|
data
|
|
92
92
|
} = column;
|
|
@@ -95,7 +95,7 @@ const isWorldMapColumn = column => {
|
|
|
95
95
|
array_type,
|
|
96
96
|
array_data
|
|
97
97
|
} = data || {};
|
|
98
|
-
if (result_type !==
|
|
98
|
+
if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
const {
|
package/es/utils/column.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getDateColumnFormat = getDateColumnFormat;
|
|
7
7
|
exports.getSelectColumnOptions = getSelectColumnOptions;
|
|
8
|
-
var
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
9
|
function getSelectColumnOptions(column) {
|
|
10
10
|
if (!column || !column.data || !Array.isArray(column.data.options)) {
|
|
11
11
|
return [];
|
|
@@ -13,7 +13,7 @@ function getSelectColumnOptions(column) {
|
|
|
13
13
|
return column.data.options;
|
|
14
14
|
}
|
|
15
15
|
function getDateColumnFormat(column) {
|
|
16
|
-
let format = column && column.data && column.data.format ? column.data.format :
|
|
16
|
+
let format = column && column.data && column.data.format ? column.data.format : _dtableUtils.DEFAULT_DATE_FORMAT;
|
|
17
17
|
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
18
18
|
format = format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY');
|
|
19
19
|
return format;
|
package/es/utils/common-utils.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.isShapeEqual = exports.isBoolean = exports.isArrayCellValue = exports.ge
|
|
|
11
11
|
exports.isStatItemEqual = isStatItemEqual;
|
|
12
12
|
exports.shallowEqual = shallowEqual;
|
|
13
13
|
exports.sortDataByGroupSum = exports.shouldCalculateStatItem = void 0;
|
|
14
|
-
var
|
|
14
|
+
var _dtableUtils = require("dtable-utils");
|
|
15
15
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
16
16
|
var _constants = require("../constants");
|
|
17
17
|
var _statUtils = _interopRequireDefault(require("./stat-utils"));
|
|
@@ -19,12 +19,14 @@ const generatorUniqueId = list => {
|
|
|
19
19
|
let uniqueId;
|
|
20
20
|
let isUnique = false;
|
|
21
21
|
while (!isUnique) {
|
|
22
|
-
uniqueId = (0,
|
|
22
|
+
uniqueId = (0, _dtableUtils.generatorBase64Code)();
|
|
23
23
|
|
|
24
24
|
// eslint-disable-next-line
|
|
25
25
|
if (!Array.isArray(list) || list.length === 0) {
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line
|
|
28
30
|
isUnique = list.every(item => item._id !== uniqueId);
|
|
29
31
|
if (isUnique) {
|
|
30
32
|
break;
|
|
@@ -152,13 +154,13 @@ const isArrayCellValue = column => {
|
|
|
152
154
|
type,
|
|
153
155
|
data
|
|
154
156
|
} = column;
|
|
155
|
-
return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] ||
|
|
157
|
+
return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY && _dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
|
|
156
158
|
;
|
|
157
159
|
};
|
|
158
160
|
exports.isArrayCellValue = isArrayCellValue;
|
|
159
161
|
const getSummaryResult = function (results, summaryMethod) {
|
|
160
162
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
161
|
-
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0,
|
|
163
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableUtils.isNumber)(res)) : [];
|
|
162
164
|
switch (summaryMethod) {
|
|
163
165
|
case _constants.SUMMARY_METHOD_MAP.Max:
|
|
164
166
|
{
|
|
@@ -233,7 +235,7 @@ const getPieColor = (color_option, column, index, data, currentTheme) => {
|
|
|
233
235
|
const {
|
|
234
236
|
colors
|
|
235
237
|
} = currentTheme;
|
|
236
|
-
if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType ===
|
|
238
|
+
if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT)) {
|
|
237
239
|
if (columnData && columnData.options) {
|
|
238
240
|
const selectedItem = columnData.options.find(item => item.name === data.name) || {};
|
|
239
241
|
return selectedItem.color || '#dbdbdb';
|
|
@@ -253,7 +255,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
253
255
|
summary_type
|
|
254
256
|
} = statItem;
|
|
255
257
|
const isAdvanced = summary_type === 'advanced';
|
|
256
|
-
const column =
|
|
258
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
|
|
257
259
|
let sum = data.reduce((total, currentValue) => {
|
|
258
260
|
return total += currentValue.value;
|
|
259
261
|
}, 0);
|
|
@@ -284,7 +286,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
284
286
|
}, 0);
|
|
285
287
|
let formattedValueSum = filteredSum;
|
|
286
288
|
if (isAdvanced) {
|
|
287
|
-
const summaryColumn =
|
|
289
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
288
290
|
formattedValueSum = _statUtils.default.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
|
|
289
291
|
}
|
|
290
292
|
let original_name_list = [];
|
|
@@ -329,7 +331,7 @@ const formatNumericValue = function (value) {
|
|
|
329
331
|
};
|
|
330
332
|
exports.formatNumericValue = formatNumericValue;
|
|
331
333
|
const getLabelFontSize = label_font_size => {
|
|
332
|
-
return (0,
|
|
334
|
+
return (0, _dtableUtils.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
|
|
333
335
|
};
|
|
334
336
|
exports.getLabelFontSize = getLabelFontSize;
|
|
335
337
|
const getSummaryColumnMethod = function (method, summaryColumnName) {
|