sea-chart 2.0.36 → 2.0.38
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/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +49 -57
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +65 -73
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
exports.findIfColumnDataIsArray = findIfColumnDataIsArray;
|
|
9
|
-
var _shallowequal = _interopRequireDefault(require("shallowequal"));
|
|
10
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
|
-
var _slugid = _interopRequireDefault(require("slugid"));
|
|
12
|
-
var _dtableUtils = require("dtable-utils");
|
|
13
|
-
var _constants = require("../../constants");
|
|
14
|
-
var _cellFormatUtils = require("../cell-format-utils");
|
|
15
|
-
var _collaboratorUtils = require("../collaborator-utils");
|
|
16
|
-
var _columnUtils = require("../column-utils");
|
|
17
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
-
var _context = _interopRequireDefault(require("../../context"));
|
|
19
|
-
var _collaborator = require("../collaborator");
|
|
20
|
-
var _index = require("../index");
|
|
21
1
|
var _BaseUtils;
|
|
22
|
-
|
|
2
|
+
import shallowEqual from 'shallowequal';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import slugid from 'slugid';
|
|
5
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString, isArchiveView, getViewById, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP } from 'dtable-utils';
|
|
6
|
+
import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE, HORIZONTAL_BAR_CHART_TYPES, COMPLTETELESS_CHART_TYPES, CHART_STYLE_CONFIG_SETTING_KEYS, MAP_CHART_TYPES } from '../../constants';
|
|
7
|
+
import { getClientFormulaDisplayString } from '../cell-format-utils';
|
|
8
|
+
import { getKnownCollaboratorByEmail, generateDefaultUser } from '../collaborator-utils';
|
|
9
|
+
import { getDateColumnFormat, getColumnByKey } from '../column-utils';
|
|
10
|
+
import intl from '../../intl';
|
|
11
|
+
import context from '../../context';
|
|
12
|
+
import { isValidCollaboratorEmail } from '../collaborator';
|
|
13
|
+
import { formatRowTotal, getFirstDayOfWeekForGroupby } from '../index';
|
|
14
|
+
export function findIfColumnDataIsArray(column) {
|
|
23
15
|
// link-formula may also be an array type column
|
|
24
|
-
let isGroupbyColumnDataAsAnArray = !!
|
|
25
|
-
if (column.type ===
|
|
16
|
+
let isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[column.type];
|
|
17
|
+
if (column.type === CellType.LINK_FORMULA) {
|
|
26
18
|
const {
|
|
27
19
|
result_type
|
|
28
20
|
} = column.data || {};
|
|
@@ -50,12 +42,12 @@ BaseUtils.updateSummaryValuePrecision = (result, summaryColumn, summaryValueKey)
|
|
|
50
42
|
if (enable_precision) {
|
|
51
43
|
result.forEach(item => {
|
|
52
44
|
if (format === 'percent') {
|
|
53
|
-
item[summaryValueKey] = parseFloat(
|
|
45
|
+
item[summaryValueKey] = parseFloat(getPrecisionNumber(item[summaryValueKey] * 100, {
|
|
54
46
|
enable_precision,
|
|
55
47
|
precision
|
|
56
48
|
})) / 100;
|
|
57
49
|
} else {
|
|
58
|
-
item[summaryValueKey] = parseFloat(
|
|
50
|
+
item[summaryValueKey] = parseFloat(getPrecisionNumber(item[summaryValueKey], {
|
|
59
51
|
enable_precision,
|
|
60
52
|
precision
|
|
61
53
|
}));
|
|
@@ -64,21 +56,21 @@ BaseUtils.updateSummaryValuePrecision = (result, summaryColumn, summaryValueKey)
|
|
|
64
56
|
}
|
|
65
57
|
};
|
|
66
58
|
BaseUtils.isCollaborator = column => {
|
|
67
|
-
return column.type ===
|
|
59
|
+
return column.type === CellType.COLLABORATOR;
|
|
68
60
|
};
|
|
69
61
|
// valid chart
|
|
70
62
|
BaseUtils.isValidCombinationChart = (config, table) => {
|
|
71
63
|
const summaryLeftColumnKey = config.y_axis_left_summary_column;
|
|
72
64
|
const summaryLeftType = config.y_axis_left_summary_type;
|
|
73
|
-
if (summaryLeftType ===
|
|
65
|
+
if (summaryLeftType === CHART_SUMMARY_TYPE.ADVANCED && !summaryLeftColumnKey) return false;
|
|
74
66
|
if (summaryLeftColumnKey) {
|
|
75
|
-
if (!
|
|
67
|
+
if (!getTableColumnByKey(table, summaryLeftColumnKey)) return false;
|
|
76
68
|
}
|
|
77
69
|
const summaryRightColumnKey = config.y_axis_right_summary_column;
|
|
78
70
|
const summaryRightType = config.y_axis_right_summary_type;
|
|
79
|
-
if (summaryRightType ===
|
|
71
|
+
if (summaryRightType === CHART_SUMMARY_TYPE.ADVANCED && !summaryRightColumnKey) return false;
|
|
80
72
|
if (summaryRightColumnKey) {
|
|
81
|
-
return
|
|
73
|
+
return getTableColumnByKey(table, summaryRightColumnKey);
|
|
82
74
|
}
|
|
83
75
|
return true;
|
|
84
76
|
};
|
|
@@ -91,39 +83,39 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
91
83
|
table_id,
|
|
92
84
|
type
|
|
93
85
|
} = config;
|
|
94
|
-
const table =
|
|
86
|
+
const table = getTableById(tables, table_id);
|
|
95
87
|
if (!table) return false;
|
|
96
88
|
|
|
97
89
|
// if table exists then it's a valid TABLE_ELEMENT chart
|
|
98
|
-
if (type ===
|
|
90
|
+
if (type === CHART_TYPE.TABLE_ELEMENT) {
|
|
99
91
|
return true;
|
|
100
92
|
}
|
|
101
|
-
if (type ===
|
|
93
|
+
if (type === CHART_TYPE.SCATTER) {
|
|
102
94
|
const {
|
|
103
95
|
column_groupby_column_key
|
|
104
96
|
} = config;
|
|
105
97
|
if (!column_groupby_column_key) return false;
|
|
106
98
|
}
|
|
107
|
-
if (config.type ===
|
|
99
|
+
if (config.type === CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
108
100
|
const {
|
|
109
101
|
summary_type
|
|
110
102
|
} = config;
|
|
111
|
-
if (summary_type ===
|
|
103
|
+
if (summary_type === CHART_Y_GROUP_TYPE.COUNT || !summary_type) return true;
|
|
112
104
|
const numericColumnKey = config.numeric_column_key;
|
|
113
105
|
if (!numericColumnKey) return false;
|
|
114
|
-
return
|
|
106
|
+
return getTableColumnByKey(table, numericColumnKey);
|
|
115
107
|
}
|
|
116
|
-
if (config.type ===
|
|
108
|
+
if (config.type === CHART_TYPE.DASHBOARD) {
|
|
117
109
|
const targetColumnKey = config.target_value_column_key;
|
|
118
110
|
if (!targetColumnKey) return false;
|
|
119
111
|
const totalColumnKey = config.total_value_column_key;
|
|
120
112
|
if (!totalColumnKey) return false;
|
|
121
|
-
if (!
|
|
122
|
-
return
|
|
113
|
+
if (!getTableColumnByKey(table, targetColumnKey)) return false;
|
|
114
|
+
return getTableColumnByKey(table, totalColumnKey);
|
|
123
115
|
}
|
|
124
116
|
|
|
125
117
|
// completeness chart requires groupby_column_key, completed_column_key, and target_column_key
|
|
126
|
-
if (config.type ===
|
|
118
|
+
if (config.type === CHART_TYPE.COMPLETENESS || config.type === CHART_TYPE.COMPLETENESS_GROUP) {
|
|
127
119
|
const {
|
|
128
120
|
groupby_column_key,
|
|
129
121
|
completed_column_key,
|
|
@@ -132,52 +124,52 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
132
124
|
if (!groupby_column_key) return false;
|
|
133
125
|
if (!completed_column_key) return false;
|
|
134
126
|
if (!target_column_key) return false;
|
|
135
|
-
if (!
|
|
136
|
-
if (!
|
|
137
|
-
if (!
|
|
127
|
+
if (!getTableColumnByKey(table, groupby_column_key)) return false;
|
|
128
|
+
if (!getTableColumnByKey(table, completed_column_key)) return false;
|
|
129
|
+
if (!getTableColumnByKey(table, target_column_key)) return false;
|
|
138
130
|
return true;
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
// if current chart is using "groupby_column_key" as key
|
|
142
134
|
// if groupby_column_key is null, still return false
|
|
143
135
|
let groupByColumnKey = config.groupby_column_key || config.x_axis_column_key || config.vertical_axis_column_key || config.columnKey || config.date_column_key;
|
|
144
|
-
if ([
|
|
136
|
+
if ([CHART_TYPE.BAR, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.COMBINATION].includes(config.type)) {
|
|
145
137
|
groupByColumnKey = config.x_axis_column_key;
|
|
146
138
|
}
|
|
147
|
-
if ([
|
|
139
|
+
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(config.type)) {
|
|
148
140
|
groupByColumnKey = config.vertical_axis_column_key;
|
|
149
141
|
}
|
|
150
|
-
if ([
|
|
142
|
+
if ([CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(config.type)) {
|
|
151
143
|
groupByColumnKey = config.geo_column_key;
|
|
152
144
|
}
|
|
153
|
-
if ([
|
|
145
|
+
if ([CHART_TYPE.HEAT_MAP].includes(config.type)) {
|
|
154
146
|
groupByColumnKey = config.time_column_key;
|
|
155
147
|
}
|
|
156
|
-
if ([
|
|
148
|
+
if ([CHART_TYPE.MIRROR].includes(config.type)) {
|
|
157
149
|
groupByColumnKey = config.column_key;
|
|
158
150
|
}
|
|
159
|
-
if ([
|
|
151
|
+
if ([CHART_TYPE.TREND].includes(config.type)) {
|
|
160
152
|
groupByColumnKey = config.date_column_key;
|
|
161
153
|
}
|
|
162
154
|
if (!groupByColumnKey) return false;
|
|
163
|
-
if (!
|
|
164
|
-
if (type ===
|
|
165
|
-
const column =
|
|
166
|
-
if (!column || column.type !==
|
|
155
|
+
if (!getTableColumnByKey(table, groupByColumnKey)) return false;
|
|
156
|
+
if (type === CHART_TYPE.FUNNEL) {
|
|
157
|
+
const column = getColumnByKey(config.x_axis_column_key, table.columns);
|
|
158
|
+
if (!column || column.type !== CellType.SINGLE_SELECT) return false;
|
|
167
159
|
}
|
|
168
|
-
if (type ===
|
|
160
|
+
if (type === CHART_TYPE.COMBINATION) {
|
|
169
161
|
const isExist = _BaseUtils.isValidCombinationChart(config, table);
|
|
170
162
|
if (!isExist) return false;
|
|
171
163
|
} else {
|
|
172
164
|
let summaryColumnKey = config.summary_column_key || config.y_axis_summary_column_key || config.horizontal_axis_column_key;
|
|
173
|
-
if ([
|
|
165
|
+
if ([CHART_TYPE.TABLE].includes(config.type) && config.column_groupby_multiple_numeric_column && (config === null || config === void 0 ? void 0 : config.summary_columns.length) > 0) {
|
|
174
166
|
// "key" and "column_key" are both exists currently, "column_key" is defined in public component, to avoid bugs, better not to change "column_key" to "key"
|
|
175
167
|
summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
|
|
176
168
|
}
|
|
177
169
|
const summaryType = _BaseUtils.getSummaryType(config);
|
|
178
|
-
if (summaryType ===
|
|
170
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
179
171
|
if (summaryColumnKey) {
|
|
180
|
-
return
|
|
172
|
+
return getTableColumnByKey(table, summaryColumnKey);
|
|
181
173
|
}
|
|
182
174
|
}
|
|
183
175
|
return true;
|
|
@@ -190,34 +182,34 @@ BaseUtils.getGroupColumn = (table, chart) => {
|
|
|
190
182
|
const {
|
|
191
183
|
type
|
|
192
184
|
} = config;
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
185
|
+
if (COMPLTETELESS_CHART_TYPES.includes(type)) {
|
|
186
|
+
return getTableColumnByKey(table, config.completed_column_key);
|
|
195
187
|
}
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
188
|
+
if (HORIZONTAL_BAR_CHART_TYPES.includes(type)) {
|
|
189
|
+
return getTableColumnByKey(table, config.vertical_axis_column_key);
|
|
198
190
|
}
|
|
199
|
-
if (
|
|
200
|
-
return
|
|
191
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
192
|
+
return getTableColumnByKey(table, config.groupby_column_key);
|
|
201
193
|
}
|
|
202
|
-
if (type ===
|
|
203
|
-
return
|
|
194
|
+
if (type === CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
195
|
+
return getTableColumnByKey(table, config.numeric_column_key);
|
|
204
196
|
}
|
|
205
|
-
if ([
|
|
206
|
-
return
|
|
197
|
+
if ([CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
198
|
+
return getTableColumnByKey(table, config.geo_column_key);
|
|
207
199
|
}
|
|
208
|
-
if (type ===
|
|
209
|
-
return
|
|
200
|
+
if (type === CHART_TYPE.MIRROR) {
|
|
201
|
+
return getTableColumnByKey(table, config.column_key);
|
|
210
202
|
}
|
|
211
|
-
if (type ===
|
|
212
|
-
return
|
|
203
|
+
if (type === CHART_TYPE.TREND) {
|
|
204
|
+
return getTableColumnByKey(table, config.date_column_key);
|
|
213
205
|
}
|
|
214
|
-
if (type ===
|
|
215
|
-
return
|
|
206
|
+
if (type === CHART_TYPE.HEAT_MAP) {
|
|
207
|
+
return getTableColumnByKey(table, config.time_column_key);
|
|
216
208
|
}
|
|
217
|
-
if (
|
|
218
|
-
return
|
|
209
|
+
if (MAP_CHART_TYPES.includes(type)) {
|
|
210
|
+
return getTableColumnByKey(table, config.geo_column_key);
|
|
219
211
|
}
|
|
220
|
-
return
|
|
212
|
+
return getTableColumnByKey(table, config.x_axis_column_key);
|
|
221
213
|
};
|
|
222
214
|
BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
223
215
|
const {
|
|
@@ -226,19 +218,19 @@ BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
|
226
218
|
const {
|
|
227
219
|
type
|
|
228
220
|
} = config;
|
|
229
|
-
if (
|
|
230
|
-
return
|
|
221
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
222
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
231
223
|
}
|
|
232
|
-
if ([
|
|
233
|
-
return
|
|
224
|
+
if ([CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.LINE_GROUP, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.AREA_GROUP, CHART_TYPE.COMPLETENESS, CHART_TYPE.COMPLETENESS_GROUP].includes(type)) {
|
|
225
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
234
226
|
}
|
|
235
|
-
if ([
|
|
236
|
-
return
|
|
227
|
+
if ([CHART_TYPE.MIRROR].includes(type)) {
|
|
228
|
+
return getTableColumnByKey(table, config.group_column_key);
|
|
237
229
|
}
|
|
238
|
-
if (type ===
|
|
239
|
-
return
|
|
230
|
+
if (type === CHART_TYPE.SCATTER) {
|
|
231
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
240
232
|
}
|
|
241
|
-
return
|
|
233
|
+
return getTableColumnByKey(table, config.y_axis_summary_column_key);
|
|
242
234
|
};
|
|
243
235
|
BaseUtils.getSummaryColumn = (table, chart) => {
|
|
244
236
|
const {
|
|
@@ -252,39 +244,39 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
252
244
|
horizontal_axis_column_key
|
|
253
245
|
} = config;
|
|
254
246
|
switch (type) {
|
|
255
|
-
case
|
|
256
|
-
case
|
|
247
|
+
case CHART_TYPE.COMPLETENESS:
|
|
248
|
+
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
257
249
|
{
|
|
258
|
-
return
|
|
250
|
+
return getTableColumnByKey(table, config.target_column_key);
|
|
259
251
|
}
|
|
260
|
-
case
|
|
261
|
-
case
|
|
262
|
-
case
|
|
252
|
+
case CHART_TYPE.HORIZONTAL_BAR:
|
|
253
|
+
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
254
|
+
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
263
255
|
{
|
|
264
|
-
return
|
|
256
|
+
return getTableColumnByKey(table, horizontal_axis_column_key);
|
|
265
257
|
}
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
case
|
|
269
|
-
case
|
|
270
|
-
case
|
|
271
|
-
case
|
|
272
|
-
case
|
|
258
|
+
case CHART_TYPE.BAR:
|
|
259
|
+
case CHART_TYPE.BAR_GROUP:
|
|
260
|
+
case CHART_TYPE.LINE:
|
|
261
|
+
case CHART_TYPE.LINE_GROUP:
|
|
262
|
+
case CHART_TYPE.AREA:
|
|
263
|
+
case CHART_TYPE.AREA_GROUP:
|
|
264
|
+
case CHART_TYPE.BAR_STACK:
|
|
273
265
|
{
|
|
274
|
-
return
|
|
266
|
+
return getTableColumnByKey(table, y_axis_summary_column_key);
|
|
275
267
|
}
|
|
276
|
-
case
|
|
268
|
+
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
277
269
|
{
|
|
278
|
-
return
|
|
270
|
+
return getTableColumnByKey(table, numeric_column_key);
|
|
279
271
|
}
|
|
280
|
-
case
|
|
272
|
+
case CHART_TYPE.SCATTER:
|
|
281
273
|
{
|
|
282
|
-
return
|
|
274
|
+
return getTableColumnByKey(table, config.y_axis_column_key);
|
|
283
275
|
}
|
|
284
|
-
case
|
|
276
|
+
case CHART_TYPE.COMBINATION:
|
|
285
277
|
{
|
|
286
|
-
const summaryColumnLeft =
|
|
287
|
-
const summaryColumnRight =
|
|
278
|
+
const summaryColumnLeft = getTableColumnByKey(table, config.y_axis_left_summary_column);
|
|
279
|
+
const summaryColumnRight = getTableColumnByKey(table, config.y_axis_right_summary_column);
|
|
288
280
|
return {
|
|
289
281
|
summaryColumnLeft,
|
|
290
282
|
summaryColumnRight
|
|
@@ -292,7 +284,7 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
292
284
|
}
|
|
293
285
|
default:
|
|
294
286
|
{
|
|
295
|
-
return
|
|
287
|
+
return getTableColumnByKey(table, summary_column_key);
|
|
296
288
|
}
|
|
297
289
|
}
|
|
298
290
|
};
|
|
@@ -318,7 +310,7 @@ BaseUtils.getSummaryColumnsWithMethod = (table, chart) => {
|
|
|
318
310
|
summary_method
|
|
319
311
|
} = summaryItem;
|
|
320
312
|
return {
|
|
321
|
-
column:
|
|
313
|
+
column: getTableColumnByKey(table, columnKey),
|
|
322
314
|
summary_method
|
|
323
315
|
};
|
|
324
316
|
});
|
|
@@ -327,7 +319,7 @@ BaseUtils.getGroupName = (tables, chart) => {
|
|
|
327
319
|
const {
|
|
328
320
|
config
|
|
329
321
|
} = chart;
|
|
330
|
-
const table =
|
|
322
|
+
const table = getTableById(tables, config.table_id);
|
|
331
323
|
const column = _BaseUtils.getGroupColumn(table, chart);
|
|
332
324
|
return column.name;
|
|
333
325
|
};
|
|
@@ -374,24 +366,24 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
|
|
|
374
366
|
};
|
|
375
367
|
|
|
376
368
|
// The date returned by db carries T and Z, so that there is a time difference in data formatting
|
|
377
|
-
return
|
|
369
|
+
return getDateDisplayString(summaryValue.replace(/[T|Z]/g, ' '), format);
|
|
378
370
|
}
|
|
379
|
-
if (typeof summaryValue !== 'number') return
|
|
380
|
-
return
|
|
371
|
+
if (typeof summaryValue !== 'number') return formatRowTotal(summaryValue);
|
|
372
|
+
return getNumberDisplayString(summaryValue, data || DEFAULT_NUMBER_FORMAT_OBJECT);
|
|
381
373
|
};
|
|
382
374
|
BaseUtils.isNumericSummaryColumn = summaryColumn => {
|
|
383
375
|
if (!summaryColumn) return false;
|
|
384
376
|
const {
|
|
385
377
|
type
|
|
386
378
|
} = summaryColumn;
|
|
387
|
-
return type !==
|
|
379
|
+
return type !== CellType.LINK && isNumericColumn(summaryColumn);
|
|
388
380
|
};
|
|
389
381
|
BaseUtils.isDateSummaryColumn = summaryColumn => {
|
|
390
382
|
if (!summaryColumn) return false;
|
|
391
383
|
const {
|
|
392
384
|
type
|
|
393
385
|
} = summaryColumn;
|
|
394
|
-
return type !==
|
|
386
|
+
return type !== CellType.LINK && isDateColumn(summaryColumn);
|
|
395
387
|
};
|
|
396
388
|
BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) => {
|
|
397
389
|
let {
|
|
@@ -401,14 +393,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) =
|
|
|
401
393
|
if (_BaseUtils.isDateSummaryColumn(summaryColumn)) {
|
|
402
394
|
if (summaryMethod === 'MAX') {
|
|
403
395
|
if (currentValue && nextValue) {
|
|
404
|
-
return (
|
|
396
|
+
return dayjs(currentValue).isBefore(nextValue) ? nextValue : currentValue;
|
|
405
397
|
}
|
|
406
398
|
if (!currentValue && nextValue) return nextValue;
|
|
407
399
|
return currentValue;
|
|
408
400
|
}
|
|
409
401
|
if (summaryMethod === 'MIN') {
|
|
410
402
|
if (currentValue && nextValue) {
|
|
411
|
-
return (
|
|
403
|
+
return dayjs(currentValue).isBefore(nextValue) ? currentValue : nextValue;
|
|
412
404
|
}
|
|
413
405
|
if (!currentValue && nextValue) return nextValue;
|
|
414
406
|
return currentValue;
|
|
@@ -434,7 +426,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
434
426
|
let {
|
|
435
427
|
columns
|
|
436
428
|
} = table;
|
|
437
|
-
let unStatisticalColumns = [
|
|
429
|
+
let unStatisticalColumns = [CellType.LONG_TEXT, CellType.IMAGE, CellType.FILE, CellType.CHECKBOX];
|
|
438
430
|
return columns.filter(column => {
|
|
439
431
|
return unStatisticalColumns.indexOf(column.type) === -1;
|
|
440
432
|
});
|
|
@@ -442,7 +434,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
442
434
|
BaseUtils.isChartEqual = (preChartElement, curChartElement) => {
|
|
443
435
|
const elementType = preChartElement.config.type;
|
|
444
436
|
if (elementType !== curChartElement.config.type) return false;
|
|
445
|
-
return (
|
|
437
|
+
return shallowEqual(preChartElement.config, curChartElement.config);
|
|
446
438
|
};
|
|
447
439
|
BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
448
440
|
var _preChartElement$heig, _curChartElement$heig;
|
|
@@ -454,10 +446,10 @@ BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
|
454
446
|
if ((preChartElement === null || preChartElement === void 0 ? void 0 : preChartElement.width_in_unit) !== (curChartElement === null || curChartElement === void 0 ? void 0 : curChartElement.width_in_unit)) return true;
|
|
455
447
|
const hasStyleConfig = preChartElement.style_config && curChartElement.style_config;
|
|
456
448
|
if (hasStyleConfig) {
|
|
457
|
-
const chartStyleConfigChanged =
|
|
449
|
+
const chartStyleConfigChanged = CHART_STYLE_CONFIG_SETTING_KEYS.some(key => preChartElement.style_config[key] !== curChartElement.style_config[key]);
|
|
458
450
|
return chartStyleConfigChanged;
|
|
459
451
|
}
|
|
460
|
-
return !
|
|
452
|
+
return !CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
461
453
|
};
|
|
462
454
|
BaseUtils.isChartTypeChange = (preChartElement, curChartElement) => {
|
|
463
455
|
const elementType = preChartElement.config.type;
|
|
@@ -475,9 +467,9 @@ BaseUtils.isArchiveView = (chart, tables) => {
|
|
|
475
467
|
table_id,
|
|
476
468
|
view_id
|
|
477
469
|
} = chart;
|
|
478
|
-
const table =
|
|
479
|
-
const view =
|
|
480
|
-
return view &&
|
|
470
|
+
const table = getTableById(tables, table_id);
|
|
471
|
+
const view = getViewById(table === null || table === void 0 ? void 0 : table.views, view_id);
|
|
472
|
+
return view && isArchiveView(view);
|
|
481
473
|
};
|
|
482
474
|
BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
483
475
|
return preChartElement.config.sort_type !== curChartElement.config.sort_type;
|
|
@@ -485,7 +477,7 @@ BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
|
485
477
|
BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
486
478
|
const prevStyleConfig = prevElement && prevElement.style_config;
|
|
487
479
|
const currStyleConfig = currElement && currElement.style_config;
|
|
488
|
-
if ((prevStyleConfig === null || prevStyleConfig === void 0 ? void 0 : prevStyleConfig.display_goal_line) !== (currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.display_goal_line) && (!(currStyleConfig
|
|
480
|
+
if ((prevStyleConfig === null || prevStyleConfig === void 0 ? void 0 : prevStyleConfig.display_goal_line) !== (currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.display_goal_line) && (!(currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.goal_lable) || !(currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.goal_value))) {
|
|
489
481
|
return false;
|
|
490
482
|
}
|
|
491
483
|
if (!prevStyleConfig && !currStyleConfig) {
|
|
@@ -502,24 +494,24 @@ BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
|
502
494
|
border: currBorder,
|
|
503
495
|
title: currTitle
|
|
504
496
|
} = currStyleConfig;
|
|
505
|
-
return !(
|
|
497
|
+
return !shallowEqual(prevBorder, currBorder) || !shallowEqual(prevTitle, currTitle);
|
|
506
498
|
};
|
|
507
499
|
BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
508
500
|
return !_BaseUtils.isChartEqual(prevProps.chart, currentProps.chart) ||
|
|
509
501
|
// chart attributes changed
|
|
510
|
-
!(
|
|
502
|
+
!shallowEqual(prevProps.canvasStyle, currentProps.canvasStyle) ||
|
|
511
503
|
// canvasStyle
|
|
512
|
-
!(
|
|
504
|
+
!shallowEqual(prevProps.groupbyColumn, currentProps.groupbyColumn) ||
|
|
513
505
|
// groupbyColumn's data、type changed or not exist
|
|
514
|
-
!(
|
|
506
|
+
!shallowEqual(prevProps.columnGroupbyColumn, currentProps.columnGroupbyColumn) ||
|
|
515
507
|
// columnGroupbyColumn's data、type changed or not exist
|
|
516
|
-
!(
|
|
508
|
+
!shallowEqual(prevProps.summaryColumn, currentProps.summaryColumn) ||
|
|
517
509
|
// summaryColumn's data、type changed or not exist
|
|
518
|
-
!(
|
|
510
|
+
!shallowEqual(prevProps.globalTheme, currentProps.globalTheme) ||
|
|
519
511
|
// global theme changed
|
|
520
|
-
!(
|
|
512
|
+
!shallowEqual(prevProps.chartColorTheme, currentProps.chartColorTheme) ||
|
|
521
513
|
// chart color theme changed
|
|
522
|
-
!(
|
|
514
|
+
!shallowEqual(prevProps.resizeSignal, currentProps.resizeSignal) ||
|
|
523
515
|
// chart container resize changed
|
|
524
516
|
_BaseUtils._isChartDataChange(prevProps, currentProps) || _BaseUtils.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
525
517
|
};
|
|
@@ -536,7 +528,7 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
536
528
|
const {
|
|
537
529
|
result: oldData
|
|
538
530
|
} = currentProps;
|
|
539
|
-
if (chart.config.type ===
|
|
531
|
+
if (chart.config.type === CHART_TYPE.COMBINATION) {
|
|
540
532
|
return _BaseUtils._isCombinationDataChange(newData, oldData);
|
|
541
533
|
}
|
|
542
534
|
if (!newData && !oldData) return false;
|
|
@@ -555,14 +547,14 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
555
547
|
for (let j = 0; j < (newDataItemRows === null || newDataItemRows === void 0 ? void 0 : newDataItemRows.length) || 0; j++) {
|
|
556
548
|
let newDataItemRow = newDataItemRows[j];
|
|
557
549
|
let oldDataItemRow = oldDataItemRows[j];
|
|
558
|
-
if (!(
|
|
550
|
+
if (!shallowEqual(newDataItemRow, oldDataItemRow)) return true;
|
|
559
551
|
}
|
|
560
552
|
}
|
|
561
553
|
return false;
|
|
562
554
|
};
|
|
563
555
|
BaseUtils.getColumn = (tables, tableId, columnKey) => {
|
|
564
|
-
const table =
|
|
565
|
-
return
|
|
556
|
+
const table = getTableById(tables, tableId);
|
|
557
|
+
return getTableColumnByKey(table, columnKey);
|
|
566
558
|
};
|
|
567
559
|
BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) => {
|
|
568
560
|
if (!Array.isArray(dataList)) return [];
|
|
@@ -577,7 +569,7 @@ BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) =>
|
|
|
577
569
|
item.group_name = emptyName;
|
|
578
570
|
}
|
|
579
571
|
if (!item.slugId) {
|
|
580
|
-
item.slugId =
|
|
572
|
+
item.slugId = slugid.nice();
|
|
581
573
|
}
|
|
582
574
|
if (!item.value) {
|
|
583
575
|
item.value = 0;
|
|
@@ -603,10 +595,10 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
603
595
|
const {
|
|
604
596
|
type: columnType
|
|
605
597
|
} = column || {};
|
|
606
|
-
const pieChartColorsLength =
|
|
598
|
+
const pieChartColorsLength = PIE_CHART_COLORS.length - 1;
|
|
607
599
|
const backgroundColor = [];
|
|
608
600
|
result.forEach((item, index) => {
|
|
609
|
-
if (columnType ===
|
|
601
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
610
602
|
let {
|
|
611
603
|
color
|
|
612
604
|
} = item;
|
|
@@ -615,7 +607,7 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
615
607
|
if (index > pieChartColorsLength) {
|
|
616
608
|
index = index % pieChartColorsLength;
|
|
617
609
|
}
|
|
618
|
-
backgroundColor.push(
|
|
610
|
+
backgroundColor.push(PIE_CHART_COLORS[index]);
|
|
619
611
|
}
|
|
620
612
|
});
|
|
621
613
|
return backgroundColor;
|
|
@@ -654,8 +646,8 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
654
646
|
groupby_column_key,
|
|
655
647
|
minimum_slice_percent
|
|
656
648
|
} = chart.config;
|
|
657
|
-
const table =
|
|
658
|
-
const column =
|
|
649
|
+
const table = getTableById(tables, table_id);
|
|
650
|
+
const column = getColumnByKey(groupby_column_key, table ? table.columns : []);
|
|
659
651
|
let sum = data.reduce((total, currentValue) => {
|
|
660
652
|
return total += currentValue.value;
|
|
661
653
|
}, 0);
|
|
@@ -708,9 +700,9 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
708
700
|
data: columnData
|
|
709
701
|
} = column;
|
|
710
702
|
let name = result[nameKey];
|
|
711
|
-
if (columnType ===
|
|
712
|
-
const options =
|
|
713
|
-
let selectedOption =
|
|
703
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
704
|
+
const options = getColumnOptions(column);
|
|
705
|
+
let selectedOption = getOption(options, name);
|
|
714
706
|
let {
|
|
715
707
|
name: optionName,
|
|
716
708
|
color: optionColor,
|
|
@@ -723,66 +715,66 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
723
715
|
} else {
|
|
724
716
|
result[colorKey] = '#dbdbdb';
|
|
725
717
|
}
|
|
726
|
-
} else if (columnType ===
|
|
727
|
-
const users =
|
|
718
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
719
|
+
const users = context.getCollaboratorsFromCache();
|
|
728
720
|
const user = users.find(user => user.email === name);
|
|
729
721
|
if (user) {
|
|
730
722
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
731
723
|
isNameField && (result.original_name = name);
|
|
732
724
|
resolve();
|
|
733
725
|
} else {
|
|
734
|
-
|
|
726
|
+
context.queryUsers([name], users => {
|
|
735
727
|
const userEmail = name;
|
|
736
|
-
const user = users[userEmail] ||
|
|
728
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
737
729
|
const userName = user.name || userEmail;
|
|
738
730
|
result[nameKey] = userName;
|
|
739
731
|
isNameField && (result.original_name = userEmail);
|
|
740
732
|
user.loaded = true;
|
|
741
|
-
|
|
733
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
742
734
|
resolve();
|
|
743
735
|
});
|
|
744
736
|
}
|
|
745
737
|
return;
|
|
746
|
-
} else if (columnType ===
|
|
747
|
-
const users =
|
|
738
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
739
|
+
const users = context.getCollaboratorsFromCache();
|
|
748
740
|
const user = users.find(user => user.email === name);
|
|
749
741
|
if (user) {
|
|
750
742
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
751
743
|
isNameField && (result.original_name = name);
|
|
752
744
|
resolve();
|
|
753
745
|
} else {
|
|
754
|
-
|
|
746
|
+
context.queryUsers([name], users => {
|
|
755
747
|
const userEmail = name;
|
|
756
|
-
const user = users[userEmail] ||
|
|
748
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
757
749
|
const userName = user.name || userEmail;
|
|
758
750
|
result[nameKey] = userName;
|
|
759
751
|
isNameField && (result.original_name = userEmail);
|
|
760
752
|
user.loaded = true;
|
|
761
|
-
|
|
753
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
762
754
|
resolve();
|
|
763
755
|
});
|
|
764
756
|
}
|
|
765
757
|
return;
|
|
766
|
-
} else if (columnType ===
|
|
758
|
+
} else if (columnType === CellType.NUMBER) {
|
|
767
759
|
let valueNumber = parseFloat(name);
|
|
768
|
-
result[nameKey] =
|
|
760
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
769
761
|
isNameField && (result.original_name = name);
|
|
770
|
-
} else if (columnType ===
|
|
762
|
+
} else if (columnType === CellType.DATE) {
|
|
771
763
|
name = name + '';
|
|
772
764
|
if (name && name.split('-').length === 3) {
|
|
773
|
-
let format =
|
|
765
|
+
let format = getDateColumnFormat(column);
|
|
774
766
|
let spaceIndex = format.indexOf(' ');
|
|
775
767
|
if (spaceIndex > -1) {
|
|
776
768
|
format = format.slice(0, spaceIndex);
|
|
777
769
|
}
|
|
778
|
-
result[nameKey] = (
|
|
770
|
+
result[nameKey] = dayjs(name).format(format);
|
|
779
771
|
}
|
|
780
|
-
} else if (columnType ===
|
|
772
|
+
} else if (columnType === CellType.LINK_FORMULA) {
|
|
781
773
|
// scatter only use number
|
|
782
774
|
if (isScatterChart) {
|
|
783
775
|
name.length && (name = name[0]);
|
|
784
776
|
let valueNumber = parseFloat(name);
|
|
785
|
-
result[nameKey] =
|
|
777
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
786
778
|
}
|
|
787
779
|
const {
|
|
788
780
|
array_data,
|
|
@@ -795,18 +787,18 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
795
787
|
};
|
|
796
788
|
// for linked formula, need to call recursively, using it's result as the result of the promise
|
|
797
789
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
|
|
798
|
-
} else if (columnType ===
|
|
790
|
+
} else if (columnType === CellType.FORMULA) {
|
|
799
791
|
const {
|
|
800
792
|
result_type: resultType,
|
|
801
793
|
array_type: arrayType,
|
|
802
794
|
array_data: arrayData
|
|
803
795
|
} = columnData || {};
|
|
804
|
-
if (resultType ===
|
|
796
|
+
if (resultType === FORMULA_RESULT_TYPE.NUMBER) {
|
|
805
797
|
const valueNumber = parseFloat(name);
|
|
806
|
-
result[nameKey] =
|
|
798
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
807
799
|
isNameField && (result.original_name = name);
|
|
808
|
-
} else if (resultType ===
|
|
809
|
-
result[nameKey] =
|
|
800
|
+
} else if (resultType === FORMULA_RESULT_TYPE.DATE || resultType === CellType.CTIME || resultType === CellType.MTIME) {
|
|
801
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
810
802
|
isNameField && (result.original_name = name);
|
|
811
803
|
} else if (arrayType && arrayData) {
|
|
812
804
|
const formulaArrayColumn = {
|
|
@@ -817,19 +809,19 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
817
809
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, formulaArrayColumn, nameKey, colorKey, isScatterChart, isNameField);
|
|
818
810
|
} else if (Array.isArray(name)) {
|
|
819
811
|
result[nameKey] = name.map(item => {
|
|
820
|
-
if (
|
|
821
|
-
const collaborator =
|
|
812
|
+
if (isValidCollaboratorEmail(item)) {
|
|
813
|
+
const collaborator = getKnownCollaboratorByEmail(item);
|
|
822
814
|
return collaborator ? collaborator.name : item;
|
|
823
815
|
}
|
|
824
816
|
return item;
|
|
825
817
|
}).join(', ');
|
|
826
818
|
isNameField && (result.original_name = name.join(', '));
|
|
827
|
-
} else if (typeof name === 'string' &&
|
|
828
|
-
const collaborator =
|
|
819
|
+
} else if (typeof name === 'string' && isValidCollaboratorEmail(name)) {
|
|
820
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
829
821
|
result[nameKey] = collaborator ? collaborator.name : name;
|
|
830
822
|
isNameField && (result.original_name = name);
|
|
831
823
|
} else {
|
|
832
|
-
result[nameKey] =
|
|
824
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
833
825
|
isNameField && (result.original_name = name);
|
|
834
826
|
}
|
|
835
827
|
}
|
|
@@ -856,8 +848,8 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
856
848
|
} = column;
|
|
857
849
|
const sortType = 'up';
|
|
858
850
|
const optionIdIndexMap = {};
|
|
859
|
-
const isPivotMultipleSelect = columnType ===
|
|
860
|
-
if ([
|
|
851
|
+
const isPivotMultipleSelect = columnType === CellType.MULTIPLE_SELECT && isPivot;
|
|
852
|
+
if ([CellType.SINGLE_SELECT].includes(columnType) || isPivotMultipleSelect) {
|
|
861
853
|
const {
|
|
862
854
|
options
|
|
863
855
|
} = data || {};
|
|
@@ -865,7 +857,7 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
865
857
|
optionIdIndexMap[option.id] = index;
|
|
866
858
|
});
|
|
867
859
|
}
|
|
868
|
-
const isPivotLinkFormulaSingleAndMultipleSelect = columnType ===
|
|
860
|
+
const isPivotLinkFormulaSingleAndMultipleSelect = columnType === CellType.LINK_FORMULA && [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT].includes(column.data.array_type) && isPivot;
|
|
869
861
|
if (isPivotLinkFormulaSingleAndMultipleSelect) {
|
|
870
862
|
var _column$data;
|
|
871
863
|
let {
|
|
@@ -889,14 +881,14 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
889
881
|
if (!next && next !== 0) {
|
|
890
882
|
return 1;
|
|
891
883
|
}
|
|
892
|
-
if (
|
|
884
|
+
if (CHART_SUPPORT_SORT_COLUMNS.includes(columnType)) {
|
|
893
885
|
let realColumnType = columnType;
|
|
894
|
-
if ([
|
|
886
|
+
if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
|
|
895
887
|
realColumnType = column.data.array_type;
|
|
896
888
|
}
|
|
897
889
|
switch (realColumnType) {
|
|
898
|
-
case
|
|
899
|
-
case
|
|
890
|
+
case CellType.NUMBER:
|
|
891
|
+
case CellType.RATE:
|
|
900
892
|
{
|
|
901
893
|
if (current) {
|
|
902
894
|
current = current - 0;
|
|
@@ -904,15 +896,15 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
904
896
|
if (next) {
|
|
905
897
|
next = next - 0;
|
|
906
898
|
}
|
|
907
|
-
return
|
|
899
|
+
return sortNumber(current, next, sortType);
|
|
908
900
|
}
|
|
909
|
-
case
|
|
910
|
-
case
|
|
911
|
-
case
|
|
901
|
+
case CellType.DATE:
|
|
902
|
+
case CellType.CTIME:
|
|
903
|
+
case CellType.MTIME:
|
|
912
904
|
{
|
|
913
|
-
return
|
|
905
|
+
return sortDate(current, next, sortType);
|
|
914
906
|
}
|
|
915
|
-
case
|
|
907
|
+
case CellType.SINGLE_SELECT:
|
|
916
908
|
{
|
|
917
909
|
// key was used to sort "pivot columns" in pivot chart
|
|
918
910
|
const {
|
|
@@ -925,29 +917,29 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
925
917
|
} = nextResult || {};
|
|
926
918
|
const current = currentName || currentKey;
|
|
927
919
|
const next = nextName || nextKey;
|
|
928
|
-
return
|
|
920
|
+
return sortSingleSelect(current, next, {
|
|
929
921
|
sort_type: sortType,
|
|
930
922
|
option_id_index_map: optionIdIndexMap
|
|
931
923
|
});
|
|
932
924
|
}
|
|
933
|
-
case
|
|
925
|
+
case CellType.MULTIPLE_SELECT:
|
|
934
926
|
{
|
|
935
|
-
return
|
|
927
|
+
return sortSingleSelect(current, next, {
|
|
936
928
|
sort_type: sortType,
|
|
937
929
|
option_id_index_map: optionIdIndexMap
|
|
938
930
|
});
|
|
939
931
|
}
|
|
940
|
-
case
|
|
941
|
-
case
|
|
932
|
+
case CellType.FORMULA:
|
|
933
|
+
case CellType.LINK_FORMULA:
|
|
942
934
|
{
|
|
943
|
-
return
|
|
935
|
+
return sortFormula(current, next, sortType, {
|
|
944
936
|
columnData: data,
|
|
945
937
|
value: {}
|
|
946
938
|
});
|
|
947
939
|
}
|
|
948
940
|
default:
|
|
949
941
|
{
|
|
950
|
-
return
|
|
942
|
+
return sortText(current, next, sortType);
|
|
951
943
|
}
|
|
952
944
|
}
|
|
953
945
|
}
|
|
@@ -987,7 +979,7 @@ BaseUtils.sortDataByKey = (data, key, sortType) => {
|
|
|
987
979
|
if (!nextVal && nextVal !== 0) {
|
|
988
980
|
return 1;
|
|
989
981
|
}
|
|
990
|
-
if (sortType ===
|
|
982
|
+
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
991
983
|
return currentVal > nextVal ? 1 : -1;
|
|
992
984
|
} else {
|
|
993
985
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -1013,7 +1005,7 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1013
1005
|
type,
|
|
1014
1006
|
config
|
|
1015
1007
|
} = chart;
|
|
1016
|
-
if (
|
|
1008
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
1017
1009
|
groupby_column_key = config.groupby_column_key;
|
|
1018
1010
|
} else {
|
|
1019
1011
|
groupby_column_key = config.x_axis_column_key;
|
|
@@ -1022,9 +1014,9 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1022
1014
|
const {
|
|
1023
1015
|
table_id
|
|
1024
1016
|
} = config;
|
|
1025
|
-
const table =
|
|
1026
|
-
const groupbyColumn =
|
|
1027
|
-
const columnGroupbyColumn =
|
|
1017
|
+
const table = getTableById(tables, table_id);
|
|
1018
|
+
const groupbyColumn = getTableColumnByKey(table, groupby_column_key);
|
|
1019
|
+
const columnGroupbyColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
1028
1020
|
results.forEach(item => {
|
|
1029
1021
|
const {
|
|
1030
1022
|
name,
|
|
@@ -1043,84 +1035,84 @@ BaseUtils.convertResultName = (result, column, name, nameKey, colorKey) => {
|
|
|
1043
1035
|
type: columnType,
|
|
1044
1036
|
data: columnData
|
|
1045
1037
|
} = column;
|
|
1046
|
-
if (columnType ===
|
|
1047
|
-
const options =
|
|
1048
|
-
const selectedOption =
|
|
1038
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
1039
|
+
const options = getColumnOptions(column);
|
|
1040
|
+
const selectedOption = getOption(options, name);
|
|
1049
1041
|
if (selectedOption) {
|
|
1050
1042
|
result[nameKey] = selectedOption.name;
|
|
1051
1043
|
result[colorKey] = selectedOption.color;
|
|
1052
1044
|
} else {
|
|
1053
1045
|
result[colorKey] = '#dbdbdb';
|
|
1054
1046
|
}
|
|
1055
|
-
} else if (columnType ===
|
|
1056
|
-
let collaborator =
|
|
1047
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
1048
|
+
let collaborator = getKnownCollaboratorByEmail(name);
|
|
1057
1049
|
if (collaborator) {
|
|
1058
1050
|
result[nameKey] = collaborator.name;
|
|
1059
1051
|
}
|
|
1060
|
-
} else if (columnType ===
|
|
1052
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
1061
1053
|
if (name === 'anonymous') {
|
|
1062
1054
|
result[nameKey] = name;
|
|
1063
1055
|
} else {
|
|
1064
|
-
const collaborator =
|
|
1056
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
1065
1057
|
const collaboratorTemplate = {
|
|
1066
1058
|
loaded: false,
|
|
1067
1059
|
email: name,
|
|
1068
1060
|
name: name
|
|
1069
1061
|
};
|
|
1070
|
-
|
|
1062
|
+
context.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
1071
1063
|
if (!collaborator) {
|
|
1072
|
-
|
|
1073
|
-
const collaborator = emailUserMap && emailUserMap[name] ||
|
|
1064
|
+
context.queryUsers([name], emailUserMap => {
|
|
1065
|
+
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
1074
1066
|
const loadedCollaborator = {
|
|
1075
1067
|
...collaborator,
|
|
1076
1068
|
loaded: true
|
|
1077
1069
|
};
|
|
1078
|
-
|
|
1070
|
+
context.updateCollaboratorsCache(name, loadedCollaborator);
|
|
1079
1071
|
result[nameKey] = name;
|
|
1080
1072
|
});
|
|
1081
1073
|
} else {
|
|
1082
1074
|
result[nameKey] = collaborator.name;
|
|
1083
1075
|
}
|
|
1084
1076
|
}
|
|
1085
|
-
} else if (columnType ===
|
|
1077
|
+
} else if (columnType === CellType.NUMBER) {
|
|
1086
1078
|
const valueNumber = parseFloat(name);
|
|
1087
|
-
result[nameKey] =
|
|
1088
|
-
} else if (columnType ===
|
|
1079
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1080
|
+
} else if (columnType === CellType.DATE) {
|
|
1089
1081
|
if (name && name.split('-').length === 3) {
|
|
1090
|
-
let format =
|
|
1082
|
+
let format = getDateColumnFormat(column);
|
|
1091
1083
|
const spaceIndex = format.indexOf(' ');
|
|
1092
1084
|
if (spaceIndex > -1) {
|
|
1093
1085
|
format = format.slice(0, spaceIndex);
|
|
1094
1086
|
}
|
|
1095
|
-
result[nameKey] = (
|
|
1087
|
+
result[nameKey] = dayjs(name).format(format);
|
|
1096
1088
|
}
|
|
1097
|
-
} else if (
|
|
1089
|
+
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
1098
1090
|
const {
|
|
1099
1091
|
result_type,
|
|
1100
1092
|
array_type
|
|
1101
1093
|
} = columnData || {};
|
|
1102
|
-
if (result_type ===
|
|
1094
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1103
1095
|
const valueNumber = parseFloat(name);
|
|
1104
|
-
result[nameKey] =
|
|
1105
|
-
} else if (result_type ===
|
|
1106
|
-
if (
|
|
1096
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1097
|
+
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1098
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(name)) {
|
|
1107
1099
|
result[nameKey] = name.map(email => {
|
|
1108
|
-
let user = array_type ===
|
|
1100
|
+
let user = array_type === CellType.COLLABORATOR ? getKnownCollaboratorByEmail(email) : getKnownCollaboratorByEmail(email);
|
|
1109
1101
|
return (user || {}).name;
|
|
1110
1102
|
});
|
|
1111
1103
|
}
|
|
1112
1104
|
}
|
|
1113
|
-
} else if (columnType ===
|
|
1114
|
-
result[nameKey] =
|
|
1105
|
+
} else if (columnType === CellType.LINK) {
|
|
1106
|
+
result[nameKey] = getClientFormulaDisplayString([name], columnData) || null;
|
|
1115
1107
|
}
|
|
1116
1108
|
};
|
|
1117
1109
|
// theme
|
|
1118
1110
|
BaseUtils.getCurrentTheme = themeName => {
|
|
1119
1111
|
if (themeName) {
|
|
1120
|
-
const currentColorTheme =
|
|
1112
|
+
const currentColorTheme = STYLE_COLORS.find(item => item.name === themeName);
|
|
1121
1113
|
return currentColorTheme;
|
|
1122
1114
|
}
|
|
1123
|
-
return
|
|
1115
|
+
return STYLE_COLORS[0];
|
|
1124
1116
|
};
|
|
1125
1117
|
BaseUtils.getSummaryExplanation = chart => {
|
|
1126
1118
|
const {
|
|
@@ -1130,43 +1122,43 @@ BaseUtils.getSummaryExplanation = chart => {
|
|
|
1130
1122
|
type
|
|
1131
1123
|
} = config;
|
|
1132
1124
|
switch (type) {
|
|
1133
|
-
case
|
|
1134
|
-
case
|
|
1135
|
-
case
|
|
1136
|
-
case
|
|
1125
|
+
case CHART_TYPE.PIE:
|
|
1126
|
+
case CHART_TYPE.LINE:
|
|
1127
|
+
case CHART_TYPE.LINE_GROUP:
|
|
1128
|
+
case CHART_TYPE.RING:
|
|
1137
1129
|
{
|
|
1138
1130
|
return {
|
|
1139
|
-
count:
|
|
1140
|
-
advanced:
|
|
1131
|
+
count: intl.get('Count_the_number_of_records_in_each_group'),
|
|
1132
|
+
advanced: intl.get('Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field')
|
|
1141
1133
|
};
|
|
1142
1134
|
}
|
|
1143
|
-
case
|
|
1144
|
-
case
|
|
1135
|
+
case CHART_TYPE.BAR:
|
|
1136
|
+
case CHART_TYPE.BAR_GROUP:
|
|
1145
1137
|
{
|
|
1146
1138
|
return {
|
|
1147
|
-
count:
|
|
1148
|
-
advanced:
|
|
1139
|
+
count: intl.get('Group_the_records_according_to_the_vertical_axis_and_count_the_records_in_each_group'),
|
|
1140
|
+
advanced: intl.get('Group_the_records_according_to_the_vertical_axis_and_compute_the_sum_maximum_or_minimum_of_records_in_each_group_by_a_field')
|
|
1149
1141
|
};
|
|
1150
1142
|
}
|
|
1151
1143
|
default:
|
|
1152
1144
|
{
|
|
1153
1145
|
return {
|
|
1154
|
-
count:
|
|
1155
|
-
advanced:
|
|
1146
|
+
count: intl.get('Count_the_records'),
|
|
1147
|
+
advanced: intl.get('Compute_sum_max_min')
|
|
1156
1148
|
};
|
|
1157
1149
|
}
|
|
1158
1150
|
}
|
|
1159
1151
|
};
|
|
1160
1152
|
BaseUtils.getLabelFontSize = labelFontSize => {
|
|
1161
|
-
return
|
|
1153
|
+
return isNumber(labelFontSize) ? labelFontSize : DEFAULT_LABEL_FONT_SIZE;
|
|
1162
1154
|
};
|
|
1163
1155
|
BaseUtils.imEmptyChartResult = chartResult => {
|
|
1164
1156
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1165
1157
|
};
|
|
1166
1158
|
BaseUtils.getPrecisionNumber = (value, data) => {
|
|
1167
|
-
const valueString =
|
|
1159
|
+
const valueString = getPrecisionNumber(value, data);
|
|
1168
1160
|
const valueNumber = parseFloat(valueString);
|
|
1169
|
-
return
|
|
1161
|
+
return isNumber(valueNumber) ? valueNumber : 0;
|
|
1170
1162
|
};
|
|
1171
1163
|
BaseUtils.isValidCellValue = function (cellValue) {
|
|
1172
1164
|
let includeEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1178,7 +1170,7 @@ BaseUtils.convertConfig = config => {
|
|
|
1178
1170
|
const {
|
|
1179
1171
|
type
|
|
1180
1172
|
} = config;
|
|
1181
|
-
if (type ===
|
|
1173
|
+
if (type === CHART_TYPE.HORIZONTAL_BAR || type === CHART_TYPE.HORIZONTAL_GROUP_BAR || type === CHART_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
1182
1174
|
const {
|
|
1183
1175
|
vertical_axis_column_key,
|
|
1184
1176
|
vertical_axis_date_granularity,
|
|
@@ -1217,24 +1209,24 @@ BaseUtils.convertConfig = config => {
|
|
|
1217
1209
|
};
|
|
1218
1210
|
BaseUtils.getSummaryType = config => {
|
|
1219
1211
|
switch (config.type) {
|
|
1220
|
-
case
|
|
1221
|
-
case
|
|
1222
|
-
case
|
|
1212
|
+
case CHART_TYPE.HORIZONTAL_BAR:
|
|
1213
|
+
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
1214
|
+
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1223
1215
|
{
|
|
1224
1216
|
return config.horizontal_axis_summary_type;
|
|
1225
1217
|
}
|
|
1226
|
-
case
|
|
1227
|
-
case
|
|
1228
|
-
case
|
|
1229
|
-
case
|
|
1230
|
-
case
|
|
1231
|
-
case
|
|
1232
|
-
case
|
|
1233
|
-
case
|
|
1218
|
+
case CHART_TYPE.BAR:
|
|
1219
|
+
case CHART_TYPE.BAR_GROUP:
|
|
1220
|
+
case CHART_TYPE.BAR_STACK:
|
|
1221
|
+
case CHART_TYPE.LINE:
|
|
1222
|
+
case CHART_TYPE.LINE_GROUP:
|
|
1223
|
+
case CHART_TYPE.AREA:
|
|
1224
|
+
case CHART_TYPE.AREA_GROUP:
|
|
1225
|
+
case CHART_TYPE.SCATTER:
|
|
1234
1226
|
{
|
|
1235
1227
|
return config.y_axis_summary_type;
|
|
1236
1228
|
}
|
|
1237
|
-
case
|
|
1229
|
+
case CHART_TYPE.TABLE:
|
|
1238
1230
|
default:
|
|
1239
1231
|
{
|
|
1240
1232
|
return config.summary_type;
|
|
@@ -1248,20 +1240,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1248
1240
|
data
|
|
1249
1241
|
} = column || {};
|
|
1250
1242
|
switch (type) {
|
|
1251
|
-
case
|
|
1243
|
+
case CellType.TEXT:
|
|
1252
1244
|
{
|
|
1253
1245
|
return cellValue || null;
|
|
1254
1246
|
}
|
|
1255
|
-
case
|
|
1247
|
+
case CellType.NUMBER:
|
|
1256
1248
|
{
|
|
1257
1249
|
if (!cellValue && cellValue !== 0) {
|
|
1258
1250
|
return null;
|
|
1259
1251
|
}
|
|
1260
|
-
const number =
|
|
1252
|
+
const number = getPrecisionNumber(cellValue, data);
|
|
1261
1253
|
let valueNumber = parseFloat(number);
|
|
1262
|
-
return
|
|
1254
|
+
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
1263
1255
|
}
|
|
1264
|
-
case
|
|
1256
|
+
case CellType.SINGLE_SELECT:
|
|
1265
1257
|
{
|
|
1266
1258
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
1267
1259
|
if (isInvalidValue) {
|
|
@@ -1269,20 +1261,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1269
1261
|
}
|
|
1270
1262
|
return cellValue;
|
|
1271
1263
|
}
|
|
1272
|
-
case
|
|
1273
|
-
case
|
|
1274
|
-
case
|
|
1264
|
+
case CellType.DATE:
|
|
1265
|
+
case CellType.CTIME:
|
|
1266
|
+
case CellType.MTIME:
|
|
1275
1267
|
{
|
|
1276
1268
|
if (!dateGranularity) {
|
|
1277
|
-
return
|
|
1269
|
+
return getDateDisplayString(cellValue);
|
|
1278
1270
|
}
|
|
1279
|
-
const firstDayOfWeek =
|
|
1271
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1280
1272
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
1281
|
-
return
|
|
1273
|
+
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1282
1274
|
}
|
|
1283
|
-
return
|
|
1275
|
+
return DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1284
1276
|
}
|
|
1285
|
-
case
|
|
1277
|
+
case CellType.MULTIPLE_SELECT:
|
|
1286
1278
|
{
|
|
1287
1279
|
let options = data && data.options;
|
|
1288
1280
|
if (!Array.isArray(cellValue)) {
|
|
@@ -1291,18 +1283,18 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1291
1283
|
const newCellValue = cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
1292
1284
|
return newCellValue.sort();
|
|
1293
1285
|
}
|
|
1294
|
-
case
|
|
1286
|
+
case CellType.COLLABORATOR:
|
|
1295
1287
|
{
|
|
1296
1288
|
if (!Array.isArray(cellValue)) return [];
|
|
1297
|
-
return cellValue.filter(email =>
|
|
1289
|
+
return cellValue.filter(email => isValidCollaboratorEmail(email));
|
|
1298
1290
|
}
|
|
1299
|
-
case
|
|
1300
|
-
case
|
|
1291
|
+
case CellType.CREATOR:
|
|
1292
|
+
case CellType.LAST_MODIFIER:
|
|
1301
1293
|
{
|
|
1302
1294
|
return cellValue ? cellValue : null;
|
|
1303
1295
|
}
|
|
1304
|
-
case
|
|
1305
|
-
case
|
|
1296
|
+
case CellType.LINK_FORMULA:
|
|
1297
|
+
case CellType.FORMULA:
|
|
1306
1298
|
{
|
|
1307
1299
|
if (!formulaRow) return '';
|
|
1308
1300
|
let formulaCellValue = formulaRow[key];
|
|
@@ -1310,34 +1302,34 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1310
1302
|
result_type,
|
|
1311
1303
|
array_type
|
|
1312
1304
|
} = data || {};
|
|
1313
|
-
if (result_type ===
|
|
1305
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1314
1306
|
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1315
1307
|
const dateCellValue = formulaCellValue[0];
|
|
1316
|
-
if (!dateGranularity) return
|
|
1317
|
-
const firstDayOfWeek =
|
|
1318
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return
|
|
1319
|
-
return
|
|
1308
|
+
if (!dateGranularity) return getDateDisplayString(dateCellValue);
|
|
1309
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1310
|
+
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR', firstDayOfWeek);
|
|
1311
|
+
return DateUtils.getDateByGranularity(dateCellValue, dateGranularity, firstDayOfWeek);
|
|
1320
1312
|
}
|
|
1321
|
-
return
|
|
1313
|
+
return getFormulaDisplayString(formulaCellValue, data, {
|
|
1322
1314
|
tables: value.tables
|
|
1323
1315
|
}) || null;
|
|
1324
1316
|
}
|
|
1325
|
-
if (result_type ===
|
|
1326
|
-
return
|
|
1317
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1318
|
+
return getPrecisionNumber(formulaCellValue, data);
|
|
1327
1319
|
}
|
|
1328
1320
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
1329
1321
|
}
|
|
1330
|
-
case
|
|
1322
|
+
case CellType.GEOLOCATION:
|
|
1331
1323
|
{
|
|
1332
1324
|
const {
|
|
1333
1325
|
geo_format
|
|
1334
1326
|
} = data || {};
|
|
1335
1327
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
1336
|
-
return
|
|
1328
|
+
return getGeolocationDisplayString(cellValue, data);
|
|
1337
1329
|
}
|
|
1338
1330
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
1339
1331
|
}
|
|
1340
|
-
case
|
|
1332
|
+
case CellType.LINK:
|
|
1341
1333
|
{
|
|
1342
1334
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
1343
1335
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -1345,11 +1337,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1345
1337
|
}
|
|
1346
1338
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
1347
1339
|
}
|
|
1348
|
-
case
|
|
1340
|
+
case CellType.CHECKBOX:
|
|
1349
1341
|
{
|
|
1350
1342
|
return String(!!cellValue);
|
|
1351
1343
|
}
|
|
1352
|
-
case
|
|
1344
|
+
case CellType.RATE:
|
|
1353
1345
|
{
|
|
1354
1346
|
if (!cellValue) return null;
|
|
1355
1347
|
return cellValue + '';
|
|
@@ -1365,9 +1357,9 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1365
1357
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1366
1358
|
let rowsLength = rows.length;
|
|
1367
1359
|
let total;
|
|
1368
|
-
if (summary_type ===
|
|
1360
|
+
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1369
1361
|
total = rowsLength;
|
|
1370
|
-
} else if (summary_type ===
|
|
1362
|
+
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1371
1363
|
switch (summary_method) {
|
|
1372
1364
|
case 'Distinct_values':
|
|
1373
1365
|
{
|
|
@@ -1375,7 +1367,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1375
1367
|
let existMap = {};
|
|
1376
1368
|
rows.forEach(r => {
|
|
1377
1369
|
let num;
|
|
1378
|
-
if (
|
|
1370
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1379
1371
|
const formulaRow = formula_rows[r._id] || {};
|
|
1380
1372
|
num = formulaRow[summary_column_key];
|
|
1381
1373
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -1404,14 +1396,14 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1404
1396
|
let validNumbersCount = 0;
|
|
1405
1397
|
rows.forEach(r => {
|
|
1406
1398
|
let num;
|
|
1407
|
-
if (
|
|
1399
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1408
1400
|
let formulaRow = formula_rows[r._id] || {};
|
|
1409
1401
|
num = formulaRow[summary_column_key];
|
|
1410
1402
|
num = Array.isArray(num) ? num[0] : num;
|
|
1411
1403
|
} else {
|
|
1412
1404
|
num = r[summary_column_key];
|
|
1413
1405
|
}
|
|
1414
|
-
if (
|
|
1406
|
+
if (isNumber(num)) {
|
|
1415
1407
|
validNumbersCount++;
|
|
1416
1408
|
sum += num;
|
|
1417
1409
|
}
|
|
@@ -1429,7 +1421,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1429
1421
|
if (rowsLength > 0) {
|
|
1430
1422
|
let result = rows.reduce((current, next) => {
|
|
1431
1423
|
let currentValue, nextValue;
|
|
1432
|
-
if (
|
|
1424
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1433
1425
|
let currentFormulaRow = formula_rows[current._id];
|
|
1434
1426
|
let nextFormulaRow = formula_rows[next._id];
|
|
1435
1427
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -1450,7 +1442,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1450
1442
|
return isNextGreater ? next : current;
|
|
1451
1443
|
}
|
|
1452
1444
|
});
|
|
1453
|
-
if (
|
|
1445
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1454
1446
|
let formulaRow = formula_rows[result._id];
|
|
1455
1447
|
total = formulaRow && formulaRow[summary_column_key];
|
|
1456
1448
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -1472,42 +1464,42 @@ BaseUtils.getFormattedValue = (value, column, summaryMethod) => {
|
|
|
1472
1464
|
if (!column) {
|
|
1473
1465
|
return value;
|
|
1474
1466
|
}
|
|
1475
|
-
if (summaryMethod ===
|
|
1467
|
+
if (summaryMethod === CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
|
|
1476
1468
|
return value;
|
|
1477
1469
|
}
|
|
1478
1470
|
const {
|
|
1479
1471
|
type,
|
|
1480
1472
|
data
|
|
1481
1473
|
} = column;
|
|
1482
|
-
if (
|
|
1483
|
-
return
|
|
1474
|
+
if (isNumericColumn(column)) {
|
|
1475
|
+
return getNumberDisplayString(value, data);
|
|
1484
1476
|
}
|
|
1485
|
-
if (
|
|
1486
|
-
return
|
|
1477
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
1478
|
+
return getClientFormulaDisplayString(value, data);
|
|
1487
1479
|
}
|
|
1488
1480
|
return value;
|
|
1489
1481
|
};
|
|
1490
1482
|
BaseUtils.getSummaryResult = function (results, summaryMethod) {
|
|
1491
1483
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
1492
|
-
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res =>
|
|
1484
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => isNumber(res)) : [];
|
|
1493
1485
|
switch (summaryMethod) {
|
|
1494
|
-
case
|
|
1486
|
+
case CHART_SUMMARY_TYPE.MAX:
|
|
1495
1487
|
{
|
|
1496
1488
|
return _BaseUtils.getMax(numericResults);
|
|
1497
1489
|
}
|
|
1498
|
-
case
|
|
1490
|
+
case CHART_SUMMARY_TYPE.MIN:
|
|
1499
1491
|
{
|
|
1500
1492
|
return _BaseUtils.getMin(numericResults);
|
|
1501
1493
|
}
|
|
1502
|
-
case
|
|
1494
|
+
case CHART_SUMMARY_TYPE.SUM:
|
|
1503
1495
|
{
|
|
1504
1496
|
return _BaseUtils.getSum(numericResults, precision);
|
|
1505
1497
|
}
|
|
1506
|
-
case
|
|
1498
|
+
case CHART_SUMMARY_TYPE.MEAN:
|
|
1507
1499
|
{
|
|
1508
1500
|
return _BaseUtils.getMean(numericResults, precision);
|
|
1509
1501
|
}
|
|
1510
|
-
case
|
|
1502
|
+
case CHART_SUMMARY_TYPE.Distinct_values:
|
|
1511
1503
|
{
|
|
1512
1504
|
let count = 0;
|
|
1513
1505
|
let existMap = {};
|
|
@@ -1556,15 +1548,15 @@ BaseUtils.getMean = function (list) {
|
|
|
1556
1548
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
1557
1549
|
};
|
|
1558
1550
|
BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
|
|
1559
|
-
const currentTime = (
|
|
1551
|
+
const currentTime = dayjs();
|
|
1560
1552
|
const days = duration === 'days_30' ? 30 : 7;
|
|
1561
1553
|
// set date to start of the day
|
|
1562
1554
|
const formattedEndDate = currentTime.format('YYYY-MM-DD');
|
|
1563
1555
|
const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
1564
|
-
const formattedStartDate = (
|
|
1565
|
-
const endDate = (
|
|
1566
|
-
const middleDate = (
|
|
1567
|
-
const startDate = (
|
|
1556
|
+
const formattedStartDate = dayjs(formattedMiddleDate).subtract(days, 'days').format('YYYY-MM-DD');
|
|
1557
|
+
const endDate = dayjs(formattedEndDate);
|
|
1558
|
+
const middleDate = dayjs(formattedMiddleDate);
|
|
1559
|
+
const startDate = dayjs(formattedStartDate);
|
|
1568
1560
|
let compareValue = [];
|
|
1569
1561
|
let comparedValue = [];
|
|
1570
1562
|
if (useDataDb) {
|
|
@@ -1572,7 +1564,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1572
1564
|
const days2 = [];
|
|
1573
1565
|
for (let index = 0; index < result.length; index++) {
|
|
1574
1566
|
const item = result[index];
|
|
1575
|
-
const key = (
|
|
1567
|
+
const key = dayjs(item[dbDateKey]);
|
|
1576
1568
|
if (!key.isValid()) continue;
|
|
1577
1569
|
if (key >= startDate && key < middleDate) {
|
|
1578
1570
|
comparedValue.push(item[valueKey]);
|
|
@@ -1601,7 +1593,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1601
1593
|
// }
|
|
1602
1594
|
// }
|
|
1603
1595
|
// }
|
|
1604
|
-
if (summaryType ===
|
|
1596
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1605
1597
|
comparedValue = _BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
1606
1598
|
compareValue = _BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
1607
1599
|
} else {
|
|
@@ -1627,13 +1619,13 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1627
1619
|
sqlColumnGroupbyColumnKey
|
|
1628
1620
|
} = chartSQLMap;
|
|
1629
1621
|
let newSqlRows = JSON.parse(JSON.stringify(sqlRows));
|
|
1630
|
-
if (config.summary_type ===
|
|
1622
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1631
1623
|
// has column group
|
|
1632
1624
|
if (sqlColumnGroupbyColumnKey) {
|
|
1633
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1625
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1634
1626
|
return newSqlRows;
|
|
1635
1627
|
}
|
|
1636
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1628
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1637
1629
|
return newSqlRows;
|
|
1638
1630
|
}
|
|
1639
1631
|
}
|
|
@@ -1659,7 +1651,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1659
1651
|
newSqlRows = Object.values(collaboratorsRowsMap);
|
|
1660
1652
|
}
|
|
1661
1653
|
}
|
|
1662
|
-
if (config.summary_type ===
|
|
1654
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1663
1655
|
let summarySQLColumnName2ColumnKeys;
|
|
1664
1656
|
if (summarySQLColumnName2ColumnKey) {
|
|
1665
1657
|
summarySQLColumnName2ColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
@@ -1672,10 +1664,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1672
1664
|
|
|
1673
1665
|
// has column group
|
|
1674
1666
|
if (sqlColumnGroupbyColumnKey) {
|
|
1675
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1667
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1676
1668
|
return newSqlRows;
|
|
1677
1669
|
}
|
|
1678
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1670
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1679
1671
|
return newSqlRows;
|
|
1680
1672
|
}
|
|
1681
1673
|
|
|
@@ -1683,10 +1675,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1683
1675
|
newSqlRows.forEach(item => {
|
|
1684
1676
|
summarySQLColumnName2ColumnKeys.forEach(key => {
|
|
1685
1677
|
if (key.startsWith('AVG')) {
|
|
1686
|
-
item[
|
|
1678
|
+
item[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1687
1679
|
// Update avg
|
|
1688
1680
|
const newKey = 'SUM' + key.slice(3);
|
|
1689
|
-
item[key] = item[newKey] / item[
|
|
1681
|
+
item[key] = item[newKey] / item[`COUNT(${key.slice(3)})`];
|
|
1690
1682
|
}
|
|
1691
1683
|
});
|
|
1692
1684
|
});
|
|
@@ -1698,7 +1690,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1698
1690
|
newSqlRows.forEach(item => {
|
|
1699
1691
|
summarySQLColumnName2ColumnKeys.forEach(key => {
|
|
1700
1692
|
if (key.startsWith('AVG')) {
|
|
1701
|
-
item[
|
|
1693
|
+
item[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1702
1694
|
}
|
|
1703
1695
|
});
|
|
1704
1696
|
});
|
|
@@ -1719,7 +1711,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1719
1711
|
// Avg: The avg is calculated by sum / count
|
|
1720
1712
|
if (key.startsWith('AVG')) {
|
|
1721
1713
|
newKey = 'SUM' + key.slice(3);
|
|
1722
|
-
newSqlRows[rowIndex][
|
|
1714
|
+
newSqlRows[rowIndex][`COUNT(${key.slice(3)})`] = newSqlRows[rowIndex][`COUNT(${key.slice(3)})`] + item['COUNT(*)'];
|
|
1723
1715
|
}
|
|
1724
1716
|
// Sum
|
|
1725
1717
|
if (newKey.startsWith('SUM') && newSqlRows[rowIndex][newKey]) {
|
|
@@ -1753,7 +1745,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1753
1745
|
// Avg: The avg is calculated by sum / count
|
|
1754
1746
|
if (key.startsWith('AVG')) {
|
|
1755
1747
|
newKey = 'SUM' + key.slice(3);
|
|
1756
|
-
obj[
|
|
1748
|
+
obj[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1757
1749
|
}
|
|
1758
1750
|
// Sum
|
|
1759
1751
|
if (newKey.startsWith('SUM')) {
|
|
@@ -1773,7 +1765,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1773
1765
|
// Update avg
|
|
1774
1766
|
if (key.startsWith('AVG')) {
|
|
1775
1767
|
const newKey = 'SUM' + key.slice(3);
|
|
1776
|
-
item[key] = item[newKey] / item[
|
|
1768
|
+
item[key] = item[newKey] / item[`COUNT(${key.slice(3)})`];
|
|
1777
1769
|
}
|
|
1778
1770
|
});
|
|
1779
1771
|
});
|
|
@@ -1817,16 +1809,16 @@ BaseUtils.getDateGranularityByType = chart => {
|
|
|
1817
1809
|
const {
|
|
1818
1810
|
type
|
|
1819
1811
|
} = chart;
|
|
1820
|
-
if ([
|
|
1812
|
+
if ([CHART_TYPE.AREA_GROUP, CHART_TYPE.AREA, CHART_TYPE.BAR, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.COMBINATION, CHART_TYPE.LINE_GROUP, CHART_TYPE.LINE].includes(type)) {
|
|
1821
1813
|
return chart['x_axis_date_granularity'];
|
|
1822
1814
|
}
|
|
1823
|
-
if ([
|
|
1815
|
+
if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
|
|
1824
1816
|
return chart['date_granularity'];
|
|
1825
1817
|
}
|
|
1826
|
-
if ([
|
|
1818
|
+
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1827
1819
|
return chart['vertical_axis_date_granularity'];
|
|
1828
1820
|
}
|
|
1829
|
-
if ([
|
|
1821
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1830
1822
|
return chart['groupby_date_granularity'];
|
|
1831
1823
|
}
|
|
1832
1824
|
return null;
|
|
@@ -1855,7 +1847,7 @@ BaseUtils.updateCollaboratorAndMultipleAvg = (pivot_rows, all) => {
|
|
|
1855
1847
|
let allSum = 0;
|
|
1856
1848
|
let allCount = 0;
|
|
1857
1849
|
cell.rows.forEach(r => {
|
|
1858
|
-
allSum = allSum + r[
|
|
1850
|
+
allSum = allSum + r[`SUM(${avgColumnName})`];
|
|
1859
1851
|
allCount = allCount + r['COUNT(*)'];
|
|
1860
1852
|
});
|
|
1861
1853
|
|
|
@@ -1877,13 +1869,13 @@ BaseUtils.isCollaboratorColumnOrMultipleColumn = columnMap => {
|
|
|
1877
1869
|
columnGroupbyColumn,
|
|
1878
1870
|
groupbyColumn
|
|
1879
1871
|
} = columnMap || {};
|
|
1880
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1872
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1881
1873
|
return true;
|
|
1882
1874
|
}
|
|
1883
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1875
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1884
1876
|
return true;
|
|
1885
1877
|
}
|
|
1886
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1878
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.LINK_FORMULA && [CellType.MULTIPLE_SELECT, CellType.COLLABORATOR].includes(groupbyColumn === null || groupbyColumn === void 0 ? void 0 : (_groupbyColumn$data = groupbyColumn.data) === null || _groupbyColumn$data === void 0 ? void 0 : _groupbyColumn$data.array_type)) {
|
|
1887
1879
|
return true;
|
|
1888
1880
|
}
|
|
1889
1881
|
return false;
|
|
@@ -1897,10 +1889,10 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1897
1889
|
} = chart.config;
|
|
1898
1890
|
if (!column_groupby_multiple_numeric_column) {
|
|
1899
1891
|
if (groupColumn) {
|
|
1900
|
-
if ([
|
|
1892
|
+
if ([CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1901
1893
|
data.forEach(item => {
|
|
1902
1894
|
const option = groupColumn.data.options.find(option => option.name === item[groupKey]);
|
|
1903
|
-
if (option
|
|
1895
|
+
if (option === null || option === void 0 ? void 0 : option.id) {
|
|
1904
1896
|
item['group_name_id'] = option.id;
|
|
1905
1897
|
item['oldName'] = item.name;
|
|
1906
1898
|
item.name = item['group_name_id'];
|
|
@@ -1920,4 +1912,4 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1920
1912
|
}
|
|
1921
1913
|
return data;
|
|
1922
1914
|
};
|
|
1923
|
-
|
|
1915
|
+
export default BaseUtils;
|