dtable-statistic 4.2.2 → 4.3.0
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/api/dtable-db-api.js +31 -37
- package/es/calculator/base-calculator.js +49 -99
- package/es/calculator/basic-chart-calculator.js +335 -559
- package/es/calculator/combination-calculator.js +231 -299
- package/es/calculator/compare-bar-calculator.js +184 -281
- package/es/calculator/completeness-calculator.js +203 -288
- package/es/calculator/copy-value.js +18 -18
- package/es/calculator/dashboard-calculator.js +68 -137
- package/es/calculator/heat-map-calculator.js +139 -220
- package/es/calculator/horizontal-bar-calculator.js +64 -93
- package/es/calculator/index.js +53 -69
- package/es/calculator/map-calculator.js +98 -174
- package/es/calculator/mirror-calculator.js +137 -216
- package/es/calculator/number-card-calculator.js +58 -126
- package/es/calculator/pivot-table-calculator.js +750 -792
- package/es/calculator/scatter-calculator.js +72 -140
- package/es/calculator/thread-manager.js +48 -67
- package/es/calculator/trend-calculator.js +107 -191
- package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
- package/es/calculator/workers/calculator.worker.js +22 -6
- package/es/calculator/workers/card-calculator-worker.js +16 -14
- package/es/calculator/workers/combination-calculator-worker.js +128 -135
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
- package/es/calculator/workers/completeness-calculator-worker.js +56 -49
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
- package/es/calculator/workers/mirror-calculator-worker.js +52 -52
- package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
- package/es/calculator/workers/scatter-calculator-worker.js +34 -32
- package/es/calculator/workers/trend-calculator-worker.js +33 -29
- package/es/calculator/world-map-calculator.js +120 -197
- package/es/components/common-add-tool.js +7 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
- package/es/components/dialog/color-theme-dialog.js +34 -47
- package/es/components/dialog/delete-confirmation-dialog.js +7 -5
- package/es/components/dialog/enlarged-chart-dialog.js +68 -81
- package/es/components/dialog/new-table-dialog.js +62 -80
- package/es/components/dialog/new-view-dialog.js +50 -62
- package/es/components/dialog/rename-view-dialog.js +49 -58
- package/es/components/dialog/statistic-record-dialog/index.js +233 -231
- package/es/components/dialog/statistic-types-dialog/index.js +40 -49
- package/es/components/dialog/table-select-dialog.js +61 -70
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
- package/es/components/dtable-popover.js +62 -81
- package/es/components/dtable-search-input.js +89 -99
- package/es/components/dtable-select.js +55 -74
- package/es/components/icon.js +5 -3
- package/es/components/loading.js +1 -1
- package/es/components/modal-portal.js +15 -32
- package/es/components/popover/color-rules/color-rule.js +137 -141
- package/es/components/popover/color-rules/index.js +58 -66
- package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
- package/es/components/popover/color-rules/rule-filters/index.js +50 -58
- package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
- package/es/components/popover/color-rules-popover.js +117 -121
- package/es/components/popover/color-selector-popover.js +60 -70
- package/es/components/seatable-radio/index.js +2 -2
- package/es/components/select/option-group.js +139 -157
- package/es/components/select/option.js +26 -40
- package/es/components/select/select.js +97 -112
- package/es/components/toast/alert.js +65 -80
- package/es/components/toast/index.js +1 -1
- package/es/components/toast/toast.js +76 -103
- package/es/components/toast/toastManager.js +57 -93
- package/es/components/toast/toaster.js +58 -56
- package/es/constants/color-rules.js +8 -5
- package/es/constants/dtable-select-style.js +44 -48
- package/es/constants/event-types.js +4 -4
- package/es/constants/index.js +328 -242
- package/es/constants/map.js +2 -2
- package/es/constants/model.js +20 -20
- package/es/constants/regions.js +1 -1
- package/es/constants/zIndexes.js +1 -1
- package/es/custom-g2.js +11 -11
- package/es/dashboard.js +343 -333
- package/es/desktop-dashboard.js +217 -224
- package/es/index.js +45 -58
- package/es/locale/index.js +3 -3
- package/es/locale/lang/de.js +1 -1
- package/es/locale/lang/en.js +7 -7
- package/es/locale/lang/fr.js +1 -1
- package/es/locale/lang/zh_CN.js +1 -1
- package/es/mobile-dashboard.js +76 -89
- package/es/model/bar-group.js +34 -44
- package/es/model/bar.js +26 -36
- package/es/model/base-model.js +11 -12
- package/es/model/basic-number-card.js +10 -20
- package/es/model/collaborators.js +10 -11
- package/es/model/combination.js +32 -42
- package/es/model/compare-bar.js +30 -40
- package/es/model/completeness-group.js +19 -29
- package/es/model/completeness.js +14 -24
- package/es/model/custom-bar.js +14 -24
- package/es/model/dashboard.js +9 -19
- package/es/model/generic-model.js +187 -197
- package/es/model/heat-map.js +16 -26
- package/es/model/horizontal-bar-group.js +32 -42
- package/es/model/horizontal-bar.js +26 -36
- package/es/model/index.js +31 -3
- package/es/model/map.js +20 -30
- package/es/model/mirror.js +15 -25
- package/es/model/pie.js +21 -31
- package/es/model/ring.js +23 -33
- package/es/model/scatter.js +11 -21
- package/es/model/statistic-dashboard.js +7 -8
- package/es/model/table.js +19 -29
- package/es/model/trend.js +15 -25
- package/es/model/world-map.js +17 -27
- package/es/service/chart-service.js +69 -65
- package/es/service/dashboard-service.js +421 -419
- package/es/service/map-json.js +112 -132
- package/es/stat-editor/chart-name-editor.js +44 -58
- package/es/stat-editor/index.js +59 -70
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
- package/es/stat-editor/stat-settings/map/map-level.js +31 -43
- package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
- package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
- package/es/stat-list/chart-preview.js +85 -98
- package/es/stat-list/index.js +170 -178
- package/es/stat-view/area-chart.js +282 -274
- package/es/stat-view/bar-chart.js +300 -292
- package/es/stat-view/base-chart.js +58 -52
- package/es/stat-view/basic-number-card.js +115 -168
- package/es/stat-view/combination-chart.js +298 -334
- package/es/stat-view/compare-chart.js +256 -254
- package/es/stat-view/completeness-chart.js +194 -206
- package/es/stat-view/custom-bar.js +221 -223
- package/es/stat-view/dashboard-chart.js +122 -180
- package/es/stat-view/heat-map.js +268 -294
- package/es/stat-view/horizontal-bar-chart.js +291 -281
- package/es/stat-view/index.js +136 -152
- package/es/stat-view/line-chart.js +267 -265
- package/es/stat-view/map.js +246 -246
- package/es/stat-view/mirror.js +141 -152
- package/es/stat-view/pie-chart.js +143 -156
- package/es/stat-view/pivot-table/index.js +113 -118
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
- package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
- package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
- package/es/stat-view/ring-chart.js +189 -200
- package/es/stat-view/scatter-chart.js +162 -213
- package/es/stat-view/treemap-chart.js +136 -200
- package/es/stat-view/trend-chart.js +137 -183
- package/es/stat-view/world-map.js +233 -243
- package/es/tabs/index.js +164 -169
- package/es/tabs/tab.js +101 -116
- package/es/utils/basic-chart-utils.js +7 -9
- package/es/utils/cell-format.js +48 -51
- package/es/utils/cell-value.js +1 -1
- package/es/utils/collaborator.js +15 -14
- package/es/utils/color-utils.js +48 -37
- package/es/utils/column-utils.js +47 -33
- package/es/utils/column.js +1 -1
- package/es/utils/common-utils.js +111 -117
- package/es/utils/date-format.js +17 -17
- package/es/utils/export-table-utils.js +507 -396
- package/es/utils/index.js +6 -6
- package/es/utils/map.js +30 -34
- package/es/utils/model.js +3 -5
- package/es/utils/object.js +4 -4
- package/es/utils/pivot-table.js +20 -20
- package/es/utils/row-utils.js +41 -33
- package/es/utils/search.js +18 -20
- package/es/utils/sql-utils.js +132 -98
- package/es/utils/stat-utils.js +303 -320
- package/es/utils/trend-utils.js +57 -67
- package/package.json +2 -2
package/es/utils/column-utils.js
CHANGED
|
@@ -1,83 +1,97 @@
|
|
|
1
1
|
import { CellType, isDateColumn, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES } from 'dtable-store';
|
|
2
2
|
import { MIRROR_COLUMN_LIST } from '../constants';
|
|
3
3
|
export function getColorFromSingleSelectColumn(column, target) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
let {
|
|
5
|
+
type: columnType,
|
|
6
|
+
data: columnData
|
|
7
|
+
} = column;
|
|
6
8
|
if (columnType !== CellType.SINGLE_SELECT) {
|
|
7
9
|
return null;
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const options = columnData ? columnData.options : [];
|
|
12
|
+
const selectedOption = options.find(option => {
|
|
13
|
+
let id = target;
|
|
12
14
|
if (Array.isArray(target)) {
|
|
13
15
|
id = target[0];
|
|
14
16
|
}
|
|
15
17
|
return option.id === id;
|
|
16
18
|
});
|
|
17
|
-
|
|
19
|
+
const color = selectedOption && selectedOption.color;
|
|
18
20
|
return color || null;
|
|
19
21
|
}
|
|
20
|
-
export
|
|
22
|
+
export const isStatisticDateColumn = column => {
|
|
21
23
|
if (!column) return false;
|
|
22
24
|
return isDateColumn(column);
|
|
23
25
|
};
|
|
24
|
-
export
|
|
26
|
+
export const isMapColumn = column => {
|
|
25
27
|
if (!column) return false;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const {
|
|
29
|
+
type,
|
|
30
|
+
data
|
|
31
|
+
} = column;
|
|
28
32
|
if (type === CellType.GEOLOCATION) {
|
|
29
|
-
|
|
30
|
-
geo_format
|
|
33
|
+
const {
|
|
34
|
+
geo_format
|
|
35
|
+
} = data || {};
|
|
31
36
|
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
32
37
|
return false;
|
|
33
38
|
}
|
|
34
39
|
return true;
|
|
35
40
|
}
|
|
36
41
|
if (FORMULA_COLUMN_TYPES.includes(type)) {
|
|
37
|
-
|
|
38
|
-
result_type
|
|
39
|
-
array_type
|
|
40
|
-
array_data
|
|
42
|
+
const {
|
|
43
|
+
result_type,
|
|
44
|
+
array_type,
|
|
45
|
+
array_data
|
|
46
|
+
} = data || {};
|
|
41
47
|
if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
|
|
42
48
|
return false;
|
|
43
49
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
const {
|
|
51
|
+
geo_format
|
|
52
|
+
} = array_data || {};
|
|
53
|
+
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
47
54
|
return false;
|
|
48
55
|
}
|
|
49
56
|
return true;
|
|
50
57
|
}
|
|
51
58
|
return false;
|
|
52
59
|
};
|
|
53
|
-
export
|
|
60
|
+
export const isMirrorColumn = column => {
|
|
54
61
|
if (!column) return false;
|
|
55
62
|
return MIRROR_COLUMN_LIST.includes(column.type);
|
|
56
63
|
};
|
|
57
|
-
export
|
|
64
|
+
export const isWorldMapColumn = column => {
|
|
58
65
|
if (!column) return false;
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
const {
|
|
67
|
+
type,
|
|
68
|
+
data
|
|
69
|
+
} = column;
|
|
61
70
|
if (type === CellType.TEXT) return true;
|
|
62
71
|
if (type === CellType.GEOLOCATION) {
|
|
63
|
-
|
|
64
|
-
geo_format
|
|
72
|
+
const {
|
|
73
|
+
geo_format
|
|
74
|
+
} = data || {};
|
|
65
75
|
if (geo_format === 'country_region') {
|
|
66
76
|
return true;
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
if (FORMULA_COLUMN_TYPES.includes(type)) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
const {
|
|
81
|
+
data
|
|
82
|
+
} = column;
|
|
83
|
+
const {
|
|
84
|
+
result_type,
|
|
85
|
+
array_type,
|
|
86
|
+
array_data
|
|
87
|
+
} = data || {};
|
|
75
88
|
if (result_type !== FORMULA_RESULT_TYPE.ARRAY || array_type !== CellType.GEOLOCATION) {
|
|
76
89
|
return false;
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
const {
|
|
92
|
+
geo_format
|
|
93
|
+
} = array_data || {};
|
|
94
|
+
if (geo_format === 'country_region') {
|
|
81
95
|
return true;
|
|
82
96
|
}
|
|
83
97
|
}
|
package/es/utils/column.js
CHANGED
|
@@ -6,7 +6,7 @@ export function getSelectColumnOptions(column) {
|
|
|
6
6
|
return column.data.options;
|
|
7
7
|
}
|
|
8
8
|
export function getDateColumnFormat(column) {
|
|
9
|
-
|
|
9
|
+
let format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
|
|
10
10
|
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
11
11
|
format = format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY');
|
|
12
12
|
return format;
|
package/es/utils/common-utils.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, generatorBase64Code, isNumber, TableUtils } from 'dtable-store';
|
|
3
2
|
import intl from 'react-intl-universal';
|
|
4
3
|
import { STAT_TYPE, DEFAULT_LABEL_FONT_SIZE, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, CHART_STYLE_COLORS, PIE_COLOR_OPTIONS, SUMMARY_METHOD_MAP } from '../constants';
|
|
5
4
|
import StatUtils from './stat-utils';
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const generatorUniqueId = list => {
|
|
6
|
+
let uniqueId;
|
|
7
|
+
let isUnique = false;
|
|
9
8
|
while (!isUnique) {
|
|
10
9
|
uniqueId = generatorBase64Code();
|
|
11
10
|
|
|
@@ -13,20 +12,20 @@ export var generatorUniqueId = function generatorUniqueId(list) {
|
|
|
13
12
|
if (!Array.isArray(list) || list.length === 0) {
|
|
14
13
|
break;
|
|
15
14
|
}
|
|
16
|
-
isUnique = list.every(
|
|
17
|
-
return item._id !== uniqueId;
|
|
18
|
-
});
|
|
15
|
+
isUnique = list.every(item => item._id !== uniqueId);
|
|
19
16
|
if (isUnique) {
|
|
20
17
|
break;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
return uniqueId;
|
|
24
21
|
};
|
|
25
|
-
export
|
|
26
|
-
|
|
22
|
+
export const getImageUrl = imageName => {
|
|
23
|
+
const {
|
|
24
|
+
mediaUrl
|
|
25
|
+
} = window.dtable;
|
|
27
26
|
return "".concat(mediaUrl, "dtable-statistic/img/").concat(imageName);
|
|
28
27
|
};
|
|
29
|
-
export
|
|
28
|
+
export const isShapeEqual = (position1, position2) => {
|
|
30
29
|
if (position1 && position2) {
|
|
31
30
|
return position1.w === position2.w && position1.h === position2.h;
|
|
32
31
|
}
|
|
@@ -34,7 +33,7 @@ export var isShapeEqual = function isShapeEqual(position1, position2) {
|
|
|
34
33
|
return false;
|
|
35
34
|
};
|
|
36
35
|
export function isStatItemEqual(prevStatItem, chart) {
|
|
37
|
-
|
|
36
|
+
let statItemType = prevStatItem.type;
|
|
38
37
|
if (statItemType !== chart.type) return false;
|
|
39
38
|
return shallowEqual(prevStatItem, chart);
|
|
40
39
|
}
|
|
@@ -45,15 +44,15 @@ export function shallowEqual(objA, objB) {
|
|
|
45
44
|
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
46
45
|
return false;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const keysA = Object.keys(objA);
|
|
48
|
+
const keysB = Object.keys(objB);
|
|
50
49
|
if (keysA.length !== keysB.length) {
|
|
51
50
|
return false;
|
|
52
51
|
}
|
|
53
|
-
for (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
53
|
+
let key = keysA[i];
|
|
54
|
+
let valueA = objA[key];
|
|
55
|
+
let valueB = objB[key];
|
|
57
56
|
if (key === 'layout') continue;
|
|
58
57
|
// line | chart-bar | chart-bar-stack | chart-bar-group
|
|
59
58
|
if (key === 'show_x_axis_label') continue;
|
|
@@ -75,7 +74,7 @@ export function shallowEqual(objA, objB) {
|
|
|
75
74
|
if (objA.type !== 'basic_number_card' && objA.type !== STAT_TYPE.DASHBOARD && key === 'name') continue;
|
|
76
75
|
if (Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
77
76
|
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
78
|
-
|
|
77
|
+
let isArrayEqual = arraysEqual(valueA, valueB);
|
|
79
78
|
if (!isArrayEqual) return false;
|
|
80
79
|
} else if (valueA !== valueB) {
|
|
81
80
|
return false;
|
|
@@ -89,9 +88,9 @@ export function shallowEqual(objA, objB) {
|
|
|
89
88
|
}
|
|
90
89
|
return true;
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
export
|
|
94
|
-
|
|
91
|
+
const IGNORE_STAT_KEYS = ['layout', 'name', 'show_y_axis_label', 'show_x_axis_label', 'show_vertical_axis_label', 'show_horizontal_axis_label', 'vertical_axis_label_position', 'horizontal_axis_label_position', 'horizontal_axis_label_color', 'y_axis_label_color', 'data_color', 'display_data', 'show_y_axis_left_label', 'show_y_axis_right_label', 'x_axis_label_position', 'y_axis_label_position', 'y_axis_left_color', 'y_axis_right_color', 'y_axis_left_label_position', 'y_axis_right_label_position', 'minimum_slice_percent', 'bubble_color', 'map_type', 'legend_direction', 'legend_size', 'completed_color', 'uncompleted_color', 'display_percentage', 'label_font_size'];
|
|
92
|
+
export const shouldCalculateStatItem = (prevStatItem, chart) => {
|
|
93
|
+
let statItemType = prevStatItem.type;
|
|
95
94
|
if (statItemType !== chart.type) return true;
|
|
96
95
|
if (prevStatItem === chart) {
|
|
97
96
|
return false;
|
|
@@ -99,19 +98,19 @@ export var shouldCalculateStatItem = function shouldCalculateStatItem(prevStatIt
|
|
|
99
98
|
if (typeof prevStatItem !== 'object' || !prevStatItem || typeof chart !== 'object' || !chart) {
|
|
100
99
|
return true;
|
|
101
100
|
}
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
const keysA = Object.keys(prevStatItem);
|
|
102
|
+
const keysB = Object.keys(chart);
|
|
104
103
|
if (keysA.length !== keysB.length) {
|
|
105
104
|
return true;
|
|
106
105
|
}
|
|
107
|
-
for (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
107
|
+
let key = keysA[i];
|
|
108
|
+
let valueA = prevStatItem[key];
|
|
109
|
+
let valueB = chart[key];
|
|
111
110
|
if (IGNORE_STAT_KEYS.includes(key)) continue;
|
|
112
111
|
if (Object.prototype.hasOwnProperty.call(chart, key)) {
|
|
113
112
|
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
114
|
-
|
|
113
|
+
let isArrayEqual = arraysEqual(valueA, valueB);
|
|
115
114
|
if (!isArrayEqual) return true;
|
|
116
115
|
} else if (valueA !== valueB) {
|
|
117
116
|
return true;
|
|
@@ -125,24 +124,24 @@ export var shouldCalculateStatItem = function shouldCalculateStatItem(prevStatIt
|
|
|
125
124
|
export function arraysEqual(arrayA, arrayB) {
|
|
126
125
|
if (arrayA === null || arrayB === null) return false;
|
|
127
126
|
if (arrayA.length !== arrayB.length) return false;
|
|
128
|
-
for (
|
|
127
|
+
for (let i = 0; i < arrayA.length; i++) {
|
|
129
128
|
if (!shallowEqual(arrayA[i], arrayB[i])) return false;
|
|
130
129
|
}
|
|
131
130
|
return true;
|
|
132
131
|
}
|
|
133
|
-
export
|
|
132
|
+
export const isArrayCellValue = column => {
|
|
134
133
|
if (!column) return false;
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const {
|
|
135
|
+
type,
|
|
136
|
+
data
|
|
137
|
+
} = column;
|
|
137
138
|
return MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === FORMULA_RESULT_TYPE.ARRAY && COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
|
|
138
139
|
;
|
|
139
140
|
};
|
|
140
141
|
|
|
141
|
-
export
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return isNumber(res);
|
|
145
|
-
}) : [];
|
|
142
|
+
export const getSummaryResult = function (results, summaryMethod) {
|
|
143
|
+
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
144
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => isNumber(res)) : [];
|
|
146
145
|
switch (summaryMethod) {
|
|
147
146
|
case SUMMARY_METHOD_MAP.Max:
|
|
148
147
|
{
|
|
@@ -162,10 +161,10 @@ export var getSummaryResult = function getSummaryResult(results, summaryMethod)
|
|
|
162
161
|
}
|
|
163
162
|
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
164
163
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
Array.isArray(results) && results.forEach(
|
|
168
|
-
|
|
164
|
+
let count = 0;
|
|
165
|
+
let existMap = {};
|
|
166
|
+
Array.isArray(results) && results.forEach(resNum => {
|
|
167
|
+
let num = resNum;
|
|
169
168
|
if (!num) {
|
|
170
169
|
if (num === 0) {
|
|
171
170
|
num = '0';
|
|
@@ -186,68 +185,72 @@ export var getSummaryResult = function getSummaryResult(results, summaryMethod)
|
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
187
|
};
|
|
189
|
-
|
|
188
|
+
const getMax = list => {
|
|
190
189
|
if (list.length === 0) return 0;
|
|
191
190
|
return Number.parseFloat(Math.max.apply(null, list));
|
|
192
191
|
};
|
|
193
|
-
|
|
192
|
+
const getMin = list => {
|
|
194
193
|
if (list.length === 0) return 0;
|
|
195
194
|
return Number.parseFloat(Math.min.apply(null, list).toFixed(8));
|
|
196
195
|
};
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
const getSum = function (list) {
|
|
197
|
+
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
199
198
|
if (list.length === 0) return 0;
|
|
200
|
-
|
|
199
|
+
const sum = list.reduce((a, b) => {
|
|
201
200
|
return a + b;
|
|
202
201
|
}, 0);
|
|
203
202
|
return Number.parseFloat(Number(sum).toFixed(8));
|
|
204
203
|
};
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
const getMean = function (list) {
|
|
205
|
+
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
207
206
|
if (list.length === 0) return 0;
|
|
208
|
-
|
|
207
|
+
const sum = getSum(list);
|
|
209
208
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
210
209
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
const getPieColor = (color_option, column, index, data, currentTheme) => {
|
|
211
|
+
let {
|
|
212
|
+
type: columnType,
|
|
213
|
+
data: columnData
|
|
214
|
+
} = column;
|
|
215
|
+
const {
|
|
216
|
+
colors
|
|
217
|
+
} = currentTheme;
|
|
215
218
|
if (color_option === PIE_COLOR_OPTIONS[1] && (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT)) {
|
|
216
219
|
if (columnData && columnData.options) {
|
|
217
|
-
|
|
218
|
-
return item.name === data.name;
|
|
219
|
-
}) || {};
|
|
220
|
+
const selectedItem = columnData.options.find(item => item.name === data.name) || {};
|
|
220
221
|
return selectedItem.color || '#dbdbdb';
|
|
221
222
|
}
|
|
222
223
|
} else {
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
const sIndex = String(index);
|
|
225
|
+
const colorIndex = sIndex.charAt(sIndex.length - 1);
|
|
225
226
|
return colors[colorIndex];
|
|
226
227
|
}
|
|
227
228
|
};
|
|
228
229
|
export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
230
|
+
const {
|
|
231
|
+
groupby_column_key,
|
|
232
|
+
color_option,
|
|
233
|
+
summary_column_key,
|
|
234
|
+
summary_method: summaryMethod,
|
|
235
|
+
summary_type
|
|
236
|
+
} = statItem;
|
|
237
|
+
const isAdvanced = summary_type === 'advanced';
|
|
238
|
+
const column = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
239
|
+
let sum = data.reduce((total, currentValue) => {
|
|
237
240
|
return total += currentValue.value;
|
|
238
241
|
}, 0);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
data.forEach(
|
|
246
|
-
|
|
242
|
+
const minimumSlicePercentage = typeof statItem.minimum_slice_percent === 'number' ? statItem.minimum_slice_percent : 1.5;
|
|
243
|
+
const threshold = sum * (minimumSlicePercentage / 100 || 0);
|
|
244
|
+
const filteredItems = [];
|
|
245
|
+
const colorSet = [];
|
|
246
|
+
const filteredData = [];
|
|
247
|
+
let stepIndex = 0;
|
|
248
|
+
data.forEach((item, index) => {
|
|
249
|
+
const value = item.value;
|
|
247
250
|
if (value >= threshold) {
|
|
248
|
-
|
|
251
|
+
const colorIndex = index - stepIndex;
|
|
249
252
|
item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
|
|
250
|
-
|
|
253
|
+
const color = getPieColor(color_option, column, colorIndex, item, currentTheme);
|
|
251
254
|
item.color = color;
|
|
252
255
|
colorSet.push(color);
|
|
253
256
|
filteredData.push(item);
|
|
@@ -258,18 +261,18 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
258
261
|
});
|
|
259
262
|
data = filteredData;
|
|
260
263
|
if (filteredItems.length > 0) {
|
|
261
|
-
|
|
264
|
+
const filteredSum = filteredItems.reduce((total, currentValue) => {
|
|
262
265
|
return total += currentValue.value;
|
|
263
266
|
}, 0);
|
|
264
|
-
|
|
267
|
+
let formattedValueSum = filteredSum;
|
|
265
268
|
if (isAdvanced) {
|
|
266
|
-
|
|
269
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
267
270
|
formattedValueSum = StatUtils.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
|
|
268
271
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
filteredItems.forEach(
|
|
272
|
+
let original_name_list = [];
|
|
273
|
+
let name_list = [];
|
|
274
|
+
let rows = [];
|
|
275
|
+
filteredItems.forEach(item => {
|
|
273
276
|
if (item.original_name) {
|
|
274
277
|
original_name_list.push(item.original_name);
|
|
275
278
|
}
|
|
@@ -277,13 +280,13 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
277
280
|
name_list.push(item.name);
|
|
278
281
|
}
|
|
279
282
|
if (item.rows) {
|
|
280
|
-
rows.push
|
|
283
|
+
rows.push(...item.rows);
|
|
281
284
|
}
|
|
282
285
|
});
|
|
283
286
|
data.push({
|
|
284
|
-
rows
|
|
285
|
-
name_list
|
|
286
|
-
original_name_list
|
|
287
|
+
rows,
|
|
288
|
+
name_list,
|
|
289
|
+
original_name_list,
|
|
287
290
|
name: intl.get('Others'),
|
|
288
291
|
value: filteredSum,
|
|
289
292
|
formatted_value: formattedValueSum,
|
|
@@ -297,61 +300,52 @@ export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
297
300
|
data.colorSet = colorSet;
|
|
298
301
|
return data;
|
|
299
302
|
}
|
|
300
|
-
export
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
precision =
|
|
303
|
+
export const formatNumericValue = function (value) {
|
|
304
|
+
let column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
305
|
+
const data = column.data || {};
|
|
306
|
+
let {
|
|
307
|
+
precision = 8
|
|
308
|
+
} = data;
|
|
305
309
|
value = value || 0;
|
|
306
310
|
return parseFloat(value.toFixed(precision));
|
|
307
311
|
};
|
|
308
|
-
export
|
|
312
|
+
export const getLabelFontSize = label_font_size => {
|
|
309
313
|
return isNumber(label_font_size) ? label_font_size : DEFAULT_LABEL_FONT_SIZE;
|
|
310
314
|
};
|
|
311
|
-
export
|
|
312
|
-
|
|
315
|
+
export const getSummaryColumnMethod = function (method, summaryColumnName) {
|
|
316
|
+
let useSingleQuote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
313
317
|
if (method === 'Distinct_values') {
|
|
314
318
|
return "COUNT(DISTINCT ".concat(summaryColumnName, ")");
|
|
315
319
|
}
|
|
316
320
|
return "".concat(method, "(").concat(useSingleQuote ? '`' : '').concat(summaryColumnName).concat(useSingleQuote ? '`' : '', ")");
|
|
317
321
|
};
|
|
318
|
-
export
|
|
322
|
+
export const getCurrentTheme = colorThemeName => {
|
|
319
323
|
if (colorThemeName) {
|
|
320
|
-
|
|
321
|
-
return item.name === colorThemeName;
|
|
322
|
-
});
|
|
324
|
+
const currentColorTheme = CHART_STYLE_COLORS.find(item => item.name === colorThemeName);
|
|
323
325
|
return currentColorTheme || CHART_STYLE_COLORS[0];
|
|
324
326
|
}
|
|
325
327
|
return CHART_STYLE_COLORS[0];
|
|
326
328
|
};
|
|
327
329
|
|
|
328
330
|
// for stacked bar, stacked horizontal bar
|
|
329
|
-
export
|
|
330
|
-
|
|
331
|
-
data.forEach(
|
|
332
|
-
if (nameSumMap.filter(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
var items = data.filter(function (originItem) {
|
|
336
|
-
return originItem.name == item.name;
|
|
337
|
-
});
|
|
338
|
-
var valueSum = items.reduce(function (accumulator, currentItem) {
|
|
339
|
-
return accumulator + currentItem.value;
|
|
340
|
-
}, 0);
|
|
331
|
+
export const sortDataByGroupSum = (data, sortType) => {
|
|
332
|
+
const nameSumMap = [];
|
|
333
|
+
data.forEach(item => {
|
|
334
|
+
if (nameSumMap.filter(filteredItem => filteredItem.name == item.name).length == 0) {
|
|
335
|
+
const items = data.filter(originItem => originItem.name == item.name);
|
|
336
|
+
const valueSum = items.reduce((accumulator, currentItem) => accumulator + currentItem.value, 0);
|
|
341
337
|
nameSumMap.push({
|
|
342
338
|
name: item.name,
|
|
343
|
-
items
|
|
344
|
-
valueSum
|
|
339
|
+
items,
|
|
340
|
+
valueSum
|
|
345
341
|
});
|
|
346
342
|
}
|
|
347
343
|
});
|
|
348
344
|
|
|
349
345
|
// sort group
|
|
350
346
|
StatUtils.sortDataByKey(nameSumMap, 'valueSum', sortType);
|
|
351
|
-
return nameSumMap.reduce(
|
|
352
|
-
return accumulator.concat(currentItem.items);
|
|
353
|
-
}, []);
|
|
347
|
+
return nameSumMap.reduce((accumulator, currentItem) => accumulator.concat(currentItem.items), []);
|
|
354
348
|
};
|
|
355
|
-
export
|
|
349
|
+
export const isBoolean = val => {
|
|
356
350
|
return typeof val === 'boolean';
|
|
357
351
|
};
|
package/es/utils/date-format.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
2
|
+
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
3
|
+
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
4
|
+
const frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
5
|
+
const deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
6
|
+
const esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
7
|
+
const plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
8
|
+
const csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
9
|
+
const ruRU = require('@seafile/seafile-calendar/lib/locale/ru_RU');
|
|
10
10
|
function translateCalendar() {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const locale = window.dtable ? window.dtable.lang : 'en';
|
|
12
|
+
let language;
|
|
13
13
|
switch (locale) {
|
|
14
14
|
case 'zh-cn':
|
|
15
15
|
language = zhCN;
|
|
@@ -50,12 +50,12 @@ function translateCalendar() {
|
|
|
50
50
|
return language;
|
|
51
51
|
}
|
|
52
52
|
function getTodayDate() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
let todayDate = new Date();
|
|
54
|
+
let year = todayDate.getFullYear();
|
|
55
|
+
let month = todayDate.getMonth() + 1;
|
|
56
|
+
let date = todayDate.getDate();
|
|
57
|
+
let hour = todayDate.getHours();
|
|
58
|
+
let minute = todayDate.getMinutes();
|
|
59
59
|
month = month > 9 ? month : "0".concat(month);
|
|
60
60
|
date = date > 9 ? date : "0".concat(date);
|
|
61
61
|
hour = hour > 9 ? hour : "0".concat(hour);
|