dtable-statistic 4.3.3 → 4.3.4
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 +3 -10
- package/es/calculator/base-calculator.js +12 -20
- package/es/calculator/basic-chart-calculator.js +65 -72
- package/es/calculator/combination-calculator.js +57 -64
- package/es/calculator/compare-bar-calculator.js +26 -33
- package/es/calculator/completeness-calculator.js +30 -37
- package/es/calculator/copy-value.js +1 -7
- package/es/calculator/dashboard-calculator.js +13 -20
- package/es/calculator/heat-map-calculator.js +18 -25
- package/es/calculator/horizontal-bar-calculator.js +8 -15
- package/es/calculator/index.js +35 -42
- package/es/calculator/map-calculator.js +22 -29
- package/es/calculator/mirror-calculator.js +20 -27
- package/es/calculator/number-card-calculator.js +10 -17
- package/es/calculator/pivot-table-calculator.js +58 -65
- package/es/calculator/scatter-calculator.js +14 -21
- package/es/calculator/thread-manager.js +1 -7
- package/es/calculator/trend-calculator.js +22 -29
- package/es/calculator/workers/basic-chart-calculator-worker.js +76 -83
- package/es/calculator/workers/calculator.worker.js +30 -33
- package/es/calculator/workers/card-calculator-worker.js +13 -19
- package/es/calculator/workers/combination-calculator-worker.js +46 -53
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +22 -29
- package/es/calculator/workers/completeness-calculator-worker.js +34 -41
- package/es/calculator/workers/dashboard-calculator-worker.js +18 -24
- package/es/calculator/workers/mirror-calculator-worker.js +22 -29
- package/es/calculator/workers/pivot-table-calculator-worker.js +77 -84
- package/es/calculator/workers/scatter-calculator-worker.js +20 -27
- package/es/calculator/workers/trend-calculator-worker.js +27 -34
- package/es/calculator/world-map-calculator.js +17 -24
- package/es/components/common-add-tool.js +5 -12
- package/es/components/dialog/chart-addition-edit-dialog.js +12 -20
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +101 -108
- package/es/components/dialog/color-theme-dialog.js +15 -22
- package/es/components/dialog/delete-confirmation-dialog.js +11 -18
- package/es/components/dialog/enlarged-chart-dialog.js +20 -28
- package/es/components/dialog/new-table-dialog.js +16 -23
- package/es/components/dialog/new-view-dialog.js +14 -21
- package/es/components/dialog/rename-view-dialog.js +14 -22
- package/es/components/dialog/statistic-record-dialog/index.js +37 -45
- package/es/components/dialog/statistic-types-dialog/index.js +14 -22
- package/es/components/dialog/table-select-dialog.js +15 -23
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +41 -49
- package/es/components/dtable-popover.js +12 -19
- package/es/components/dtable-search-input.js +13 -21
- package/es/components/dtable-select.js +15 -21
- package/es/components/icon.js +4 -11
- package/es/components/index.js +11 -76
- package/es/components/loading.js +3 -10
- package/es/components/modal-portal.js +5 -12
- package/es/components/popover/color-rules/color-rule.js +25 -33
- package/es/components/popover/color-rules/index.js +6 -14
- package/es/components/popover/color-rules/rule-filters/filter.js +27 -34
- package/es/components/popover/color-rules/rule-filters/index.js +17 -25
- package/es/components/popover/color-rules/rule-filters/number-input.js +9 -17
- package/es/components/popover/color-rules-popover.js +24 -32
- package/es/components/popover/color-selector-popover.js +10 -17
- package/es/components/seatable-radio/index.js +9 -16
- package/es/components/select/index.js +2 -9
- package/es/components/select/option-group.js +19 -27
- package/es/components/select/option.js +6 -14
- package/es/components/select/select.js +17 -25
- package/es/components/toast/alert.js +24 -31
- package/es/components/toast/index.js +3 -10
- package/es/components/toast/toast.js +12 -20
- package/es/components/toast/toastManager.js +9 -17
- package/es/components/toast/toaster.js +6 -14
- package/es/constants/color-rules.js +6 -12
- package/es/constants/dtable-select-style.js +4 -9
- package/es/constants/event-types.js +4 -10
- package/es/constants/index.js +67 -96
- package/es/constants/key-codes.js +0 -2
- package/es/constants/map.js +2 -8
- package/es/constants/model.js +20 -26
- package/es/constants/regions.js +3 -8
- package/es/constants/zIndexes.js +1 -7
- package/es/custom-g2.js +208 -236
- package/es/dashboard.js +50 -58
- package/es/desktop-dashboard.js +47 -55
- package/es/index.js +3 -6
- package/es/locale/index.js +10 -13
- package/es/locale/lang/de.js +1 -7
- package/es/locale/lang/en.js +1 -7
- package/es/locale/lang/fr.js +1 -7
- package/es/locale/lang/zh_CN.js +1 -7
- package/es/mobile-dashboard.js +38 -46
- package/es/model/bar-group.js +11 -19
- package/es/model/bar.js +10 -18
- package/es/model/base-model.js +2 -9
- package/es/model/basic-number-card.js +8 -16
- package/es/model/collaborators.js +2 -9
- package/es/model/combination.js +12 -20
- package/es/model/compare-bar.js +16 -24
- package/es/model/completeness-group.js +8 -16
- package/es/model/completeness.js +5 -13
- package/es/model/custom-bar.js +6 -14
- package/es/model/dashboard.js +6 -14
- package/es/model/generic-model.js +133 -141
- package/es/model/heat-map.js +11 -19
- package/es/model/horizontal-bar-group.js +10 -18
- package/es/model/horizontal-bar.js +10 -18
- package/es/model/index.js +53 -185
- package/es/model/map.js +15 -23
- package/es/model/mirror.js +13 -21
- package/es/model/pie.js +10 -18
- package/es/model/ring.js +11 -19
- package/es/model/scatter.js +6 -14
- package/es/model/statistic-dashboard.js +2 -9
- package/es/model/table.js +10 -18
- package/es/model/trend.js +12 -20
- package/es/model/world-map.js +13 -21
- package/es/service/chart-service.js +7 -14
- package/es/service/dashboard-service.js +34 -41
- package/es/service/map-json.js +8 -14
- package/es/stat-editor/chart-name-editor.js +8 -15
- package/es/stat-editor/index.js +16 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +21 -29
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +49 -57
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +4 -11
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +43 -51
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +37 -45
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +26 -34
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +47 -55
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +22 -30
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +27 -35
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +24 -32
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +33 -41
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +22 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +27 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +46 -54
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +23 -31
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +26 -34
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +77 -85
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +21 -29
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +73 -81
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +16 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +19 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +49 -57
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +47 -55
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +11 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +45 -53
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +9 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +20 -28
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +30 -38
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +50 -58
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +47 -55
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +11 -19
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +12 -19
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +62 -70
- package/es/stat-editor/stat-settings/map/map-level.js +13 -20
- package/es/stat-editor/stat-settings/map/map-province-city.js +20 -27
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +20 -28
- package/es/stat-editor/stat-settings/public-setting/calender.js +22 -29
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +6 -13
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +9 -16
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +13 -21
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +27 -35
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +18 -26
- package/es/stat-list/chart-preview.js +20 -28
- package/es/stat-list/index.js +27 -35
- package/es/stat-view/area-chart.js +43 -50
- package/es/stat-view/bar-chart.js +47 -54
- package/es/stat-view/base-chart.js +24 -32
- package/es/stat-view/basic-number-card.js +19 -26
- package/es/stat-view/combination-chart.js +49 -56
- package/es/stat-view/compare-chart.js +39 -46
- package/es/stat-view/completeness-chart.js +28 -35
- package/es/stat-view/custom-bar.js +31 -38
- package/es/stat-view/dashboard-chart.js +15 -22
- package/es/stat-view/heat-map.js +43 -50
- package/es/stat-view/horizontal-bar-chart.js +51 -58
- package/es/stat-view/index.js +73 -80
- package/es/stat-view/line-chart.js +39 -46
- package/es/stat-view/map.js +33 -40
- package/es/stat-view/mirror.js +21 -28
- package/es/stat-view/pie-chart.js +29 -36
- package/es/stat-view/pivot-table/index.js +32 -39
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +31 -39
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +29 -37
- package/es/stat-view/pivot-table/pivot-table-display-name.js +46 -54
- package/es/stat-view/pivot-table/two-dimension-table.js +62 -70
- package/es/stat-view/ring-chart.js +38 -45
- package/es/stat-view/scatter-chart.js +30 -37
- package/es/stat-view/treemap-chart.js +37 -44
- package/es/stat-view/trend-chart.js +32 -39
- package/es/stat-view/world-map.js +33 -40
- package/es/tabs/index.js +32 -40
- package/es/tabs/tab.js +26 -34
- package/es/utils/basic-chart-utils.js +2 -9
- package/es/utils/cell-format.js +14 -22
- package/es/utils/cell-value.js +7 -14
- package/es/utils/collaborator.js +4 -13
- package/es/utils/color-utils.js +18 -29
- package/es/utils/column-utils.js +18 -29
- package/es/utils/column.js +4 -11
- package/es/utils/common-utils.js +41 -65
- package/es/utils/date-format.js +2 -8
- package/es/utils/export-table-utils.js +82 -91
- package/es/utils/index.js +11 -100
- package/es/utils/map.js +26 -36
- package/es/utils/model.js +6 -14
- package/es/utils/object.js +6 -15
- package/es/utils/pivot-table.js +16 -23
- package/es/utils/row-utils.js +23 -33
- package/es/utils/search.js +21 -29
- package/es/utils/sql-utils.js +65 -75
- package/es/utils/stat-utils.js +60 -66
- package/es/utils/trend-utils.js +32 -40
- package/package.json +1 -1
package/es/utils/common-utils.js
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.arraysEqual = arraysEqual;
|
|
8
|
-
exports.formatNumericValue = void 0;
|
|
9
|
-
exports.formatPieChartData = formatPieChartData;
|
|
10
|
-
exports.isShapeEqual = exports.isBoolean = exports.isArrayCellValue = exports.getSummaryResult = exports.getSummaryColumnMethod = exports.getLabelFontSize = exports.getImageUrl = exports.getCurrentTheme = exports.generatorUniqueId = void 0;
|
|
11
|
-
exports.isStatItemEqual = isStatItemEqual;
|
|
12
|
-
exports.shallowEqual = shallowEqual;
|
|
13
|
-
exports.sortDataByGroupSum = exports.shouldCalculateStatItem = void 0;
|
|
14
|
-
var _dtableStore = require("dtable-store");
|
|
15
|
-
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
16
|
-
var _constants = require("../constants");
|
|
17
|
-
var _statUtils = _interopRequireDefault(require("./stat-utils"));
|
|
18
|
-
const generatorUniqueId = list => {
|
|
1
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, generatorBase64Code, isNumber, TableUtils } from 'dtable-store';
|
|
2
|
+
import intl from 'react-intl-universal';
|
|
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';
|
|
4
|
+
import StatUtils from './stat-utils';
|
|
5
|
+
export const generatorUniqueId = list => {
|
|
19
6
|
let uniqueId;
|
|
20
7
|
let isUnique = false;
|
|
21
8
|
while (!isUnique) {
|
|
22
|
-
uniqueId =
|
|
9
|
+
uniqueId = generatorBase64Code();
|
|
23
10
|
|
|
24
11
|
// eslint-disable-next-line
|
|
25
12
|
if (!Array.isArray(list) || list.length === 0) {
|
|
@@ -32,28 +19,25 @@ const generatorUniqueId = list => {
|
|
|
32
19
|
}
|
|
33
20
|
return uniqueId;
|
|
34
21
|
};
|
|
35
|
-
|
|
36
|
-
const getImageUrl = imageName => {
|
|
22
|
+
export const getImageUrl = imageName => {
|
|
37
23
|
const {
|
|
38
24
|
mediaUrl
|
|
39
25
|
} = window.dtable;
|
|
40
26
|
return "".concat(mediaUrl, "dtable-statistic/img/").concat(imageName);
|
|
41
27
|
};
|
|
42
|
-
|
|
43
|
-
const isShapeEqual = (position1, position2) => {
|
|
28
|
+
export const isShapeEqual = (position1, position2) => {
|
|
44
29
|
if (position1 && position2) {
|
|
45
30
|
return position1.w === position2.w && position1.h === position2.h;
|
|
46
31
|
}
|
|
47
32
|
if (!position1 && !position2) return true;
|
|
48
33
|
return false;
|
|
49
34
|
};
|
|
50
|
-
|
|
51
|
-
function isStatItemEqual(prevStatItem, chart) {
|
|
35
|
+
export function isStatItemEqual(prevStatItem, chart) {
|
|
52
36
|
let statItemType = prevStatItem.type;
|
|
53
37
|
if (statItemType !== chart.type) return false;
|
|
54
38
|
return shallowEqual(prevStatItem, chart);
|
|
55
39
|
}
|
|
56
|
-
function shallowEqual(objA, objB) {
|
|
40
|
+
export function shallowEqual(objA, objB) {
|
|
57
41
|
if (objA === objB) {
|
|
58
42
|
return true;
|
|
59
43
|
}
|
|
@@ -87,7 +71,7 @@ function shallowEqual(objA, objB) {
|
|
|
87
71
|
if (key === 'show_y_axis_right_label') continue;
|
|
88
72
|
if (key === 'y_axis_left_label_position') continue;
|
|
89
73
|
if (key === 'y_axis_right_label_position') continue;
|
|
90
|
-
if (objA.type !== 'basic_number_card' && objA.type !==
|
|
74
|
+
if (objA.type !== 'basic_number_card' && objA.type !== STAT_TYPE.DASHBOARD && key === 'name') continue;
|
|
91
75
|
if (Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
92
76
|
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
93
77
|
let isArrayEqual = arraysEqual(valueA, valueB);
|
|
@@ -105,7 +89,7 @@ function shallowEqual(objA, objB) {
|
|
|
105
89
|
return true;
|
|
106
90
|
}
|
|
107
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'];
|
|
108
|
-
const shouldCalculateStatItem = (prevStatItem, chart) => {
|
|
92
|
+
export const shouldCalculateStatItem = (prevStatItem, chart) => {
|
|
109
93
|
let statItemType = prevStatItem.type;
|
|
110
94
|
if (statItemType !== chart.type) return true;
|
|
111
95
|
if (prevStatItem === chart) {
|
|
@@ -137,8 +121,7 @@ const shouldCalculateStatItem = (prevStatItem, chart) => {
|
|
|
137
121
|
}
|
|
138
122
|
return false;
|
|
139
123
|
};
|
|
140
|
-
|
|
141
|
-
function arraysEqual(arrayA, arrayB) {
|
|
124
|
+
export function arraysEqual(arrayA, arrayB) {
|
|
142
125
|
if (arrayA === null || arrayB === null) return false;
|
|
143
126
|
if (arrayA.length !== arrayB.length) return false;
|
|
144
127
|
for (let i = 0; i < arrayA.length; i++) {
|
|
@@ -146,37 +129,37 @@ function arraysEqual(arrayA, arrayB) {
|
|
|
146
129
|
}
|
|
147
130
|
return true;
|
|
148
131
|
}
|
|
149
|
-
const isArrayCellValue = column => {
|
|
132
|
+
export const isArrayCellValue = column => {
|
|
150
133
|
if (!column) return false;
|
|
151
134
|
const {
|
|
152
135
|
type,
|
|
153
136
|
data
|
|
154
137
|
} = column;
|
|
155
|
-
return
|
|
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
|
|
156
139
|
;
|
|
157
140
|
};
|
|
158
|
-
|
|
159
|
-
const getSummaryResult = function (results, summaryMethod) {
|
|
141
|
+
|
|
142
|
+
export const getSummaryResult = function (results, summaryMethod) {
|
|
160
143
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
161
|
-
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res =>
|
|
144
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => isNumber(res)) : [];
|
|
162
145
|
switch (summaryMethod) {
|
|
163
|
-
case
|
|
146
|
+
case SUMMARY_METHOD_MAP.Max:
|
|
164
147
|
{
|
|
165
148
|
return getMax(numericResults);
|
|
166
149
|
}
|
|
167
|
-
case
|
|
150
|
+
case SUMMARY_METHOD_MAP.Min:
|
|
168
151
|
{
|
|
169
152
|
return getMin(numericResults);
|
|
170
153
|
}
|
|
171
|
-
case
|
|
154
|
+
case SUMMARY_METHOD_MAP.Sum:
|
|
172
155
|
{
|
|
173
156
|
return getSum(numericResults, precision);
|
|
174
157
|
}
|
|
175
|
-
case
|
|
158
|
+
case SUMMARY_METHOD_MAP.Mean:
|
|
176
159
|
{
|
|
177
160
|
return getMean(numericResults, precision);
|
|
178
161
|
}
|
|
179
|
-
case
|
|
162
|
+
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
180
163
|
{
|
|
181
164
|
let count = 0;
|
|
182
165
|
let existMap = {};
|
|
@@ -202,7 +185,6 @@ const getSummaryResult = function (results, summaryMethod) {
|
|
|
202
185
|
}
|
|
203
186
|
}
|
|
204
187
|
};
|
|
205
|
-
exports.getSummaryResult = getSummaryResult;
|
|
206
188
|
const getMax = list => {
|
|
207
189
|
if (list.length === 0) return 0;
|
|
208
190
|
return Number.parseFloat(Math.max.apply(null, list));
|
|
@@ -233,7 +215,7 @@ const getPieColor = (color_option, column, index, data, currentTheme) => {
|
|
|
233
215
|
const {
|
|
234
216
|
colors
|
|
235
217
|
} = currentTheme;
|
|
236
|
-
if (color_option ===
|
|
218
|
+
if (color_option === PIE_COLOR_OPTIONS[1] && (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT)) {
|
|
237
219
|
if (columnData && columnData.options) {
|
|
238
220
|
const selectedItem = columnData.options.find(item => item.name === data.name) || {};
|
|
239
221
|
return selectedItem.color || '#dbdbdb';
|
|
@@ -244,7 +226,7 @@ const getPieColor = (color_option, column, index, data, currentTheme) => {
|
|
|
244
226
|
return colors[colorIndex];
|
|
245
227
|
}
|
|
246
228
|
};
|
|
247
|
-
function formatPieChartData(data, statItem, table, currentTheme) {
|
|
229
|
+
export function formatPieChartData(data, statItem, table, currentTheme) {
|
|
248
230
|
const {
|
|
249
231
|
groupby_column_key,
|
|
250
232
|
color_option,
|
|
@@ -253,7 +235,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
253
235
|
summary_type
|
|
254
236
|
} = statItem;
|
|
255
237
|
const isAdvanced = summary_type === 'advanced';
|
|
256
|
-
const column =
|
|
238
|
+
const column = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
257
239
|
let sum = data.reduce((total, currentValue) => {
|
|
258
240
|
return total += currentValue.value;
|
|
259
241
|
}, 0);
|
|
@@ -284,8 +266,8 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
284
266
|
}, 0);
|
|
285
267
|
let formattedValueSum = filteredSum;
|
|
286
268
|
if (isAdvanced) {
|
|
287
|
-
const summaryColumn =
|
|
288
|
-
formattedValueSum =
|
|
269
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
270
|
+
formattedValueSum = StatUtils.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
|
|
289
271
|
}
|
|
290
272
|
let original_name_list = [];
|
|
291
273
|
let name_list = [];
|
|
@@ -305,7 +287,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
305
287
|
rows,
|
|
306
288
|
name_list,
|
|
307
289
|
original_name_list,
|
|
308
|
-
name:
|
|
290
|
+
name: intl.get('Others'),
|
|
309
291
|
value: filteredSum,
|
|
310
292
|
formatted_value: formattedValueSum,
|
|
311
293
|
color: '#dbdbdb',
|
|
@@ -318,7 +300,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
|
|
|
318
300
|
data.colorSet = colorSet;
|
|
319
301
|
return data;
|
|
320
302
|
}
|
|
321
|
-
const formatNumericValue = function (value) {
|
|
303
|
+
export const formatNumericValue = function (value) {
|
|
322
304
|
let column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
323
305
|
const data = column.data || {};
|
|
324
306
|
let {
|
|
@@ -327,30 +309,26 @@ const formatNumericValue = function (value) {
|
|
|
327
309
|
value = value || 0;
|
|
328
310
|
return parseFloat(value.toFixed(precision));
|
|
329
311
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return (0, _dtableStore.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
|
|
312
|
+
export const getLabelFontSize = label_font_size => {
|
|
313
|
+
return isNumber(label_font_size) ? label_font_size : DEFAULT_LABEL_FONT_SIZE;
|
|
333
314
|
};
|
|
334
|
-
|
|
335
|
-
const getSummaryColumnMethod = function (method, summaryColumnName) {
|
|
315
|
+
export const getSummaryColumnMethod = function (method, summaryColumnName) {
|
|
336
316
|
let useSingleQuote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
337
317
|
if (method === 'Distinct_values') {
|
|
338
318
|
return "COUNT(DISTINCT ".concat(summaryColumnName, ")");
|
|
339
319
|
}
|
|
340
320
|
return "".concat(method, "(").concat(useSingleQuote ? '`' : '').concat(summaryColumnName).concat(useSingleQuote ? '`' : '', ")");
|
|
341
321
|
};
|
|
342
|
-
|
|
343
|
-
const getCurrentTheme = colorThemeName => {
|
|
322
|
+
export const getCurrentTheme = colorThemeName => {
|
|
344
323
|
if (colorThemeName) {
|
|
345
|
-
const currentColorTheme =
|
|
346
|
-
return currentColorTheme ||
|
|
324
|
+
const currentColorTheme = CHART_STYLE_COLORS.find(item => item.name === colorThemeName);
|
|
325
|
+
return currentColorTheme || CHART_STYLE_COLORS[0];
|
|
347
326
|
}
|
|
348
|
-
return
|
|
327
|
+
return CHART_STYLE_COLORS[0];
|
|
349
328
|
};
|
|
350
329
|
|
|
351
330
|
// for stacked bar, stacked horizontal bar
|
|
352
|
-
|
|
353
|
-
const sortDataByGroupSum = (data, sortType) => {
|
|
331
|
+
export const sortDataByGroupSum = (data, sortType) => {
|
|
354
332
|
const nameSumMap = [];
|
|
355
333
|
data.forEach(item => {
|
|
356
334
|
if (nameSumMap.filter(filteredItem => filteredItem.name === item.name).length === 0) {
|
|
@@ -365,11 +343,9 @@ const sortDataByGroupSum = (data, sortType) => {
|
|
|
365
343
|
});
|
|
366
344
|
|
|
367
345
|
// sort group
|
|
368
|
-
|
|
346
|
+
StatUtils.sortDataByKey(nameSumMap, 'valueSum', sortType);
|
|
369
347
|
return nameSumMap.reduce((accumulator, currentItem) => accumulator.concat(currentItem.items), []);
|
|
370
348
|
};
|
|
371
|
-
|
|
372
|
-
const isBoolean = val => {
|
|
349
|
+
export const isBoolean = val => {
|
|
373
350
|
return typeof val === 'boolean';
|
|
374
|
-
};
|
|
375
|
-
exports.isBoolean = isBoolean;
|
|
351
|
+
};
|
package/es/utils/date-format.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTodayDate = getTodayDate;
|
|
7
|
-
exports.translateCalendar = translateCalendar;
|
|
8
1
|
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
9
2
|
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
10
3
|
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
@@ -68,4 +61,5 @@ function getTodayDate() {
|
|
|
68
61
|
hour = hour > 9 ? hour : "0".concat(hour);
|
|
69
62
|
minute = minute > 9 ? minute : "0".concat(minute);
|
|
70
63
|
return "".concat(year, "-").concat(month, "-").concat(date, " ").concat(hour, ":").concat(minute);
|
|
71
|
-
}
|
|
64
|
+
}
|
|
65
|
+
export { translateCalendar, getTodayDate };
|