sea-chart 2.0.43 → 2.0.45
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 +4 -11
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
- 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 +27 -35
- 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 +11 -18
- package/dist/components/color-popover/color-rules/color-rule.js +25 -33
- package/dist/components/color-popover/color-rules/index.js +6 -14
- 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 +10 -18
- package/dist/components/color-popover/color-rules-popover.js +26 -34
- package/dist/components/color-popover/color-selector-popover.js +10 -18
- package/dist/components/color-setting/color-group-selector.js +12 -20
- package/dist/components/common-add-tool/index.js +6 -13
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +12 -19
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +16 -24
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
- 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 +4 -11
- 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 +25 -33
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +54 -64
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +15 -22
- package/dist/components/row-card/row-card-header.js +14 -21
- package/dist/components/row-card/row-card-item.js +33 -41
- package/dist/components/row-card/row-card.js +15 -23
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +21 -21
- package/dist/components/types-dialog/index.js +56 -64
- 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 +149 -273
- 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 +20 -24
- 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 +8 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +19 -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 +15 -18
- package/dist/model/horizontal-group-bar.js +14 -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 +15 -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 +7 -13
- 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 +83 -74
- 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 +69 -60
- 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 +18 -26
- 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 +94 -77
- 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 +26 -34
- 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 +64 -72
- 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 +111 -119
- 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 +62 -53
- 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 +17 -25
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- 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 +24 -32
- 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 +23 -31
- 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 +72 -80
- package/dist/settings/widgets/switch/index.js +8 -15
- 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 +63 -71
- package/dist/utils/cell-format-utils.js +18 -28
- package/dist/utils/cell-value-utils.js +5 -12
- package/dist/utils/chart-utils/base-utils.js +362 -334
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
- 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 +19 -26
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
- 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 +21 -28
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
- 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 +284 -246
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +18 -30
- package/dist/utils/collaborator.js +4 -13
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +65 -92
- package/dist/utils/common-utils.js +27 -52
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +11 -19
- 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 +1 -7
- package/dist/utils/options-utils.js +8 -16
- package/dist/utils/row-record-utils.js +182 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +49 -55
- package/dist/utils/sql/column-2-sql-column.js +146 -154
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.css +0 -17
- package/dist/view/index.js +89 -95
- package/dist/view/title/index.js +15 -23
- package/dist/view/wrapper/area-group.js +57 -74
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +47 -58
- package/dist/view/wrapper/bar-custom-stack.js +53 -121
- package/dist/view/wrapper/bar-group.js +55 -96
- package/dist/view/wrapper/bar-stack.js +58 -92
- package/dist/view/wrapper/bar.js +45 -66
- package/dist/view/wrapper/basic-number-card.js +25 -26
- package/dist/view/wrapper/chart-component.js +600 -166
- package/dist/view/wrapper/combination.js +79 -87
- package/dist/view/wrapper/completeness-group.js +46 -98
- package/dist/view/wrapper/completeness.js +45 -97
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +65 -64
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +61 -78
- package/dist/view/wrapper/horizontal-bar-stack.js +60 -111
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +52 -68
- package/dist/view/wrapper/line.js +47 -67
- package/dist/view/wrapper/map-bubble.js +46 -59
- package/dist/view/wrapper/map-world-bubble.js +45 -58
- package/dist/view/wrapper/map-world.js +47 -60
- package/dist/view/wrapper/map.js +48 -60
- package/dist/view/wrapper/mirror.js +45 -64
- package/dist/view/wrapper/pie.js +51 -59
- package/dist/view/wrapper/ring.js +57 -64
- package/dist/view/wrapper/scatter.js +53 -69
- package/dist/view/wrapper/table/index.js +13 -21
- 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 +50 -58
- package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
- package/dist/view/wrapper/table/two-dimension-table.js +76 -84
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +96 -105
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/record.js +10 -17
- package/dist/view/wrapper/table-element/components/records-body.js +17 -19
- 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 +23 -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 +5 -15
- 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 +39 -57
- package/dist/view/wrapper/trend.js +41 -48
- package/package.json +1 -1
|
@@ -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, getMultipleOptionName, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isEmpty, 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, DEFAULT_ITEM_COLOR } 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;
|
|
@@ -633,7 +625,7 @@ BaseUtils.getPieColor = (column, index, data, currentTheme, useColumnColor) => {
|
|
|
633
625
|
const selectedItem = columnData.options.find(item => {
|
|
634
626
|
return item.name === data.name.trim();
|
|
635
627
|
}) || {};
|
|
636
|
-
return selectedItem.color ||
|
|
628
|
+
return selectedItem.color || DEFAULT_ITEM_COLOR;
|
|
637
629
|
}
|
|
638
630
|
} else {
|
|
639
631
|
const pieChartColorsLength = colors.length - 1;
|
|
@@ -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);
|
|
@@ -686,11 +678,11 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
686
678
|
filteredData.push({
|
|
687
679
|
name: '_Others',
|
|
688
680
|
value: filteredSum,
|
|
689
|
-
color:
|
|
681
|
+
color: DEFAULT_ITEM_COLOR,
|
|
690
682
|
percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%',
|
|
691
683
|
rows
|
|
692
684
|
});
|
|
693
|
-
colorMap['_Others'] =
|
|
685
|
+
colorMap['_Others'] = DEFAULT_ITEM_COLOR;
|
|
694
686
|
}
|
|
695
687
|
return {
|
|
696
688
|
data: filteredData,
|
|
@@ -708,9 +700,14 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
708
700
|
data: columnData
|
|
709
701
|
} = column;
|
|
710
702
|
let name = result[nameKey];
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
|
|
703
|
+
if (isEmpty(name)) {
|
|
704
|
+
result[colorKey] = result[colorKey] || DEFAULT_ITEM_COLOR;
|
|
705
|
+
resolve(resultPromise);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if (columnType === CellType.SINGLE_SELECT) {
|
|
709
|
+
const options = getColumnOptions(column);
|
|
710
|
+
let selectedOption = getOption(options, name);
|
|
714
711
|
let {
|
|
715
712
|
name: optionName,
|
|
716
713
|
color: optionColor,
|
|
@@ -721,68 +718,80 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
721
718
|
result[colorKey] = optionColor;
|
|
722
719
|
isNameField && (result.original_name = id);
|
|
723
720
|
} else {
|
|
724
|
-
result[colorKey] =
|
|
721
|
+
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
725
722
|
}
|
|
726
|
-
} else if (columnType ===
|
|
727
|
-
const
|
|
723
|
+
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
724
|
+
const options = getColumnOptions(column);
|
|
725
|
+
const optionIds = Array.isArray(name) ? name : [name];
|
|
726
|
+
const optionNames = getMultipleOptionName(options, optionIds);
|
|
727
|
+
if (optionNames) {
|
|
728
|
+
result[nameKey] = optionNames;
|
|
729
|
+
const firstOption = options.find(o => optionIds.includes(o.id));
|
|
730
|
+
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || DEFAULT_ITEM_COLOR;
|
|
731
|
+
isNameField && (result.original_name = optionIds);
|
|
732
|
+
} else {
|
|
733
|
+
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
734
|
+
}
|
|
735
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
736
|
+
const users = context.getCollaboratorsFromCache();
|
|
728
737
|
const user = users.find(user => user.email === name);
|
|
729
738
|
if (user) {
|
|
730
739
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
731
740
|
isNameField && (result.original_name = name);
|
|
732
741
|
resolve();
|
|
733
742
|
} else {
|
|
734
|
-
|
|
743
|
+
context.queryUsers([name], users => {
|
|
735
744
|
const userEmail = name;
|
|
736
|
-
const user = users[userEmail] ||
|
|
745
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
737
746
|
const userName = user.name || userEmail;
|
|
738
747
|
result[nameKey] = userName;
|
|
739
748
|
isNameField && (result.original_name = userEmail);
|
|
740
749
|
user.loaded = true;
|
|
741
|
-
|
|
750
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
742
751
|
resolve();
|
|
743
752
|
});
|
|
744
753
|
}
|
|
745
754
|
return;
|
|
746
|
-
} else if (columnType ===
|
|
747
|
-
const users =
|
|
755
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
756
|
+
const users = context.getCollaboratorsFromCache();
|
|
748
757
|
const user = users.find(user => user.email === name);
|
|
749
758
|
if (user) {
|
|
750
759
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
751
760
|
isNameField && (result.original_name = name);
|
|
752
761
|
resolve();
|
|
753
762
|
} else {
|
|
754
|
-
|
|
763
|
+
context.queryUsers([name], users => {
|
|
755
764
|
const userEmail = name;
|
|
756
|
-
const user = users[userEmail] ||
|
|
765
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
757
766
|
const userName = user.name || userEmail;
|
|
758
767
|
result[nameKey] = userName;
|
|
759
768
|
isNameField && (result.original_name = userEmail);
|
|
760
769
|
user.loaded = true;
|
|
761
|
-
|
|
770
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
762
771
|
resolve();
|
|
763
772
|
});
|
|
764
773
|
}
|
|
765
774
|
return;
|
|
766
|
-
} else if (columnType ===
|
|
775
|
+
} else if (columnType === CellType.NUMBER) {
|
|
767
776
|
let valueNumber = parseFloat(name);
|
|
768
|
-
result[nameKey] =
|
|
777
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
769
778
|
isNameField && (result.original_name = name);
|
|
770
|
-
} else if (columnType ===
|
|
779
|
+
} else if (columnType === CellType.DATE) {
|
|
771
780
|
name = name + '';
|
|
772
781
|
if (name && name.split('-').length === 3) {
|
|
773
|
-
let format =
|
|
782
|
+
let format = getDateColumnFormat(column);
|
|
774
783
|
let spaceIndex = format.indexOf(' ');
|
|
775
784
|
if (spaceIndex > -1) {
|
|
776
785
|
format = format.slice(0, spaceIndex);
|
|
777
786
|
}
|
|
778
|
-
result[nameKey] = (
|
|
787
|
+
result[nameKey] = dayjs(name).format(format);
|
|
779
788
|
}
|
|
780
|
-
} else if (columnType ===
|
|
789
|
+
} else if (columnType === CellType.LINK_FORMULA) {
|
|
781
790
|
// scatter only use number
|
|
782
791
|
if (isScatterChart) {
|
|
783
792
|
name.length && (name = name[0]);
|
|
784
793
|
let valueNumber = parseFloat(name);
|
|
785
|
-
result[nameKey] =
|
|
794
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
786
795
|
}
|
|
787
796
|
const {
|
|
788
797
|
array_data,
|
|
@@ -795,18 +804,18 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
795
804
|
};
|
|
796
805
|
// for linked formula, need to call recursively, using it's result as the result of the promise
|
|
797
806
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
|
|
798
|
-
} else if (columnType ===
|
|
807
|
+
} else if (columnType === CellType.FORMULA) {
|
|
799
808
|
const {
|
|
800
809
|
result_type: resultType,
|
|
801
810
|
array_type: arrayType,
|
|
802
811
|
array_data: arrayData
|
|
803
812
|
} = columnData || {};
|
|
804
|
-
if (resultType ===
|
|
813
|
+
if (resultType === FORMULA_RESULT_TYPE.NUMBER) {
|
|
805
814
|
const valueNumber = parseFloat(name);
|
|
806
|
-
result[nameKey] =
|
|
815
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
807
816
|
isNameField && (result.original_name = name);
|
|
808
|
-
} else if (resultType ===
|
|
809
|
-
result[nameKey] =
|
|
817
|
+
} else if (resultType === FORMULA_RESULT_TYPE.DATE || resultType === CellType.CTIME || resultType === CellType.MTIME) {
|
|
818
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
810
819
|
isNameField && (result.original_name = name);
|
|
811
820
|
} else if (arrayType && arrayData) {
|
|
812
821
|
const formulaArrayColumn = {
|
|
@@ -817,19 +826,19 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
817
826
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, formulaArrayColumn, nameKey, colorKey, isScatterChart, isNameField);
|
|
818
827
|
} else if (Array.isArray(name)) {
|
|
819
828
|
result[nameKey] = name.map(item => {
|
|
820
|
-
if (
|
|
821
|
-
const collaborator =
|
|
829
|
+
if (isValidCollaboratorEmail(item)) {
|
|
830
|
+
const collaborator = getKnownCollaboratorByEmail(item);
|
|
822
831
|
return collaborator ? collaborator.name : item;
|
|
823
832
|
}
|
|
824
833
|
return item;
|
|
825
834
|
}).join(', ');
|
|
826
835
|
isNameField && (result.original_name = name.join(', '));
|
|
827
|
-
} else if (typeof name === 'string' &&
|
|
828
|
-
const collaborator =
|
|
836
|
+
} else if (typeof name === 'string' && isValidCollaboratorEmail(name)) {
|
|
837
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
829
838
|
result[nameKey] = collaborator ? collaborator.name : name;
|
|
830
839
|
isNameField && (result.original_name = name);
|
|
831
840
|
} else {
|
|
832
|
-
result[nameKey] =
|
|
841
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
833
842
|
isNameField && (result.original_name = name);
|
|
834
843
|
}
|
|
835
844
|
}
|
|
@@ -856,8 +865,8 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
856
865
|
} = column;
|
|
857
866
|
const sortType = 'up';
|
|
858
867
|
const optionIdIndexMap = {};
|
|
859
|
-
const isPivotMultipleSelect = columnType ===
|
|
860
|
-
if ([
|
|
868
|
+
const isPivotMultipleSelect = columnType === CellType.MULTIPLE_SELECT && isPivot;
|
|
869
|
+
if ([CellType.SINGLE_SELECT].includes(columnType) || isPivotMultipleSelect) {
|
|
861
870
|
const {
|
|
862
871
|
options
|
|
863
872
|
} = data || {};
|
|
@@ -865,7 +874,7 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
865
874
|
optionIdIndexMap[option.id] = index;
|
|
866
875
|
});
|
|
867
876
|
}
|
|
868
|
-
const isPivotLinkFormulaSingleAndMultipleSelect = columnType ===
|
|
877
|
+
const isPivotLinkFormulaSingleAndMultipleSelect = columnType === CellType.LINK_FORMULA && [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT].includes(column.data.array_type) && isPivot;
|
|
869
878
|
if (isPivotLinkFormulaSingleAndMultipleSelect) {
|
|
870
879
|
var _column$data;
|
|
871
880
|
let {
|
|
@@ -889,14 +898,14 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
889
898
|
if (!next && next !== 0) {
|
|
890
899
|
return 1;
|
|
891
900
|
}
|
|
892
|
-
if (
|
|
901
|
+
if (CHART_SUPPORT_SORT_COLUMNS.includes(columnType)) {
|
|
893
902
|
let realColumnType = columnType;
|
|
894
|
-
if ([
|
|
903
|
+
if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
|
|
895
904
|
realColumnType = column.data.array_type;
|
|
896
905
|
}
|
|
897
906
|
switch (realColumnType) {
|
|
898
|
-
case
|
|
899
|
-
case
|
|
907
|
+
case CellType.NUMBER:
|
|
908
|
+
case CellType.RATE:
|
|
900
909
|
{
|
|
901
910
|
if (current) {
|
|
902
911
|
current = current - 0;
|
|
@@ -904,15 +913,15 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
904
913
|
if (next) {
|
|
905
914
|
next = next - 0;
|
|
906
915
|
}
|
|
907
|
-
return
|
|
916
|
+
return sortNumber(current, next, sortType);
|
|
908
917
|
}
|
|
909
|
-
case
|
|
910
|
-
case
|
|
911
|
-
case
|
|
918
|
+
case CellType.DATE:
|
|
919
|
+
case CellType.CTIME:
|
|
920
|
+
case CellType.MTIME:
|
|
912
921
|
{
|
|
913
|
-
return
|
|
922
|
+
return sortDate(current, next, sortType);
|
|
914
923
|
}
|
|
915
|
-
case
|
|
924
|
+
case CellType.SINGLE_SELECT:
|
|
916
925
|
{
|
|
917
926
|
// key was used to sort "pivot columns" in pivot chart
|
|
918
927
|
const {
|
|
@@ -925,29 +934,29 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
925
934
|
} = nextResult || {};
|
|
926
935
|
const current = currentName || currentKey;
|
|
927
936
|
const next = nextName || nextKey;
|
|
928
|
-
return
|
|
937
|
+
return sortSingleSelect(current, next, {
|
|
929
938
|
sort_type: sortType,
|
|
930
939
|
option_id_index_map: optionIdIndexMap
|
|
931
940
|
});
|
|
932
941
|
}
|
|
933
|
-
case
|
|
942
|
+
case CellType.MULTIPLE_SELECT:
|
|
934
943
|
{
|
|
935
|
-
return
|
|
944
|
+
return sortSingleSelect(current, next, {
|
|
936
945
|
sort_type: sortType,
|
|
937
946
|
option_id_index_map: optionIdIndexMap
|
|
938
947
|
});
|
|
939
948
|
}
|
|
940
|
-
case
|
|
941
|
-
case
|
|
949
|
+
case CellType.FORMULA:
|
|
950
|
+
case CellType.LINK_FORMULA:
|
|
942
951
|
{
|
|
943
|
-
return
|
|
952
|
+
return sortFormula(current, next, sortType, {
|
|
944
953
|
columnData: data,
|
|
945
954
|
value: {}
|
|
946
955
|
});
|
|
947
956
|
}
|
|
948
957
|
default:
|
|
949
958
|
{
|
|
950
|
-
return
|
|
959
|
+
return sortText(current, next, sortType);
|
|
951
960
|
}
|
|
952
961
|
}
|
|
953
962
|
}
|
|
@@ -962,8 +971,8 @@ BaseUtils.sortChartData = (charts, sort_key) => {
|
|
|
962
971
|
const {
|
|
963
972
|
value: next
|
|
964
973
|
} = nextResult;
|
|
965
|
-
if (
|
|
966
|
-
if (
|
|
974
|
+
if (isEmpty(current)) return -1;
|
|
975
|
+
if (isEmpty(next)) return 1;
|
|
967
976
|
if (sort_key === 'ascending') {
|
|
968
977
|
return current > next ? 1 : -1;
|
|
969
978
|
}
|
|
@@ -987,7 +996,7 @@ BaseUtils.sortDataByKey = (data, key, sortType) => {
|
|
|
987
996
|
if (!nextVal && nextVal !== 0) {
|
|
988
997
|
return 1;
|
|
989
998
|
}
|
|
990
|
-
if (sortType ===
|
|
999
|
+
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
991
1000
|
return currentVal > nextVal ? 1 : -1;
|
|
992
1001
|
} else {
|
|
993
1002
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -1013,7 +1022,7 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1013
1022
|
type,
|
|
1014
1023
|
config
|
|
1015
1024
|
} = chart;
|
|
1016
|
-
if (
|
|
1025
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
1017
1026
|
groupby_column_key = config.groupby_column_key;
|
|
1018
1027
|
} else {
|
|
1019
1028
|
groupby_column_key = config.x_axis_column_key;
|
|
@@ -1022,9 +1031,9 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1022
1031
|
const {
|
|
1023
1032
|
table_id
|
|
1024
1033
|
} = config;
|
|
1025
|
-
const table =
|
|
1026
|
-
const groupbyColumn =
|
|
1027
|
-
const columnGroupbyColumn =
|
|
1034
|
+
const table = getTableById(tables, table_id);
|
|
1035
|
+
const groupbyColumn = getTableColumnByKey(table, groupby_column_key);
|
|
1036
|
+
const columnGroupbyColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
1028
1037
|
results.forEach(item => {
|
|
1029
1038
|
const {
|
|
1030
1039
|
name,
|
|
@@ -1043,84 +1052,95 @@ BaseUtils.convertResultName = (result, column, name, nameKey, colorKey) => {
|
|
|
1043
1052
|
type: columnType,
|
|
1044
1053
|
data: columnData
|
|
1045
1054
|
} = column;
|
|
1046
|
-
if (columnType ===
|
|
1047
|
-
const options =
|
|
1048
|
-
const selectedOption =
|
|
1055
|
+
if (columnType === CellType.SINGLE_SELECT) {
|
|
1056
|
+
const options = getColumnOptions(column);
|
|
1057
|
+
const selectedOption = getOption(options, name);
|
|
1049
1058
|
if (selectedOption) {
|
|
1050
1059
|
result[nameKey] = selectedOption.name;
|
|
1051
1060
|
result[colorKey] = selectedOption.color;
|
|
1052
1061
|
} else {
|
|
1053
|
-
result[colorKey] =
|
|
1062
|
+
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
1063
|
+
}
|
|
1064
|
+
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
1065
|
+
const options = getColumnOptions(column);
|
|
1066
|
+
const optionIds = Array.isArray(name) ? name : [name];
|
|
1067
|
+
const optionNames = getMultipleOptionName(options, optionIds);
|
|
1068
|
+
if (optionNames) {
|
|
1069
|
+
result[nameKey] = optionNames;
|
|
1070
|
+
const firstOption = options.find(o => optionIds.includes(o.id));
|
|
1071
|
+
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || DEFAULT_ITEM_COLOR;
|
|
1072
|
+
} else {
|
|
1073
|
+
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
1054
1074
|
}
|
|
1055
|
-
} else if (columnType ===
|
|
1056
|
-
let collaborator =
|
|
1075
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
1076
|
+
let collaborator = getKnownCollaboratorByEmail(name);
|
|
1057
1077
|
if (collaborator) {
|
|
1058
1078
|
result[nameKey] = collaborator.name;
|
|
1059
1079
|
}
|
|
1060
|
-
} else if (columnType ===
|
|
1080
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
1061
1081
|
if (name === 'anonymous') {
|
|
1062
1082
|
result[nameKey] = name;
|
|
1063
1083
|
} else {
|
|
1064
|
-
const collaborator =
|
|
1084
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
1065
1085
|
const collaboratorTemplate = {
|
|
1066
1086
|
loaded: false,
|
|
1067
1087
|
email: name,
|
|
1068
1088
|
name: name
|
|
1069
1089
|
};
|
|
1070
|
-
|
|
1090
|
+
context.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
1071
1091
|
if (!collaborator) {
|
|
1072
|
-
|
|
1073
|
-
const collaborator = emailUserMap && emailUserMap[name] ||
|
|
1092
|
+
context.queryUsers([name], emailUserMap => {
|
|
1093
|
+
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
1074
1094
|
const loadedCollaborator = {
|
|
1075
1095
|
...collaborator,
|
|
1076
1096
|
loaded: true
|
|
1077
1097
|
};
|
|
1078
|
-
|
|
1098
|
+
context.updateCollaboratorsCache(name, loadedCollaborator);
|
|
1079
1099
|
result[nameKey] = name;
|
|
1080
1100
|
});
|
|
1081
1101
|
} else {
|
|
1082
1102
|
result[nameKey] = collaborator.name;
|
|
1083
1103
|
}
|
|
1084
1104
|
}
|
|
1085
|
-
} else if (columnType ===
|
|
1105
|
+
} else if (columnType === CellType.NUMBER) {
|
|
1086
1106
|
const valueNumber = parseFloat(name);
|
|
1087
|
-
result[nameKey] =
|
|
1088
|
-
} else if (columnType ===
|
|
1107
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1108
|
+
} else if (columnType === CellType.DATE) {
|
|
1089
1109
|
if (name && name.split('-').length === 3) {
|
|
1090
|
-
let format =
|
|
1110
|
+
let format = getDateColumnFormat(column);
|
|
1091
1111
|
const spaceIndex = format.indexOf(' ');
|
|
1092
1112
|
if (spaceIndex > -1) {
|
|
1093
1113
|
format = format.slice(0, spaceIndex);
|
|
1094
1114
|
}
|
|
1095
|
-
result[nameKey] = (
|
|
1115
|
+
result[nameKey] = dayjs(name).format(format);
|
|
1096
1116
|
}
|
|
1097
|
-
} else if (
|
|
1117
|
+
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
1098
1118
|
const {
|
|
1099
1119
|
result_type,
|
|
1100
1120
|
array_type
|
|
1101
1121
|
} = columnData || {};
|
|
1102
|
-
if (result_type ===
|
|
1122
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1103
1123
|
const valueNumber = parseFloat(name);
|
|
1104
|
-
result[nameKey] =
|
|
1105
|
-
} else if (result_type ===
|
|
1106
|
-
if (
|
|
1124
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1125
|
+
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1126
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(name)) {
|
|
1107
1127
|
result[nameKey] = name.map(email => {
|
|
1108
|
-
let user = array_type ===
|
|
1128
|
+
let user = array_type === CellType.COLLABORATOR ? getKnownCollaboratorByEmail(email) : getKnownCollaboratorByEmail(email);
|
|
1109
1129
|
return (user || {}).name;
|
|
1110
1130
|
});
|
|
1111
1131
|
}
|
|
1112
1132
|
}
|
|
1113
|
-
} else if (columnType ===
|
|
1114
|
-
result[nameKey] =
|
|
1133
|
+
} else if (columnType === CellType.LINK) {
|
|
1134
|
+
result[nameKey] = getClientFormulaDisplayString([name], columnData) || null;
|
|
1115
1135
|
}
|
|
1116
1136
|
};
|
|
1117
1137
|
// theme
|
|
1118
1138
|
BaseUtils.getCurrentTheme = themeName => {
|
|
1119
1139
|
if (themeName) {
|
|
1120
|
-
const currentColorTheme =
|
|
1140
|
+
const currentColorTheme = STYLE_COLORS.find(item => item.name === themeName);
|
|
1121
1141
|
return currentColorTheme;
|
|
1122
1142
|
}
|
|
1123
|
-
return
|
|
1143
|
+
return STYLE_COLORS[0];
|
|
1124
1144
|
};
|
|
1125
1145
|
BaseUtils.getSummaryExplanation = chart => {
|
|
1126
1146
|
const {
|
|
@@ -1130,43 +1150,43 @@ BaseUtils.getSummaryExplanation = chart => {
|
|
|
1130
1150
|
type
|
|
1131
1151
|
} = config;
|
|
1132
1152
|
switch (type) {
|
|
1133
|
-
case
|
|
1134
|
-
case
|
|
1135
|
-
case
|
|
1136
|
-
case
|
|
1153
|
+
case CHART_TYPE.PIE:
|
|
1154
|
+
case CHART_TYPE.LINE:
|
|
1155
|
+
case CHART_TYPE.LINE_GROUP:
|
|
1156
|
+
case CHART_TYPE.RING:
|
|
1137
1157
|
{
|
|
1138
1158
|
return {
|
|
1139
|
-
count:
|
|
1140
|
-
advanced:
|
|
1159
|
+
count: intl.get('Count_the_number_of_records_in_each_group'),
|
|
1160
|
+
advanced: intl.get('Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field')
|
|
1141
1161
|
};
|
|
1142
1162
|
}
|
|
1143
|
-
case
|
|
1144
|
-
case
|
|
1163
|
+
case CHART_TYPE.BAR:
|
|
1164
|
+
case CHART_TYPE.BAR_GROUP:
|
|
1145
1165
|
{
|
|
1146
1166
|
return {
|
|
1147
|
-
count:
|
|
1148
|
-
advanced:
|
|
1167
|
+
count: intl.get('Group_the_records_according_to_the_vertical_axis_and_count_the_records_in_each_group'),
|
|
1168
|
+
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
1169
|
};
|
|
1150
1170
|
}
|
|
1151
1171
|
default:
|
|
1152
1172
|
{
|
|
1153
1173
|
return {
|
|
1154
|
-
count:
|
|
1155
|
-
advanced:
|
|
1174
|
+
count: intl.get('Count_the_records'),
|
|
1175
|
+
advanced: intl.get('Compute_sum_max_min')
|
|
1156
1176
|
};
|
|
1157
1177
|
}
|
|
1158
1178
|
}
|
|
1159
1179
|
};
|
|
1160
1180
|
BaseUtils.getLabelFontSize = labelFontSize => {
|
|
1161
|
-
return
|
|
1181
|
+
return isNumber(labelFontSize) ? labelFontSize : DEFAULT_LABEL_FONT_SIZE;
|
|
1162
1182
|
};
|
|
1163
1183
|
BaseUtils.imEmptyChartResult = chartResult => {
|
|
1164
1184
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1165
1185
|
};
|
|
1166
1186
|
BaseUtils.getPrecisionNumber = (value, data) => {
|
|
1167
|
-
const valueString =
|
|
1187
|
+
const valueString = getPrecisionNumber(value, data);
|
|
1168
1188
|
const valueNumber = parseFloat(valueString);
|
|
1169
|
-
return
|
|
1189
|
+
return isNumber(valueNumber) ? valueNumber : 0;
|
|
1170
1190
|
};
|
|
1171
1191
|
BaseUtils.isValidCellValue = function (cellValue) {
|
|
1172
1192
|
let includeEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1178,7 +1198,7 @@ BaseUtils.convertConfig = config => {
|
|
|
1178
1198
|
const {
|
|
1179
1199
|
type
|
|
1180
1200
|
} = config;
|
|
1181
|
-
if (type ===
|
|
1201
|
+
if (type === CHART_TYPE.HORIZONTAL_BAR || type === CHART_TYPE.HORIZONTAL_GROUP_BAR || type === CHART_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
1182
1202
|
const {
|
|
1183
1203
|
vertical_axis_column_key,
|
|
1184
1204
|
vertical_axis_date_granularity,
|
|
@@ -1191,7 +1211,11 @@ BaseUtils.convertConfig = config => {
|
|
|
1191
1211
|
vertical_axis_label_position,
|
|
1192
1212
|
show_horizontal_axis_label,
|
|
1193
1213
|
horizontal_axis_label_position,
|
|
1194
|
-
horizontal_axis_label_color
|
|
1214
|
+
horizontal_axis_label_color,
|
|
1215
|
+
vertical_axis_label_font_size,
|
|
1216
|
+
vertical_axis_label_font_color,
|
|
1217
|
+
horizontal_axis_label_font_size,
|
|
1218
|
+
horizontal_axis_label_font_color
|
|
1195
1219
|
} = config;
|
|
1196
1220
|
const newConfig = {
|
|
1197
1221
|
x_axis_column_key: vertical_axis_column_key,
|
|
@@ -1203,8 +1227,12 @@ BaseUtils.convertConfig = config => {
|
|
|
1203
1227
|
y_axis_summary_column_key: horizontal_axis_column_key,
|
|
1204
1228
|
x_axis_show_label: show_vertical_axis_label,
|
|
1205
1229
|
x_axis_label_position: vertical_axis_label_position,
|
|
1230
|
+
x_axis_label_font_size: vertical_axis_label_font_size,
|
|
1231
|
+
x_axis_label_font_color: vertical_axis_label_font_color,
|
|
1206
1232
|
y_axis_show_label: show_horizontal_axis_label,
|
|
1207
1233
|
y_axis_label_position: horizontal_axis_label_position,
|
|
1234
|
+
y_axis_label_font_size: horizontal_axis_label_font_size,
|
|
1235
|
+
y_axis_label_font_color: horizontal_axis_label_font_color,
|
|
1208
1236
|
y_axis_label_color: horizontal_axis_label_color,
|
|
1209
1237
|
y_axis_auto_range: config.horizontal_axis_auto_range,
|
|
1210
1238
|
y_axis_max: config.horizontal_axis_max,
|
|
@@ -1217,24 +1245,24 @@ BaseUtils.convertConfig = config => {
|
|
|
1217
1245
|
};
|
|
1218
1246
|
BaseUtils.getSummaryType = config => {
|
|
1219
1247
|
switch (config.type) {
|
|
1220
|
-
case
|
|
1221
|
-
case
|
|
1222
|
-
case
|
|
1248
|
+
case CHART_TYPE.HORIZONTAL_BAR:
|
|
1249
|
+
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
1250
|
+
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1223
1251
|
{
|
|
1224
1252
|
return config.horizontal_axis_summary_type;
|
|
1225
1253
|
}
|
|
1226
|
-
case
|
|
1227
|
-
case
|
|
1228
|
-
case
|
|
1229
|
-
case
|
|
1230
|
-
case
|
|
1231
|
-
case
|
|
1232
|
-
case
|
|
1233
|
-
case
|
|
1254
|
+
case CHART_TYPE.BAR:
|
|
1255
|
+
case CHART_TYPE.BAR_GROUP:
|
|
1256
|
+
case CHART_TYPE.BAR_STACK:
|
|
1257
|
+
case CHART_TYPE.LINE:
|
|
1258
|
+
case CHART_TYPE.LINE_GROUP:
|
|
1259
|
+
case CHART_TYPE.AREA:
|
|
1260
|
+
case CHART_TYPE.AREA_GROUP:
|
|
1261
|
+
case CHART_TYPE.SCATTER:
|
|
1234
1262
|
{
|
|
1235
1263
|
return config.y_axis_summary_type;
|
|
1236
1264
|
}
|
|
1237
|
-
case
|
|
1265
|
+
case CHART_TYPE.TABLE:
|
|
1238
1266
|
default:
|
|
1239
1267
|
{
|
|
1240
1268
|
return config.summary_type;
|
|
@@ -1248,20 +1276,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1248
1276
|
data
|
|
1249
1277
|
} = column || {};
|
|
1250
1278
|
switch (type) {
|
|
1251
|
-
case
|
|
1279
|
+
case CellType.TEXT:
|
|
1252
1280
|
{
|
|
1253
1281
|
return cellValue || null;
|
|
1254
1282
|
}
|
|
1255
|
-
case
|
|
1283
|
+
case CellType.NUMBER:
|
|
1256
1284
|
{
|
|
1257
1285
|
if (!cellValue && cellValue !== 0) {
|
|
1258
1286
|
return null;
|
|
1259
1287
|
}
|
|
1260
|
-
const number =
|
|
1288
|
+
const number = getPrecisionNumber(cellValue, data);
|
|
1261
1289
|
let valueNumber = parseFloat(number);
|
|
1262
|
-
return
|
|
1290
|
+
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
1263
1291
|
}
|
|
1264
|
-
case
|
|
1292
|
+
case CellType.SINGLE_SELECT:
|
|
1265
1293
|
{
|
|
1266
1294
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
1267
1295
|
if (isInvalidValue) {
|
|
@@ -1269,20 +1297,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1269
1297
|
}
|
|
1270
1298
|
return cellValue;
|
|
1271
1299
|
}
|
|
1272
|
-
case
|
|
1273
|
-
case
|
|
1274
|
-
case
|
|
1300
|
+
case CellType.DATE:
|
|
1301
|
+
case CellType.CTIME:
|
|
1302
|
+
case CellType.MTIME:
|
|
1275
1303
|
{
|
|
1276
1304
|
if (!dateGranularity) {
|
|
1277
|
-
return
|
|
1305
|
+
return getDateDisplayString(cellValue);
|
|
1278
1306
|
}
|
|
1279
|
-
const firstDayOfWeek =
|
|
1307
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1280
1308
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
1281
|
-
return
|
|
1309
|
+
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1282
1310
|
}
|
|
1283
|
-
return
|
|
1311
|
+
return DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1284
1312
|
}
|
|
1285
|
-
case
|
|
1313
|
+
case CellType.MULTIPLE_SELECT:
|
|
1286
1314
|
{
|
|
1287
1315
|
let options = data && data.options;
|
|
1288
1316
|
if (!Array.isArray(cellValue)) {
|
|
@@ -1291,18 +1319,18 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1291
1319
|
const newCellValue = cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
1292
1320
|
return newCellValue.sort();
|
|
1293
1321
|
}
|
|
1294
|
-
case
|
|
1322
|
+
case CellType.COLLABORATOR:
|
|
1295
1323
|
{
|
|
1296
1324
|
if (!Array.isArray(cellValue)) return [];
|
|
1297
|
-
return cellValue.filter(email =>
|
|
1325
|
+
return cellValue.filter(email => isValidCollaboratorEmail(email));
|
|
1298
1326
|
}
|
|
1299
|
-
case
|
|
1300
|
-
case
|
|
1327
|
+
case CellType.CREATOR:
|
|
1328
|
+
case CellType.LAST_MODIFIER:
|
|
1301
1329
|
{
|
|
1302
1330
|
return cellValue ? cellValue : null;
|
|
1303
1331
|
}
|
|
1304
|
-
case
|
|
1305
|
-
case
|
|
1332
|
+
case CellType.LINK_FORMULA:
|
|
1333
|
+
case CellType.FORMULA:
|
|
1306
1334
|
{
|
|
1307
1335
|
if (!formulaRow) return '';
|
|
1308
1336
|
let formulaCellValue = formulaRow[key];
|
|
@@ -1310,34 +1338,34 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1310
1338
|
result_type,
|
|
1311
1339
|
array_type
|
|
1312
1340
|
} = data || {};
|
|
1313
|
-
if (result_type ===
|
|
1341
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1314
1342
|
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1315
1343
|
const dateCellValue = formulaCellValue[0];
|
|
1316
|
-
if (!dateGranularity) return
|
|
1317
|
-
const firstDayOfWeek =
|
|
1318
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return
|
|
1319
|
-
return
|
|
1344
|
+
if (!dateGranularity) return getDateDisplayString(dateCellValue);
|
|
1345
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1346
|
+
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR', firstDayOfWeek);
|
|
1347
|
+
return DateUtils.getDateByGranularity(dateCellValue, dateGranularity, firstDayOfWeek);
|
|
1320
1348
|
}
|
|
1321
|
-
return
|
|
1349
|
+
return getFormulaDisplayString(formulaCellValue, data, {
|
|
1322
1350
|
tables: value.tables
|
|
1323
1351
|
}) || null;
|
|
1324
1352
|
}
|
|
1325
|
-
if (result_type ===
|
|
1326
|
-
return
|
|
1353
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1354
|
+
return getPrecisionNumber(formulaCellValue, data);
|
|
1327
1355
|
}
|
|
1328
1356
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
1329
1357
|
}
|
|
1330
|
-
case
|
|
1358
|
+
case CellType.GEOLOCATION:
|
|
1331
1359
|
{
|
|
1332
1360
|
const {
|
|
1333
1361
|
geo_format
|
|
1334
1362
|
} = data || {};
|
|
1335
1363
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
1336
|
-
return
|
|
1364
|
+
return getGeolocationDisplayString(cellValue, data);
|
|
1337
1365
|
}
|
|
1338
1366
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
1339
1367
|
}
|
|
1340
|
-
case
|
|
1368
|
+
case CellType.LINK:
|
|
1341
1369
|
{
|
|
1342
1370
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
1343
1371
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -1345,11 +1373,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1345
1373
|
}
|
|
1346
1374
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
1347
1375
|
}
|
|
1348
|
-
case
|
|
1376
|
+
case CellType.CHECKBOX:
|
|
1349
1377
|
{
|
|
1350
1378
|
return String(!!cellValue);
|
|
1351
1379
|
}
|
|
1352
|
-
case
|
|
1380
|
+
case CellType.RATE:
|
|
1353
1381
|
{
|
|
1354
1382
|
if (!cellValue) return null;
|
|
1355
1383
|
return cellValue + '';
|
|
@@ -1365,9 +1393,9 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1365
1393
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1366
1394
|
let rowsLength = rows.length;
|
|
1367
1395
|
let total;
|
|
1368
|
-
if (summary_type ===
|
|
1396
|
+
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1369
1397
|
total = rowsLength;
|
|
1370
|
-
} else if (summary_type ===
|
|
1398
|
+
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1371
1399
|
switch (summary_method) {
|
|
1372
1400
|
case 'Distinct_values':
|
|
1373
1401
|
{
|
|
@@ -1375,7 +1403,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1375
1403
|
let existMap = {};
|
|
1376
1404
|
rows.forEach(r => {
|
|
1377
1405
|
let num;
|
|
1378
|
-
if (
|
|
1406
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1379
1407
|
const formulaRow = formula_rows[r._id] || {};
|
|
1380
1408
|
num = formulaRow[summary_column_key];
|
|
1381
1409
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -1404,14 +1432,14 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1404
1432
|
let validNumbersCount = 0;
|
|
1405
1433
|
rows.forEach(r => {
|
|
1406
1434
|
let num;
|
|
1407
|
-
if (
|
|
1435
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1408
1436
|
let formulaRow = formula_rows[r._id] || {};
|
|
1409
1437
|
num = formulaRow[summary_column_key];
|
|
1410
1438
|
num = Array.isArray(num) ? num[0] : num;
|
|
1411
1439
|
} else {
|
|
1412
1440
|
num = r[summary_column_key];
|
|
1413
1441
|
}
|
|
1414
|
-
if (
|
|
1442
|
+
if (isNumber(num)) {
|
|
1415
1443
|
validNumbersCount++;
|
|
1416
1444
|
sum += num;
|
|
1417
1445
|
}
|
|
@@ -1429,7 +1457,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1429
1457
|
if (rowsLength > 0) {
|
|
1430
1458
|
let result = rows.reduce((current, next) => {
|
|
1431
1459
|
let currentValue, nextValue;
|
|
1432
|
-
if (
|
|
1460
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1433
1461
|
let currentFormulaRow = formula_rows[current._id];
|
|
1434
1462
|
let nextFormulaRow = formula_rows[next._id];
|
|
1435
1463
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -1440,7 +1468,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1440
1468
|
currentValue = current[summary_column_key];
|
|
1441
1469
|
nextValue = next[summary_column_key];
|
|
1442
1470
|
}
|
|
1443
|
-
if (
|
|
1471
|
+
if (isEmpty(nextValue)) {
|
|
1444
1472
|
return current;
|
|
1445
1473
|
}
|
|
1446
1474
|
let isNextGreater = currentValue < nextValue;
|
|
@@ -1450,7 +1478,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1450
1478
|
return isNextGreater ? next : current;
|
|
1451
1479
|
}
|
|
1452
1480
|
});
|
|
1453
|
-
if (
|
|
1481
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1454
1482
|
let formulaRow = formula_rows[result._id];
|
|
1455
1483
|
total = formulaRow && formulaRow[summary_column_key];
|
|
1456
1484
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -1472,42 +1500,42 @@ BaseUtils.getFormattedValue = (value, column, summaryMethod) => {
|
|
|
1472
1500
|
if (!column) {
|
|
1473
1501
|
return value;
|
|
1474
1502
|
}
|
|
1475
|
-
if (summaryMethod ===
|
|
1503
|
+
if (summaryMethod === CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
|
|
1476
1504
|
return value;
|
|
1477
1505
|
}
|
|
1478
1506
|
const {
|
|
1479
1507
|
type,
|
|
1480
1508
|
data
|
|
1481
1509
|
} = column;
|
|
1482
|
-
if (
|
|
1483
|
-
return
|
|
1510
|
+
if (isNumericColumn(column)) {
|
|
1511
|
+
return getNumberDisplayString(value, data);
|
|
1484
1512
|
}
|
|
1485
|
-
if (
|
|
1486
|
-
return
|
|
1513
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
1514
|
+
return getClientFormulaDisplayString(value, data);
|
|
1487
1515
|
}
|
|
1488
1516
|
return value;
|
|
1489
1517
|
};
|
|
1490
1518
|
BaseUtils.getSummaryResult = function (results, summaryMethod) {
|
|
1491
1519
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
1492
|
-
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res =>
|
|
1520
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => isNumber(res)) : [];
|
|
1493
1521
|
switch (summaryMethod) {
|
|
1494
|
-
case
|
|
1522
|
+
case CHART_SUMMARY_TYPE.MAX:
|
|
1495
1523
|
{
|
|
1496
1524
|
return _BaseUtils.getMax(numericResults);
|
|
1497
1525
|
}
|
|
1498
|
-
case
|
|
1526
|
+
case CHART_SUMMARY_TYPE.MIN:
|
|
1499
1527
|
{
|
|
1500
1528
|
return _BaseUtils.getMin(numericResults);
|
|
1501
1529
|
}
|
|
1502
|
-
case
|
|
1530
|
+
case CHART_SUMMARY_TYPE.SUM:
|
|
1503
1531
|
{
|
|
1504
1532
|
return _BaseUtils.getSum(numericResults, precision);
|
|
1505
1533
|
}
|
|
1506
|
-
case
|
|
1534
|
+
case CHART_SUMMARY_TYPE.MEAN:
|
|
1507
1535
|
{
|
|
1508
1536
|
return _BaseUtils.getMean(numericResults, precision);
|
|
1509
1537
|
}
|
|
1510
|
-
case
|
|
1538
|
+
case CHART_SUMMARY_TYPE.Distinct_values:
|
|
1511
1539
|
{
|
|
1512
1540
|
let count = 0;
|
|
1513
1541
|
let existMap = {};
|
|
@@ -1556,15 +1584,15 @@ BaseUtils.getMean = function (list) {
|
|
|
1556
1584
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
1557
1585
|
};
|
|
1558
1586
|
BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
|
|
1559
|
-
const currentTime = (
|
|
1587
|
+
const currentTime = dayjs();
|
|
1560
1588
|
const days = duration === 'days_30' ? 30 : 7;
|
|
1561
1589
|
// set date to start of the day
|
|
1562
1590
|
const formattedEndDate = currentTime.format('YYYY-MM-DD');
|
|
1563
1591
|
const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
1564
|
-
const formattedStartDate = (
|
|
1565
|
-
const endDate = (
|
|
1566
|
-
const middleDate = (
|
|
1567
|
-
const startDate = (
|
|
1592
|
+
const formattedStartDate = dayjs(formattedMiddleDate).subtract(days, 'days').format('YYYY-MM-DD');
|
|
1593
|
+
const endDate = dayjs(formattedEndDate);
|
|
1594
|
+
const middleDate = dayjs(formattedMiddleDate);
|
|
1595
|
+
const startDate = dayjs(formattedStartDate);
|
|
1568
1596
|
let compareValue = [];
|
|
1569
1597
|
let comparedValue = [];
|
|
1570
1598
|
if (useDataDb) {
|
|
@@ -1572,7 +1600,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1572
1600
|
const days2 = [];
|
|
1573
1601
|
for (let index = 0; index < result.length; index++) {
|
|
1574
1602
|
const item = result[index];
|
|
1575
|
-
const key = (
|
|
1603
|
+
const key = dayjs(item[dbDateKey]);
|
|
1576
1604
|
if (!key.isValid()) continue;
|
|
1577
1605
|
if (key >= startDate && key < middleDate) {
|
|
1578
1606
|
comparedValue.push(item[valueKey]);
|
|
@@ -1601,7 +1629,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1601
1629
|
// }
|
|
1602
1630
|
// }
|
|
1603
1631
|
// }
|
|
1604
|
-
if (summaryType ===
|
|
1632
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1605
1633
|
comparedValue = _BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
1606
1634
|
compareValue = _BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
1607
1635
|
} else {
|
|
@@ -1627,13 +1655,13 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1627
1655
|
sqlColumnGroupbyColumnKey
|
|
1628
1656
|
} = chartSQLMap;
|
|
1629
1657
|
let newSqlRows = JSON.parse(JSON.stringify(sqlRows));
|
|
1630
|
-
if (config.summary_type ===
|
|
1658
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1631
1659
|
// has column group
|
|
1632
1660
|
if (sqlColumnGroupbyColumnKey) {
|
|
1633
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1661
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1634
1662
|
return newSqlRows;
|
|
1635
1663
|
}
|
|
1636
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1664
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1637
1665
|
return newSqlRows;
|
|
1638
1666
|
}
|
|
1639
1667
|
}
|
|
@@ -1659,7 +1687,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1659
1687
|
newSqlRows = Object.values(collaboratorsRowsMap);
|
|
1660
1688
|
}
|
|
1661
1689
|
}
|
|
1662
|
-
if (config.summary_type ===
|
|
1690
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1663
1691
|
let summarySQLColumnName2ColumnKeys;
|
|
1664
1692
|
if (summarySQLColumnName2ColumnKey) {
|
|
1665
1693
|
summarySQLColumnName2ColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
@@ -1672,10 +1700,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1672
1700
|
|
|
1673
1701
|
// has column group
|
|
1674
1702
|
if (sqlColumnGroupbyColumnKey) {
|
|
1675
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1703
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1676
1704
|
return newSqlRows;
|
|
1677
1705
|
}
|
|
1678
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1706
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1679
1707
|
return newSqlRows;
|
|
1680
1708
|
}
|
|
1681
1709
|
|
|
@@ -1817,16 +1845,16 @@ BaseUtils.getDateGranularityByType = chart => {
|
|
|
1817
1845
|
const {
|
|
1818
1846
|
type
|
|
1819
1847
|
} = chart;
|
|
1820
|
-
if ([
|
|
1848
|
+
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
1849
|
return chart['x_axis_date_granularity'];
|
|
1822
1850
|
}
|
|
1823
|
-
if ([
|
|
1851
|
+
if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
|
|
1824
1852
|
return chart['date_granularity'];
|
|
1825
1853
|
}
|
|
1826
|
-
if ([
|
|
1854
|
+
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1827
1855
|
return chart['vertical_axis_date_granularity'];
|
|
1828
1856
|
}
|
|
1829
|
-
if ([
|
|
1857
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1830
1858
|
return chart['groupby_date_granularity'];
|
|
1831
1859
|
}
|
|
1832
1860
|
return null;
|
|
@@ -1877,13 +1905,13 @@ BaseUtils.isCollaboratorColumnOrMultipleColumn = columnMap => {
|
|
|
1877
1905
|
columnGroupbyColumn,
|
|
1878
1906
|
groupbyColumn
|
|
1879
1907
|
} = columnMap || {};
|
|
1880
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1908
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1881
1909
|
return true;
|
|
1882
1910
|
}
|
|
1883
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1911
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1884
1912
|
return true;
|
|
1885
1913
|
}
|
|
1886
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) ===
|
|
1914
|
+
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
1915
|
return true;
|
|
1888
1916
|
}
|
|
1889
1917
|
return false;
|
|
@@ -1897,10 +1925,10 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1897
1925
|
} = chart.config;
|
|
1898
1926
|
if (!column_groupby_multiple_numeric_column) {
|
|
1899
1927
|
if (groupColumn) {
|
|
1900
|
-
if ([
|
|
1928
|
+
if ([CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1901
1929
|
data.forEach(item => {
|
|
1902
1930
|
const option = groupColumn.data.options.find(option => option.name === item[groupKey]);
|
|
1903
|
-
if (option
|
|
1931
|
+
if (option === null || option === void 0 ? void 0 : option.id) {
|
|
1904
1932
|
item['group_name_id'] = option.id;
|
|
1905
1933
|
item['oldName'] = item.name;
|
|
1906
1934
|
item.name = item['group_name_id'];
|
|
@@ -1920,4 +1948,4 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1920
1948
|
}
|
|
1921
1949
|
return data;
|
|
1922
1950
|
};
|
|
1923
|
-
|
|
1951
|
+
export default BaseUtils;
|