dtable-statistic 4.0.2-test-2
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/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, generatorBase64Code, isNumber, TableUtils } from 'dtable-store';
|
|
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
|
+
export var generatorUniqueId = function generatorUniqueId(list) {
|
|
4
|
+
var uniqueId;
|
|
5
|
+
var isUnique = false;
|
|
6
|
+
while (!isUnique) {
|
|
7
|
+
uniqueId = generatorBase64Code();
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
isUnique = Array.isArray(list) && list.length > 0 ? true : list.every(function (item) {
|
|
11
|
+
return item._id !== uniqueId;
|
|
12
|
+
});
|
|
13
|
+
if (isUnique) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return uniqueId;
|
|
18
|
+
};
|
|
19
|
+
export var getImageUrl = function getImageUrl(imageName) {
|
|
20
|
+
var mediaUrl = window.dtable.mediaUrl;
|
|
21
|
+
return "".concat(mediaUrl, "dtable-statistic/img/").concat(imageName);
|
|
22
|
+
};
|
|
23
|
+
export var isShapeEqual = function isShapeEqual(position1, position2) {
|
|
24
|
+
if (position1 && position2) {
|
|
25
|
+
return position1.w === position2.w && position1.h === position2.h;
|
|
26
|
+
}
|
|
27
|
+
if (!position1 && !position2) return true;
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
export function isStatItemEqual(prevStatItem, chart) {
|
|
31
|
+
var statItemType = prevStatItem.type;
|
|
32
|
+
if (statItemType !== chart.type) return false;
|
|
33
|
+
return shallowEqual(prevStatItem, chart);
|
|
34
|
+
}
|
|
35
|
+
export function shallowEqual(objA, objB) {
|
|
36
|
+
if (objA === objB) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
var keysA = Object.keys(objA);
|
|
43
|
+
var keysB = Object.keys(objB);
|
|
44
|
+
if (keysA.length !== keysB.length) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
48
|
+
var key = keysA[i];
|
|
49
|
+
var valueA = objA[key];
|
|
50
|
+
var valueB = objB[key];
|
|
51
|
+
if (key === 'layout') continue;
|
|
52
|
+
// line | chart-bar | chart-bar-stack | chart-bar-group
|
|
53
|
+
if (key === 'show_x_axis_label') continue;
|
|
54
|
+
if (key === 'show_y_axis_label') continue;
|
|
55
|
+
if (key === 'x_axis_label_position') continue;
|
|
56
|
+
if (key === 'y_axis_label_position') continue;
|
|
57
|
+
|
|
58
|
+
// horizontal bar | horizontal group bar
|
|
59
|
+
if (key === 'show_vertical_axis_label') continue;
|
|
60
|
+
if (key === 'show_horizontal_axis_label') continue;
|
|
61
|
+
if (key === 'vertical_axis_label_position') continue;
|
|
62
|
+
if (key === 'horizontal_axis_label_position') continue;
|
|
63
|
+
|
|
64
|
+
// combination chart
|
|
65
|
+
if (key === 'show_y_axis_left_label') continue;
|
|
66
|
+
if (key === 'show_y_axis_right_label') continue;
|
|
67
|
+
if (key === 'y_axis_left_label_position') continue;
|
|
68
|
+
if (key === 'y_axis_right_label_position') continue;
|
|
69
|
+
if (objA.type !== 'basic_number_card' && objA.type !== STAT_TYPE.DASHBOARD && key === 'name') continue;
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
71
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
72
|
+
var isArrayEqual = arraysEqual(valueA, valueB);
|
|
73
|
+
if (!isArrayEqual) return false;
|
|
74
|
+
} else if (valueA !== valueB) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!isShapeEqual(objA.layout, objB.layout)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
var 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'];
|
|
87
|
+
export var shouldCalculateStatItem = function shouldCalculateStatItem(prevStatItem, chart) {
|
|
88
|
+
var statItemType = prevStatItem.type;
|
|
89
|
+
if (statItemType !== chart.type) return true;
|
|
90
|
+
if (prevStatItem === chart) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (typeof prevStatItem !== 'object' || !prevStatItem || typeof chart !== 'object' || !chart) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
var keysA = Object.keys(prevStatItem);
|
|
97
|
+
var keysB = Object.keys(chart);
|
|
98
|
+
if (keysA.length !== keysB.length) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
102
|
+
var key = keysA[i];
|
|
103
|
+
var valueA = prevStatItem[key];
|
|
104
|
+
var valueB = chart[key];
|
|
105
|
+
if (IGNORE_STAT_KEYS.includes(key)) continue;
|
|
106
|
+
if (Object.prototype.hasOwnProperty.call(chart, key)) {
|
|
107
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
108
|
+
var isArrayEqual = arraysEqual(valueA, valueB);
|
|
109
|
+
if (!isArrayEqual) return true;
|
|
110
|
+
} else if (valueA !== valueB) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
export function arraysEqual(arrayA, arrayB) {
|
|
120
|
+
if (arrayA === null || arrayB === null) return false;
|
|
121
|
+
if (arrayA.length !== arrayB.length) return false;
|
|
122
|
+
for (var i = 0; i < arrayA.length; i++) {
|
|
123
|
+
if (!shallowEqual(arrayA[i], arrayB[i])) return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
export var isArrayCellValue = function isArrayCellValue(column) {
|
|
128
|
+
if (!column) return false;
|
|
129
|
+
var type = column.type,
|
|
130
|
+
data = column.data;
|
|
131
|
+
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
|
|
132
|
+
;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export var getSummaryResult = function getSummaryResult(results, summaryMethod) {
|
|
136
|
+
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
137
|
+
switch (summaryMethod) {
|
|
138
|
+
case SUMMARY_METHOD_MAP.Max:
|
|
139
|
+
{
|
|
140
|
+
return getMax(results);
|
|
141
|
+
}
|
|
142
|
+
case SUMMARY_METHOD_MAP.Min:
|
|
143
|
+
{
|
|
144
|
+
return getMin(results);
|
|
145
|
+
}
|
|
146
|
+
case SUMMARY_METHOD_MAP.Sum:
|
|
147
|
+
{
|
|
148
|
+
return getSum(results, precision);
|
|
149
|
+
}
|
|
150
|
+
case SUMMARY_METHOD_MAP.Mean:
|
|
151
|
+
{
|
|
152
|
+
return getMean(results, precision);
|
|
153
|
+
}
|
|
154
|
+
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
155
|
+
{
|
|
156
|
+
var result = new Set(results).size;
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
default:
|
|
160
|
+
{
|
|
161
|
+
return 0;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var getMax = function getMax(list) {
|
|
166
|
+
if (list.length === 0) return 0;
|
|
167
|
+
return Number.parseFloat(Math.max.apply(null, list));
|
|
168
|
+
};
|
|
169
|
+
var getMin = function getMin(list) {
|
|
170
|
+
if (list.length === 0) return 0;
|
|
171
|
+
return Number.parseFloat(Math.min.apply(null, list).toFixed(8));
|
|
172
|
+
};
|
|
173
|
+
var getSum = function getSum(list) {
|
|
174
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
175
|
+
if (list.length === 0) return 0;
|
|
176
|
+
var sum = list.reduce(function (a, b) {
|
|
177
|
+
return a + b;
|
|
178
|
+
}, 0);
|
|
179
|
+
return Number.parseFloat(Number(sum).toFixed(8));
|
|
180
|
+
};
|
|
181
|
+
var getMean = function getMean(list) {
|
|
182
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
183
|
+
if (list.length === 0) return 0;
|
|
184
|
+
var sum = getSum(list);
|
|
185
|
+
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
186
|
+
};
|
|
187
|
+
var getPieColor = function getPieColor(color_option, column, index, data, currentTheme) {
|
|
188
|
+
var columnType = column.type,
|
|
189
|
+
columnData = column.data;
|
|
190
|
+
var colors = currentTheme.colors;
|
|
191
|
+
if (color_option === PIE_COLOR_OPTIONS[1] && (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT)) {
|
|
192
|
+
if (columnData && columnData.options) {
|
|
193
|
+
var selectedItem = columnData.options.find(function (item) {
|
|
194
|
+
return item.name === data.name;
|
|
195
|
+
}) || {};
|
|
196
|
+
return selectedItem.color || '#dbdbdb';
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
var newIndex = String(index).at(-1);
|
|
200
|
+
return colors[newIndex];
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
204
|
+
var groupby_column_key = statItem.groupby_column_key,
|
|
205
|
+
color_option = statItem.color_option;
|
|
206
|
+
var column = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
207
|
+
var sum = data.reduce(function (total, currentValue) {
|
|
208
|
+
return total += currentValue.value;
|
|
209
|
+
}, 0);
|
|
210
|
+
var minimumSlicePercentage = typeof statItem.minimum_slice_percent === 'number' ? statItem.minimum_slice_percent : 1.5;
|
|
211
|
+
var threshold = sum * (minimumSlicePercentage / 100 || 0);
|
|
212
|
+
var filteredItems = [];
|
|
213
|
+
var colorSet = [];
|
|
214
|
+
var filteredData = [];
|
|
215
|
+
var stepIndex = 0;
|
|
216
|
+
data.forEach(function (item, index) {
|
|
217
|
+
var value = item.value;
|
|
218
|
+
if (value >= threshold) {
|
|
219
|
+
var colorIndex = index - stepIndex;
|
|
220
|
+
item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
|
|
221
|
+
var color = getPieColor(color_option, column, colorIndex, item, currentTheme);
|
|
222
|
+
item.color = color;
|
|
223
|
+
colorSet.push(color);
|
|
224
|
+
filteredData.push(item);
|
|
225
|
+
} else {
|
|
226
|
+
stepIndex += 1;
|
|
227
|
+
filteredItems.push(item);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
data = filteredData;
|
|
231
|
+
if (filteredItems.length > 0) {
|
|
232
|
+
var filteredSum = filteredItems.reduce(function (total, currentValue) {
|
|
233
|
+
return total += currentValue.value;
|
|
234
|
+
}, 0);
|
|
235
|
+
data.push({
|
|
236
|
+
name: 'Others',
|
|
237
|
+
value: filteredSum,
|
|
238
|
+
color: '#dbdbdb',
|
|
239
|
+
percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%'
|
|
240
|
+
});
|
|
241
|
+
colorSet.push('#dbdbdb');
|
|
242
|
+
}
|
|
243
|
+
data.total = sum;
|
|
244
|
+
data.colorSet = colorSet;
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
export var formatNumericValue = function formatNumericValue(value) {
|
|
248
|
+
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
249
|
+
var data = column.data || {};
|
|
250
|
+
var _data$precision = data.precision,
|
|
251
|
+
precision = _data$precision === void 0 ? 8 : _data$precision;
|
|
252
|
+
value = value || 0;
|
|
253
|
+
return parseFloat(value.toFixed(precision));
|
|
254
|
+
};
|
|
255
|
+
export var getLabelFontSize = function getLabelFontSize(label_font_size) {
|
|
256
|
+
return isNumber(label_font_size) ? label_font_size : DEFAULT_LABEL_FONT_SIZE;
|
|
257
|
+
};
|
|
258
|
+
export var getSummaryColumnMethod = function getSummaryColumnMethod(method, summaryColumnName) {
|
|
259
|
+
var useSingleQuote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
260
|
+
if (method === 'Distinct_values') {
|
|
261
|
+
return "COUNT(DISTINCT ".concat(summaryColumnName, ")");
|
|
262
|
+
}
|
|
263
|
+
return "".concat(method, "(").concat(useSingleQuote ? '`' : '').concat(summaryColumnName).concat(useSingleQuote ? '`' : '', ")");
|
|
264
|
+
};
|
|
265
|
+
export var getCurrentTheme = function getCurrentTheme(colorThemeName) {
|
|
266
|
+
if (colorThemeName) {
|
|
267
|
+
var currentColorTheme = CHART_STYLE_COLORS.find(function (item) {
|
|
268
|
+
return item.name === colorThemeName;
|
|
269
|
+
});
|
|
270
|
+
return currentColorTheme || CHART_STYLE_COLORS[0];
|
|
271
|
+
}
|
|
272
|
+
return CHART_STYLE_COLORS[0];
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// for stacked bar, stacked horizontal bar
|
|
276
|
+
export var sortDataByGroupSum = function sortDataByGroupSum(data, sortType) {
|
|
277
|
+
var nameSumMap = [];
|
|
278
|
+
data.forEach(function (item) {
|
|
279
|
+
if (nameSumMap.filter(function (filteredItem) {
|
|
280
|
+
return filteredItem.name == item.name;
|
|
281
|
+
}).length == 0) {
|
|
282
|
+
var items = data.filter(function (originItem) {
|
|
283
|
+
return originItem.name == item.name;
|
|
284
|
+
});
|
|
285
|
+
var valueSum = items.reduce(function (accumulator, currentItem) {
|
|
286
|
+
return accumulator + currentItem.value;
|
|
287
|
+
}, 0);
|
|
288
|
+
nameSumMap.push({
|
|
289
|
+
name: item.name,
|
|
290
|
+
items: items,
|
|
291
|
+
valueSum: valueSum
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
var sortSum = sortType == 'ascending' ? function (a, b) {
|
|
296
|
+
return a.valueSum - b.valueSum;
|
|
297
|
+
} : function (a, b) {
|
|
298
|
+
return b.valueSum - a.valueSum;
|
|
299
|
+
};
|
|
300
|
+
return nameSumMap.sort(sortSum).reduce(function (accumulator, currentItem) {
|
|
301
|
+
return accumulator.concat(currentItem.items);
|
|
302
|
+
}, []);
|
|
303
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
2
|
+
var zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
3
|
+
var enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
4
|
+
var frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
5
|
+
var deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
6
|
+
var esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
7
|
+
var plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
8
|
+
var csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
9
|
+
var ruRU = require('@seafile/seafile-calendar/lib/locale/ru_RU');
|
|
10
|
+
function translateCalendar() {
|
|
11
|
+
var locale = window.dtable ? window.dtable.lang : 'en';
|
|
12
|
+
var language;
|
|
13
|
+
switch (locale) {
|
|
14
|
+
case 'zh-cn':
|
|
15
|
+
language = zhCN;
|
|
16
|
+
break;
|
|
17
|
+
case 'zh-tw':
|
|
18
|
+
language = zhTW;
|
|
19
|
+
break;
|
|
20
|
+
case 'en':
|
|
21
|
+
language = enUS;
|
|
22
|
+
break;
|
|
23
|
+
case 'fr':
|
|
24
|
+
language = frFR;
|
|
25
|
+
break;
|
|
26
|
+
case 'de':
|
|
27
|
+
language = deDE;
|
|
28
|
+
break;
|
|
29
|
+
case 'es':
|
|
30
|
+
language = esES;
|
|
31
|
+
break;
|
|
32
|
+
case 'es-ar':
|
|
33
|
+
language = esES;
|
|
34
|
+
break;
|
|
35
|
+
case 'es-mx':
|
|
36
|
+
language = esES;
|
|
37
|
+
break;
|
|
38
|
+
case 'pl':
|
|
39
|
+
language = plPL;
|
|
40
|
+
break;
|
|
41
|
+
case 'cs':
|
|
42
|
+
language = csCZ;
|
|
43
|
+
break;
|
|
44
|
+
case 'ru':
|
|
45
|
+
language = ruRU;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
language = enUS;
|
|
49
|
+
}
|
|
50
|
+
return language;
|
|
51
|
+
}
|
|
52
|
+
function getTodayDate() {
|
|
53
|
+
var todayDate = new Date();
|
|
54
|
+
var year = todayDate.getFullYear();
|
|
55
|
+
var month = todayDate.getMonth() + 1;
|
|
56
|
+
var date = todayDate.getDate();
|
|
57
|
+
var hour = todayDate.getHours();
|
|
58
|
+
var minute = todayDate.getMinutes();
|
|
59
|
+
month = month > 9 ? month : "0".concat(month);
|
|
60
|
+
date = date > 9 ? date : "0".concat(date);
|
|
61
|
+
hour = hour > 9 ? hour : "0".concat(hour);
|
|
62
|
+
minute = minute > 9 ? minute : "0".concat(minute);
|
|
63
|
+
return "".concat(year, "-").concat(month, "-").concat(date, " ").concat(hour, ":").concat(minute);
|
|
64
|
+
}
|
|
65
|
+
export { translateCalendar, getTodayDate };
|