sea-chart 2.0.37 → 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 +20 -69
- package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
- 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 +31 -37
- 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 +41 -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 +12 -23
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +11 -24
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +13 -16
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +28 -38
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +58 -69
- 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 +61 -68
- package/dist/components/tooltip/index.js +39 -28
- 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 +13 -16
- 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 +2 -7
- package/dist/locale/lang/en.js +2 -7
- package/dist/locale/lang/es.js +2 -7
- package/dist/locale/lang/fr.js +2 -7
- package/dist/locale/lang/pt.js +2 -7
- package/dist/locale/lang/ru.js +2 -7
- package/dist/locale/lang/zh_CN.js +2 -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 +14 -17
- 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 +14 -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 +66 -73
- 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 +51 -59
- package/dist/settings/basic-number-card/data-settings.js +50 -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 -64
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +67 -75
- 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 +44 -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 +22 -30
- 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 +57 -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 +49 -58
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.css +1 -31
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +113 -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 +44 -52
- 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 +59 -66
- 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 +27 -34
- package/dist/settings/widgets/data-filter/index.js +59 -59
- 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 +52 -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 +75 -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 +65 -72
- package/dist/utils/cell-format-utils.js +25 -33
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +467 -367
- package/dist/utils/chart-utils/index.js +29 -40
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +78 -85
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -21
- 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 +28 -26
- 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 +94 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -25
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +50 -36
- package/dist/utils/chart-utils/sql-statistics-utils.js +385 -388
- 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 +88 -102
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +7 -11
- 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 +73 -219
- 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 +251 -183
- 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 +162 -172
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +50 -45
- package/dist/view/index.css +2 -8
- package/dist/view/index.js +102 -103
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +57 -57
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +56 -48
- package/dist/view/wrapper/bar-custom-stack.js +73 -55
- package/dist/view/wrapper/bar-group.js +94 -73
- package/dist/view/wrapper/bar-stack.js +49 -57
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +50 -34
- package/dist/view/wrapper/chart-component.js +164 -569
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +140 -93
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +104 -59
- 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 +70 -58
- package/dist/view/wrapper/horizontal-bar-stack.js +48 -56
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +49 -52
- 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 +40 -47
- package/dist/view/wrapper/map-world.js +42 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +45 -53
- package/dist/view/wrapper/ring.js +50 -58
- package/dist/view/wrapper/scatter.js +50 -56
- 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 -92
- 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 -16
- 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 +8 -13
- 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 +30 -43
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +80 -65
- package/package.json +15 -12
|
@@ -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,77 +83,93 @@ 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);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// completeness chart requires groupby_column_key, completed_column_key, and target_column_key
|
|
118
|
+
if (config.type === CHART_TYPE.COMPLETENESS || config.type === CHART_TYPE.COMPLETENESS_GROUP) {
|
|
119
|
+
const {
|
|
120
|
+
groupby_column_key,
|
|
121
|
+
completed_column_key,
|
|
122
|
+
target_column_key
|
|
123
|
+
} = config;
|
|
124
|
+
if (!groupby_column_key) return false;
|
|
125
|
+
if (!completed_column_key) return false;
|
|
126
|
+
if (!target_column_key) return false;
|
|
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;
|
|
130
|
+
return true;
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
// if current chart is using "groupby_column_key" as key
|
|
126
134
|
// if groupby_column_key is null, still return false
|
|
127
135
|
let groupByColumnKey = config.groupby_column_key || config.x_axis_column_key || config.vertical_axis_column_key || config.columnKey || config.date_column_key;
|
|
128
|
-
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)) {
|
|
129
137
|
groupByColumnKey = config.x_axis_column_key;
|
|
130
138
|
}
|
|
131
|
-
if ([
|
|
139
|
+
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(config.type)) {
|
|
132
140
|
groupByColumnKey = config.vertical_axis_column_key;
|
|
133
141
|
}
|
|
134
|
-
if ([
|
|
142
|
+
if ([CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(config.type)) {
|
|
135
143
|
groupByColumnKey = config.geo_column_key;
|
|
136
144
|
}
|
|
137
|
-
if ([
|
|
145
|
+
if ([CHART_TYPE.HEAT_MAP].includes(config.type)) {
|
|
138
146
|
groupByColumnKey = config.time_column_key;
|
|
139
147
|
}
|
|
140
|
-
if ([
|
|
148
|
+
if ([CHART_TYPE.MIRROR].includes(config.type)) {
|
|
141
149
|
groupByColumnKey = config.column_key;
|
|
142
150
|
}
|
|
143
|
-
if ([
|
|
151
|
+
if ([CHART_TYPE.TREND].includes(config.type)) {
|
|
144
152
|
groupByColumnKey = config.date_column_key;
|
|
145
153
|
}
|
|
146
154
|
if (!groupByColumnKey) return false;
|
|
147
|
-
if (!
|
|
148
|
-
if (type ===
|
|
149
|
-
const column =
|
|
150
|
-
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;
|
|
151
159
|
}
|
|
152
|
-
if (type ===
|
|
160
|
+
if (type === CHART_TYPE.COMBINATION) {
|
|
153
161
|
const isExist = _BaseUtils.isValidCombinationChart(config, table);
|
|
154
162
|
if (!isExist) return false;
|
|
155
163
|
} else {
|
|
156
164
|
let summaryColumnKey = config.summary_column_key || config.y_axis_summary_column_key || config.horizontal_axis_column_key;
|
|
157
|
-
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) {
|
|
158
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"
|
|
159
167
|
summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
|
|
160
168
|
}
|
|
161
|
-
const summaryType =
|
|
162
|
-
if (summaryType ===
|
|
169
|
+
const summaryType = _BaseUtils.getSummaryType(config);
|
|
170
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
163
171
|
if (summaryColumnKey) {
|
|
164
|
-
return
|
|
172
|
+
return getTableColumnByKey(table, summaryColumnKey);
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
return true;
|
|
@@ -174,34 +182,34 @@ BaseUtils.getGroupColumn = (table, chart) => {
|
|
|
174
182
|
const {
|
|
175
183
|
type
|
|
176
184
|
} = config;
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
185
|
+
if (COMPLTETELESS_CHART_TYPES.includes(type)) {
|
|
186
|
+
return getTableColumnByKey(table, config.completed_column_key);
|
|
179
187
|
}
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
188
|
+
if (HORIZONTAL_BAR_CHART_TYPES.includes(type)) {
|
|
189
|
+
return getTableColumnByKey(table, config.vertical_axis_column_key);
|
|
182
190
|
}
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
191
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
192
|
+
return getTableColumnByKey(table, config.groupby_column_key);
|
|
185
193
|
}
|
|
186
|
-
if (type ===
|
|
187
|
-
return
|
|
194
|
+
if (type === CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
195
|
+
return getTableColumnByKey(table, config.numeric_column_key);
|
|
188
196
|
}
|
|
189
|
-
if ([
|
|
190
|
-
return
|
|
197
|
+
if ([CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
198
|
+
return getTableColumnByKey(table, config.geo_column_key);
|
|
191
199
|
}
|
|
192
|
-
if (type ===
|
|
193
|
-
return
|
|
200
|
+
if (type === CHART_TYPE.MIRROR) {
|
|
201
|
+
return getTableColumnByKey(table, config.column_key);
|
|
194
202
|
}
|
|
195
|
-
if (type ===
|
|
196
|
-
return
|
|
203
|
+
if (type === CHART_TYPE.TREND) {
|
|
204
|
+
return getTableColumnByKey(table, config.date_column_key);
|
|
197
205
|
}
|
|
198
|
-
if (type ===
|
|
199
|
-
return
|
|
206
|
+
if (type === CHART_TYPE.HEAT_MAP) {
|
|
207
|
+
return getTableColumnByKey(table, config.time_column_key);
|
|
200
208
|
}
|
|
201
|
-
if (
|
|
202
|
-
return
|
|
209
|
+
if (MAP_CHART_TYPES.includes(type)) {
|
|
210
|
+
return getTableColumnByKey(table, config.geo_column_key);
|
|
203
211
|
}
|
|
204
|
-
return
|
|
212
|
+
return getTableColumnByKey(table, config.x_axis_column_key);
|
|
205
213
|
};
|
|
206
214
|
BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
207
215
|
const {
|
|
@@ -210,19 +218,19 @@ BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
|
210
218
|
const {
|
|
211
219
|
type
|
|
212
220
|
} = config;
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
221
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
222
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
215
223
|
}
|
|
216
|
-
if ([
|
|
217
|
-
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);
|
|
218
226
|
}
|
|
219
|
-
if ([
|
|
220
|
-
return
|
|
227
|
+
if ([CHART_TYPE.MIRROR].includes(type)) {
|
|
228
|
+
return getTableColumnByKey(table, config.group_column_key);
|
|
221
229
|
}
|
|
222
|
-
if (type ===
|
|
223
|
-
return
|
|
230
|
+
if (type === CHART_TYPE.SCATTER) {
|
|
231
|
+
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
224
232
|
}
|
|
225
|
-
return
|
|
233
|
+
return getTableColumnByKey(table, config.y_axis_summary_column_key);
|
|
226
234
|
};
|
|
227
235
|
BaseUtils.getSummaryColumn = (table, chart) => {
|
|
228
236
|
const {
|
|
@@ -236,39 +244,39 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
236
244
|
horizontal_axis_column_key
|
|
237
245
|
} = config;
|
|
238
246
|
switch (type) {
|
|
239
|
-
case
|
|
240
|
-
case
|
|
247
|
+
case CHART_TYPE.COMPLETENESS:
|
|
248
|
+
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
241
249
|
{
|
|
242
|
-
return
|
|
250
|
+
return getTableColumnByKey(table, config.target_column_key);
|
|
243
251
|
}
|
|
244
|
-
case
|
|
245
|
-
case
|
|
246
|
-
case
|
|
252
|
+
case CHART_TYPE.HORIZONTAL_BAR:
|
|
253
|
+
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
254
|
+
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
247
255
|
{
|
|
248
|
-
return
|
|
256
|
+
return getTableColumnByKey(table, horizontal_axis_column_key);
|
|
249
257
|
}
|
|
250
|
-
case
|
|
251
|
-
case
|
|
252
|
-
case
|
|
253
|
-
case
|
|
254
|
-
case
|
|
255
|
-
case
|
|
256
|
-
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:
|
|
257
265
|
{
|
|
258
|
-
return
|
|
266
|
+
return getTableColumnByKey(table, y_axis_summary_column_key);
|
|
259
267
|
}
|
|
260
|
-
case
|
|
268
|
+
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
261
269
|
{
|
|
262
|
-
return
|
|
270
|
+
return getTableColumnByKey(table, numeric_column_key);
|
|
263
271
|
}
|
|
264
|
-
case
|
|
272
|
+
case CHART_TYPE.SCATTER:
|
|
265
273
|
{
|
|
266
|
-
return
|
|
274
|
+
return getTableColumnByKey(table, config.y_axis_column_key);
|
|
267
275
|
}
|
|
268
|
-
case
|
|
276
|
+
case CHART_TYPE.COMBINATION:
|
|
269
277
|
{
|
|
270
|
-
const summaryColumnLeft =
|
|
271
|
-
const summaryColumnRight =
|
|
278
|
+
const summaryColumnLeft = getTableColumnByKey(table, config.y_axis_left_summary_column);
|
|
279
|
+
const summaryColumnRight = getTableColumnByKey(table, config.y_axis_right_summary_column);
|
|
272
280
|
return {
|
|
273
281
|
summaryColumnLeft,
|
|
274
282
|
summaryColumnRight
|
|
@@ -276,7 +284,7 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
276
284
|
}
|
|
277
285
|
default:
|
|
278
286
|
{
|
|
279
|
-
return
|
|
287
|
+
return getTableColumnByKey(table, summary_column_key);
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
};
|
|
@@ -302,7 +310,7 @@ BaseUtils.getSummaryColumnsWithMethod = (table, chart) => {
|
|
|
302
310
|
summary_method
|
|
303
311
|
} = summaryItem;
|
|
304
312
|
return {
|
|
305
|
-
column:
|
|
313
|
+
column: getTableColumnByKey(table, columnKey),
|
|
306
314
|
summary_method
|
|
307
315
|
};
|
|
308
316
|
});
|
|
@@ -311,7 +319,7 @@ BaseUtils.getGroupName = (tables, chart) => {
|
|
|
311
319
|
const {
|
|
312
320
|
config
|
|
313
321
|
} = chart;
|
|
314
|
-
const table =
|
|
322
|
+
const table = getTableById(tables, config.table_id);
|
|
315
323
|
const column = _BaseUtils.getGroupColumn(table, chart);
|
|
316
324
|
return column.name;
|
|
317
325
|
};
|
|
@@ -358,24 +366,24 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
|
|
|
358
366
|
};
|
|
359
367
|
|
|
360
368
|
// The date returned by db carries T and Z, so that there is a time difference in data formatting
|
|
361
|
-
return
|
|
369
|
+
return getDateDisplayString(summaryValue.replace(/[T|Z]/g, ' '), format);
|
|
362
370
|
}
|
|
363
|
-
if (typeof summaryValue !== 'number') return
|
|
364
|
-
return
|
|
371
|
+
if (typeof summaryValue !== 'number') return formatRowTotal(summaryValue);
|
|
372
|
+
return getNumberDisplayString(summaryValue, data || DEFAULT_NUMBER_FORMAT_OBJECT);
|
|
365
373
|
};
|
|
366
374
|
BaseUtils.isNumericSummaryColumn = summaryColumn => {
|
|
367
375
|
if (!summaryColumn) return false;
|
|
368
376
|
const {
|
|
369
377
|
type
|
|
370
378
|
} = summaryColumn;
|
|
371
|
-
return type !==
|
|
379
|
+
return type !== CellType.LINK && isNumericColumn(summaryColumn);
|
|
372
380
|
};
|
|
373
381
|
BaseUtils.isDateSummaryColumn = summaryColumn => {
|
|
374
382
|
if (!summaryColumn) return false;
|
|
375
383
|
const {
|
|
376
384
|
type
|
|
377
385
|
} = summaryColumn;
|
|
378
|
-
return type !==
|
|
386
|
+
return type !== CellType.LINK && isDateColumn(summaryColumn);
|
|
379
387
|
};
|
|
380
388
|
BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) => {
|
|
381
389
|
let {
|
|
@@ -385,14 +393,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) =
|
|
|
385
393
|
if (_BaseUtils.isDateSummaryColumn(summaryColumn)) {
|
|
386
394
|
if (summaryMethod === 'MAX') {
|
|
387
395
|
if (currentValue && nextValue) {
|
|
388
|
-
return (
|
|
396
|
+
return dayjs(currentValue).isBefore(nextValue) ? nextValue : currentValue;
|
|
389
397
|
}
|
|
390
398
|
if (!currentValue && nextValue) return nextValue;
|
|
391
399
|
return currentValue;
|
|
392
400
|
}
|
|
393
401
|
if (summaryMethod === 'MIN') {
|
|
394
402
|
if (currentValue && nextValue) {
|
|
395
|
-
return (
|
|
403
|
+
return dayjs(currentValue).isBefore(nextValue) ? currentValue : nextValue;
|
|
396
404
|
}
|
|
397
405
|
if (!currentValue && nextValue) return nextValue;
|
|
398
406
|
return currentValue;
|
|
@@ -418,7 +426,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
418
426
|
let {
|
|
419
427
|
columns
|
|
420
428
|
} = table;
|
|
421
|
-
let unStatisticalColumns = [
|
|
429
|
+
let unStatisticalColumns = [CellType.LONG_TEXT, CellType.IMAGE, CellType.FILE, CellType.CHECKBOX];
|
|
422
430
|
return columns.filter(column => {
|
|
423
431
|
return unStatisticalColumns.indexOf(column.type) === -1;
|
|
424
432
|
});
|
|
@@ -426,7 +434,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
426
434
|
BaseUtils.isChartEqual = (preChartElement, curChartElement) => {
|
|
427
435
|
const elementType = preChartElement.config.type;
|
|
428
436
|
if (elementType !== curChartElement.config.type) return false;
|
|
429
|
-
return (
|
|
437
|
+
return shallowEqual(preChartElement.config, curChartElement.config);
|
|
430
438
|
};
|
|
431
439
|
BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
432
440
|
var _preChartElement$heig, _curChartElement$heig;
|
|
@@ -438,10 +446,10 @@ BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
|
438
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;
|
|
439
447
|
const hasStyleConfig = preChartElement.style_config && curChartElement.style_config;
|
|
440
448
|
if (hasStyleConfig) {
|
|
441
|
-
const chartStyleConfigChanged =
|
|
449
|
+
const chartStyleConfigChanged = CHART_STYLE_CONFIG_SETTING_KEYS.some(key => preChartElement.style_config[key] !== curChartElement.style_config[key]);
|
|
442
450
|
return chartStyleConfigChanged;
|
|
443
451
|
}
|
|
444
|
-
return !
|
|
452
|
+
return !CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
445
453
|
};
|
|
446
454
|
BaseUtils.isChartTypeChange = (preChartElement, curChartElement) => {
|
|
447
455
|
const elementType = preChartElement.config.type;
|
|
@@ -459,9 +467,9 @@ BaseUtils.isArchiveView = (chart, tables) => {
|
|
|
459
467
|
table_id,
|
|
460
468
|
view_id
|
|
461
469
|
} = chart;
|
|
462
|
-
const table =
|
|
463
|
-
const view =
|
|
464
|
-
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);
|
|
465
473
|
};
|
|
466
474
|
BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
467
475
|
return preChartElement.config.sort_type !== curChartElement.config.sort_type;
|
|
@@ -469,7 +477,7 @@ BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
|
469
477
|
BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
470
478
|
const prevStyleConfig = prevElement && prevElement.style_config;
|
|
471
479
|
const currStyleConfig = currElement && currElement.style_config;
|
|
472
|
-
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))) {
|
|
473
481
|
return false;
|
|
474
482
|
}
|
|
475
483
|
if (!prevStyleConfig && !currStyleConfig) {
|
|
@@ -486,24 +494,24 @@ BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
|
486
494
|
border: currBorder,
|
|
487
495
|
title: currTitle
|
|
488
496
|
} = currStyleConfig;
|
|
489
|
-
return !(
|
|
497
|
+
return !shallowEqual(prevBorder, currBorder) || !shallowEqual(prevTitle, currTitle);
|
|
490
498
|
};
|
|
491
499
|
BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
492
500
|
return !_BaseUtils.isChartEqual(prevProps.chart, currentProps.chart) ||
|
|
493
501
|
// chart attributes changed
|
|
494
|
-
!(
|
|
502
|
+
!shallowEqual(prevProps.canvasStyle, currentProps.canvasStyle) ||
|
|
495
503
|
// canvasStyle
|
|
496
|
-
!(
|
|
504
|
+
!shallowEqual(prevProps.groupbyColumn, currentProps.groupbyColumn) ||
|
|
497
505
|
// groupbyColumn's data、type changed or not exist
|
|
498
|
-
!(
|
|
506
|
+
!shallowEqual(prevProps.columnGroupbyColumn, currentProps.columnGroupbyColumn) ||
|
|
499
507
|
// columnGroupbyColumn's data、type changed or not exist
|
|
500
|
-
!(
|
|
508
|
+
!shallowEqual(prevProps.summaryColumn, currentProps.summaryColumn) ||
|
|
501
509
|
// summaryColumn's data、type changed or not exist
|
|
502
|
-
!(
|
|
510
|
+
!shallowEqual(prevProps.globalTheme, currentProps.globalTheme) ||
|
|
503
511
|
// global theme changed
|
|
504
|
-
!(
|
|
512
|
+
!shallowEqual(prevProps.chartColorTheme, currentProps.chartColorTheme) ||
|
|
505
513
|
// chart color theme changed
|
|
506
|
-
!(
|
|
514
|
+
!shallowEqual(prevProps.resizeSignal, currentProps.resizeSignal) ||
|
|
507
515
|
// chart container resize changed
|
|
508
516
|
_BaseUtils._isChartDataChange(prevProps, currentProps) || _BaseUtils.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
509
517
|
};
|
|
@@ -520,7 +528,7 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
520
528
|
const {
|
|
521
529
|
result: oldData
|
|
522
530
|
} = currentProps;
|
|
523
|
-
if (chart.config.type ===
|
|
531
|
+
if (chart.config.type === CHART_TYPE.COMBINATION) {
|
|
524
532
|
return _BaseUtils._isCombinationDataChange(newData, oldData);
|
|
525
533
|
}
|
|
526
534
|
if (!newData && !oldData) return false;
|
|
@@ -539,28 +547,29 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
539
547
|
for (let j = 0; j < (newDataItemRows === null || newDataItemRows === void 0 ? void 0 : newDataItemRows.length) || 0; j++) {
|
|
540
548
|
let newDataItemRow = newDataItemRows[j];
|
|
541
549
|
let oldDataItemRow = oldDataItemRows[j];
|
|
542
|
-
if (!(
|
|
550
|
+
if (!shallowEqual(newDataItemRow, oldDataItemRow)) return true;
|
|
543
551
|
}
|
|
544
552
|
}
|
|
545
553
|
return false;
|
|
546
554
|
};
|
|
547
555
|
BaseUtils.getColumn = (tables, tableId, columnKey) => {
|
|
548
|
-
const table =
|
|
549
|
-
return
|
|
556
|
+
const table = getTableById(tables, tableId);
|
|
557
|
+
return getTableColumnByKey(table, columnKey);
|
|
550
558
|
};
|
|
551
559
|
BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) => {
|
|
552
560
|
if (!Array.isArray(dataList)) return [];
|
|
553
561
|
let updatedStatistics = [];
|
|
554
562
|
for (let i = 0; i < dataList.length; i++) {
|
|
555
563
|
let item = dataList[i];
|
|
556
|
-
|
|
564
|
+
// let updated = {};
|
|
565
|
+
if (!item.name && item.name !== 0) {
|
|
557
566
|
item.name = emptyName;
|
|
558
567
|
}
|
|
559
568
|
if (column_groupby_column_key && !item.group_name) {
|
|
560
569
|
item.group_name = emptyName;
|
|
561
570
|
}
|
|
562
571
|
if (!item.slugId) {
|
|
563
|
-
item.slugId =
|
|
572
|
+
item.slugId = slugid.nice();
|
|
564
573
|
}
|
|
565
574
|
if (!item.value) {
|
|
566
575
|
item.value = 0;
|
|
@@ -586,10 +595,10 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
586
595
|
const {
|
|
587
596
|
type: columnType
|
|
588
597
|
} = column || {};
|
|
589
|
-
const pieChartColorsLength =
|
|
598
|
+
const pieChartColorsLength = PIE_CHART_COLORS.length - 1;
|
|
590
599
|
const backgroundColor = [];
|
|
591
600
|
result.forEach((item, index) => {
|
|
592
|
-
if (columnType ===
|
|
601
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
593
602
|
let {
|
|
594
603
|
color
|
|
595
604
|
} = item;
|
|
@@ -598,7 +607,7 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
598
607
|
if (index > pieChartColorsLength) {
|
|
599
608
|
index = index % pieChartColorsLength;
|
|
600
609
|
}
|
|
601
|
-
backgroundColor.push(
|
|
610
|
+
backgroundColor.push(PIE_CHART_COLORS[index]);
|
|
602
611
|
}
|
|
603
612
|
});
|
|
604
613
|
return backgroundColor;
|
|
@@ -637,8 +646,8 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
637
646
|
groupby_column_key,
|
|
638
647
|
minimum_slice_percent
|
|
639
648
|
} = chart.config;
|
|
640
|
-
const table =
|
|
641
|
-
const column =
|
|
649
|
+
const table = getTableById(tables, table_id);
|
|
650
|
+
const column = getColumnByKey(groupby_column_key, table ? table.columns : []);
|
|
642
651
|
let sum = data.reduce((total, currentValue) => {
|
|
643
652
|
return total += currentValue.value;
|
|
644
653
|
}, 0);
|
|
@@ -683,102 +692,164 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
683
692
|
};
|
|
684
693
|
// table
|
|
685
694
|
// format SINGLE_SELECT, LAST_MODIFIER, CREATOR, COLLABORATOR, DATE, NUMBER
|
|
686
|
-
BaseUtils.updateTableViewListItemNameAndColor = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
data: columnData
|
|
690
|
-
} = column;
|
|
691
|
-
let name = result[nameKey];
|
|
692
|
-
if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
693
|
-
const options = (0, _dtableUtils.getColumnOptions)(column);
|
|
694
|
-
let selectedOption = (0, _dtableUtils.getOption)(options, name);
|
|
695
|
+
BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
696
|
+
return new Promise((resolve, reject) => {
|
|
697
|
+
let resultPromise = Promise.resolve();
|
|
695
698
|
let {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
result[nameKey] = name.join(', ');
|
|
715
|
-
return;
|
|
699
|
+
type: columnType,
|
|
700
|
+
data: columnData
|
|
701
|
+
} = column;
|
|
702
|
+
let name = result[nameKey];
|
|
703
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
704
|
+
const options = getColumnOptions(column);
|
|
705
|
+
let selectedOption = getOption(options, name);
|
|
706
|
+
let {
|
|
707
|
+
name: optionName,
|
|
708
|
+
color: optionColor,
|
|
709
|
+
id
|
|
710
|
+
} = selectedOption || {};
|
|
711
|
+
if (selectedOption) {
|
|
712
|
+
result[nameKey] = optionName;
|
|
713
|
+
result[colorKey] = optionColor;
|
|
714
|
+
isNameField && (result.original_name = id);
|
|
715
|
+
} else {
|
|
716
|
+
result[colorKey] = '#dbdbdb';
|
|
716
717
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
718
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
719
|
+
const users = context.getCollaboratorsFromCache();
|
|
720
|
+
const user = users.find(user => user.email === name);
|
|
721
|
+
if (user) {
|
|
722
|
+
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
723
|
+
isNameField && (result.original_name = name);
|
|
724
|
+
resolve();
|
|
725
|
+
} else {
|
|
726
|
+
context.queryUsers([name], users => {
|
|
727
|
+
const userEmail = name;
|
|
728
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
729
|
+
const userName = user.name || userEmail;
|
|
730
|
+
result[nameKey] = userName;
|
|
731
|
+
isNameField && (result.original_name = userEmail);
|
|
732
|
+
user.loaded = true;
|
|
733
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
734
|
+
resolve();
|
|
735
|
+
});
|
|
730
736
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
737
|
+
return;
|
|
738
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
739
|
+
const users = context.getCollaboratorsFromCache();
|
|
740
|
+
const user = users.find(user => user.email === name);
|
|
741
|
+
if (user) {
|
|
742
|
+
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
743
|
+
isNameField && (result.original_name = name);
|
|
744
|
+
resolve();
|
|
745
|
+
} else {
|
|
746
|
+
context.queryUsers([name], users => {
|
|
747
|
+
const userEmail = name;
|
|
748
|
+
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
749
|
+
const userName = user.name || userEmail;
|
|
750
|
+
result[nameKey] = userName;
|
|
751
|
+
isNameField && (result.original_name = userEmail);
|
|
752
|
+
user.loaded = true;
|
|
753
|
+
context.updateCollaboratorsCache(userEmail, user);
|
|
754
|
+
resolve();
|
|
755
|
+
});
|
|
745
756
|
}
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
} else if (columnType === _dtableUtils.CellType.LINK_FORMULA) {
|
|
749
|
-
// scatter only use number
|
|
750
|
-
if (isScatterChart) {
|
|
751
|
-
name.length && (name = name[0]);
|
|
757
|
+
return;
|
|
758
|
+
} else if (columnType === CellType.NUMBER) {
|
|
752
759
|
let valueNumber = parseFloat(name);
|
|
753
|
-
result[nameKey] =
|
|
760
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
761
|
+
isNameField && (result.original_name = name);
|
|
762
|
+
} else if (columnType === CellType.DATE) {
|
|
763
|
+
name = name + '';
|
|
764
|
+
if (name && name.split('-').length === 3) {
|
|
765
|
+
let format = getDateColumnFormat(column);
|
|
766
|
+
let spaceIndex = format.indexOf(' ');
|
|
767
|
+
if (spaceIndex > -1) {
|
|
768
|
+
format = format.slice(0, spaceIndex);
|
|
769
|
+
}
|
|
770
|
+
result[nameKey] = dayjs(name).format(format);
|
|
771
|
+
}
|
|
772
|
+
} else if (columnType === CellType.LINK_FORMULA) {
|
|
773
|
+
// scatter only use number
|
|
774
|
+
if (isScatterChart) {
|
|
775
|
+
name.length && (name = name[0]);
|
|
776
|
+
let valueNumber = parseFloat(name);
|
|
777
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
778
|
+
}
|
|
779
|
+
const {
|
|
780
|
+
array_data,
|
|
781
|
+
array_type
|
|
782
|
+
} = columnData;
|
|
783
|
+
const linkedColumn = {
|
|
784
|
+
...column,
|
|
785
|
+
type: array_type,
|
|
786
|
+
data: array_data
|
|
787
|
+
};
|
|
788
|
+
// for linked formula, need to call recursively, using it's result as the result of the promise
|
|
789
|
+
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
|
|
790
|
+
} else if (columnType === CellType.FORMULA) {
|
|
791
|
+
const {
|
|
792
|
+
result_type: resultType,
|
|
793
|
+
array_type: arrayType,
|
|
794
|
+
array_data: arrayData
|
|
795
|
+
} = columnData || {};
|
|
796
|
+
if (resultType === FORMULA_RESULT_TYPE.NUMBER) {
|
|
797
|
+
const valueNumber = parseFloat(name);
|
|
798
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
799
|
+
isNameField && (result.original_name = name);
|
|
800
|
+
} else if (resultType === FORMULA_RESULT_TYPE.DATE || resultType === CellType.CTIME || resultType === CellType.MTIME) {
|
|
801
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
802
|
+
isNameField && (result.original_name = name);
|
|
803
|
+
} else if (arrayType && arrayData) {
|
|
804
|
+
const formulaArrayColumn = {
|
|
805
|
+
...column,
|
|
806
|
+
type: arrayType,
|
|
807
|
+
data: arrayData
|
|
808
|
+
};
|
|
809
|
+
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, formulaArrayColumn, nameKey, colorKey, isScatterChart, isNameField);
|
|
810
|
+
} else if (Array.isArray(name)) {
|
|
811
|
+
result[nameKey] = name.map(item => {
|
|
812
|
+
if (isValidCollaboratorEmail(item)) {
|
|
813
|
+
const collaborator = getKnownCollaboratorByEmail(item);
|
|
814
|
+
return collaborator ? collaborator.name : item;
|
|
815
|
+
}
|
|
816
|
+
return item;
|
|
817
|
+
}).join(', ');
|
|
818
|
+
isNameField && (result.original_name = name.join(', '));
|
|
819
|
+
} else if (typeof name === 'string' && isValidCollaboratorEmail(name)) {
|
|
820
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
821
|
+
result[nameKey] = collaborator ? collaborator.name : name;
|
|
822
|
+
isNameField && (result.original_name = name);
|
|
823
|
+
} else {
|
|
824
|
+
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
825
|
+
isNameField && (result.original_name = name);
|
|
826
|
+
}
|
|
754
827
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
array_type
|
|
758
|
-
} = columnData;
|
|
759
|
-
const linkedColumn = {
|
|
760
|
-
...column,
|
|
761
|
-
type: array_type,
|
|
762
|
-
data: array_data
|
|
763
|
-
};
|
|
764
|
-
return _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
|
|
765
|
-
}
|
|
828
|
+
resolve(resultPromise);
|
|
829
|
+
});
|
|
766
830
|
};
|
|
767
|
-
BaseUtils.updateTableViewList = (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
831
|
+
BaseUtils.updateTableViewList = async (result, column, nameKey, colorKey, isScatterChart, isNameField) => {
|
|
832
|
+
const promises = [];
|
|
768
833
|
result.forEach(result => {
|
|
769
|
-
_BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
|
|
834
|
+
const promise = _BaseUtils.updateTableViewListItemNameAndColor(result, column, nameKey, colorKey, isScatterChart, isNameField);
|
|
835
|
+
promises.push(promise);
|
|
770
836
|
});
|
|
837
|
+
try {
|
|
838
|
+
await Promise.all(promises);
|
|
839
|
+
} catch (e) {
|
|
840
|
+
console.error(e);
|
|
841
|
+
}
|
|
771
842
|
};
|
|
772
|
-
// sort chart
|
|
773
|
-
BaseUtils.sortCharts = (
|
|
843
|
+
// sort chart result
|
|
844
|
+
BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
774
845
|
let {
|
|
775
846
|
type: columnType,
|
|
776
847
|
data
|
|
777
848
|
} = column;
|
|
778
849
|
const sortType = 'up';
|
|
779
850
|
const optionIdIndexMap = {};
|
|
780
|
-
const isPivotMultipleSelect = columnType ===
|
|
781
|
-
if ([
|
|
851
|
+
const isPivotMultipleSelect = columnType === CellType.MULTIPLE_SELECT && isPivot;
|
|
852
|
+
if ([CellType.SINGLE_SELECT].includes(columnType) || isPivotMultipleSelect) {
|
|
782
853
|
const {
|
|
783
854
|
options
|
|
784
855
|
} = data || {};
|
|
@@ -786,7 +857,7 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
786
857
|
optionIdIndexMap[option.id] = index;
|
|
787
858
|
});
|
|
788
859
|
}
|
|
789
|
-
const isPivotLinkFormulaSingleAndMultipleSelect = columnType ===
|
|
860
|
+
const isPivotLinkFormulaSingleAndMultipleSelect = columnType === CellType.LINK_FORMULA && [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT].includes(column.data.array_type) && isPivot;
|
|
790
861
|
if (isPivotLinkFormulaSingleAndMultipleSelect) {
|
|
791
862
|
var _column$data;
|
|
792
863
|
let {
|
|
@@ -797,7 +868,7 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
797
868
|
optionIdIndexMap[option.id] = index;
|
|
798
869
|
});
|
|
799
870
|
}
|
|
800
|
-
|
|
871
|
+
results.sort((currResult, nextResult) => {
|
|
801
872
|
let {
|
|
802
873
|
[sortKey]: current
|
|
803
874
|
} = currResult;
|
|
@@ -810,14 +881,14 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
810
881
|
if (!next && next !== 0) {
|
|
811
882
|
return 1;
|
|
812
883
|
}
|
|
813
|
-
if (
|
|
884
|
+
if (CHART_SUPPORT_SORT_COLUMNS.includes(columnType)) {
|
|
814
885
|
let realColumnType = columnType;
|
|
815
|
-
if ([
|
|
886
|
+
if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
|
|
816
887
|
realColumnType = column.data.array_type;
|
|
817
888
|
}
|
|
818
889
|
switch (realColumnType) {
|
|
819
|
-
case
|
|
820
|
-
case
|
|
890
|
+
case CellType.NUMBER:
|
|
891
|
+
case CellType.RATE:
|
|
821
892
|
{
|
|
822
893
|
if (current) {
|
|
823
894
|
current = current - 0;
|
|
@@ -825,15 +896,15 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
825
896
|
if (next) {
|
|
826
897
|
next = next - 0;
|
|
827
898
|
}
|
|
828
|
-
return
|
|
899
|
+
return sortNumber(current, next, sortType);
|
|
829
900
|
}
|
|
830
|
-
case
|
|
831
|
-
case
|
|
832
|
-
case
|
|
901
|
+
case CellType.DATE:
|
|
902
|
+
case CellType.CTIME:
|
|
903
|
+
case CellType.MTIME:
|
|
833
904
|
{
|
|
834
|
-
return
|
|
905
|
+
return sortDate(current, next, sortType);
|
|
835
906
|
}
|
|
836
|
-
case
|
|
907
|
+
case CellType.SINGLE_SELECT:
|
|
837
908
|
{
|
|
838
909
|
// key was used to sort "pivot columns" in pivot chart
|
|
839
910
|
const {
|
|
@@ -846,29 +917,29 @@ BaseUtils.sortCharts = (charts, column, sortKey, isPivot) => {
|
|
|
846
917
|
} = nextResult || {};
|
|
847
918
|
const current = currentName || currentKey;
|
|
848
919
|
const next = nextName || nextKey;
|
|
849
|
-
return
|
|
920
|
+
return sortSingleSelect(current, next, {
|
|
850
921
|
sort_type: sortType,
|
|
851
922
|
option_id_index_map: optionIdIndexMap
|
|
852
923
|
});
|
|
853
924
|
}
|
|
854
|
-
case
|
|
925
|
+
case CellType.MULTIPLE_SELECT:
|
|
855
926
|
{
|
|
856
|
-
return
|
|
927
|
+
return sortSingleSelect(current, next, {
|
|
857
928
|
sort_type: sortType,
|
|
858
929
|
option_id_index_map: optionIdIndexMap
|
|
859
930
|
});
|
|
860
931
|
}
|
|
861
|
-
case
|
|
862
|
-
case
|
|
932
|
+
case CellType.FORMULA:
|
|
933
|
+
case CellType.LINK_FORMULA:
|
|
863
934
|
{
|
|
864
|
-
return
|
|
935
|
+
return sortFormula(current, next, sortType, {
|
|
865
936
|
columnData: data,
|
|
866
937
|
value: {}
|
|
867
938
|
});
|
|
868
939
|
}
|
|
869
940
|
default:
|
|
870
941
|
{
|
|
871
|
-
return
|
|
942
|
+
return sortText(current, next, sortType);
|
|
872
943
|
}
|
|
873
944
|
}
|
|
874
945
|
}
|
|
@@ -908,7 +979,7 @@ BaseUtils.sortDataByKey = (data, key, sortType) => {
|
|
|
908
979
|
if (!nextVal && nextVal !== 0) {
|
|
909
980
|
return 1;
|
|
910
981
|
}
|
|
911
|
-
if (sortType ===
|
|
982
|
+
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
912
983
|
return currentVal > nextVal ? 1 : -1;
|
|
913
984
|
} else {
|
|
914
985
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -934,7 +1005,7 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
934
1005
|
type,
|
|
935
1006
|
config
|
|
936
1007
|
} = chart;
|
|
937
|
-
if (
|
|
1008
|
+
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
938
1009
|
groupby_column_key = config.groupby_column_key;
|
|
939
1010
|
} else {
|
|
940
1011
|
groupby_column_key = config.x_axis_column_key;
|
|
@@ -943,9 +1014,9 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
943
1014
|
const {
|
|
944
1015
|
table_id
|
|
945
1016
|
} = config;
|
|
946
|
-
const table =
|
|
947
|
-
const groupbyColumn =
|
|
948
|
-
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);
|
|
949
1020
|
results.forEach(item => {
|
|
950
1021
|
const {
|
|
951
1022
|
name,
|
|
@@ -964,84 +1035,84 @@ BaseUtils.convertResultName = (result, column, name, nameKey, colorKey) => {
|
|
|
964
1035
|
type: columnType,
|
|
965
1036
|
data: columnData
|
|
966
1037
|
} = column;
|
|
967
|
-
if (columnType ===
|
|
968
|
-
const options =
|
|
969
|
-
const selectedOption =
|
|
1038
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
1039
|
+
const options = getColumnOptions(column);
|
|
1040
|
+
const selectedOption = getOption(options, name);
|
|
970
1041
|
if (selectedOption) {
|
|
971
1042
|
result[nameKey] = selectedOption.name;
|
|
972
1043
|
result[colorKey] = selectedOption.color;
|
|
973
1044
|
} else {
|
|
974
1045
|
result[colorKey] = '#dbdbdb';
|
|
975
1046
|
}
|
|
976
|
-
} else if (columnType ===
|
|
977
|
-
let collaborator =
|
|
1047
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
1048
|
+
let collaborator = getKnownCollaboratorByEmail(name);
|
|
978
1049
|
if (collaborator) {
|
|
979
1050
|
result[nameKey] = collaborator.name;
|
|
980
1051
|
}
|
|
981
|
-
} else if (columnType ===
|
|
1052
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
982
1053
|
if (name === 'anonymous') {
|
|
983
1054
|
result[nameKey] = name;
|
|
984
1055
|
} else {
|
|
985
|
-
const collaborator =
|
|
1056
|
+
const collaborator = getKnownCollaboratorByEmail(name);
|
|
986
1057
|
const collaboratorTemplate = {
|
|
987
1058
|
loaded: false,
|
|
988
1059
|
email: name,
|
|
989
1060
|
name: name
|
|
990
1061
|
};
|
|
991
|
-
|
|
1062
|
+
context.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
992
1063
|
if (!collaborator) {
|
|
993
|
-
|
|
994
|
-
const collaborator = emailUserMap && emailUserMap[name] ||
|
|
1064
|
+
context.queryUsers([name], emailUserMap => {
|
|
1065
|
+
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
995
1066
|
const loadedCollaborator = {
|
|
996
1067
|
...collaborator,
|
|
997
1068
|
loaded: true
|
|
998
1069
|
};
|
|
999
|
-
|
|
1070
|
+
context.updateCollaboratorsCache(name, loadedCollaborator);
|
|
1000
1071
|
result[nameKey] = name;
|
|
1001
1072
|
});
|
|
1002
1073
|
} else {
|
|
1003
1074
|
result[nameKey] = collaborator.name;
|
|
1004
1075
|
}
|
|
1005
1076
|
}
|
|
1006
|
-
} else if (columnType ===
|
|
1077
|
+
} else if (columnType === CellType.NUMBER) {
|
|
1007
1078
|
const valueNumber = parseFloat(name);
|
|
1008
|
-
result[nameKey] =
|
|
1009
|
-
} else if (columnType ===
|
|
1079
|
+
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1080
|
+
} else if (columnType === CellType.DATE) {
|
|
1010
1081
|
if (name && name.split('-').length === 3) {
|
|
1011
|
-
let format =
|
|
1082
|
+
let format = getDateColumnFormat(column);
|
|
1012
1083
|
const spaceIndex = format.indexOf(' ');
|
|
1013
1084
|
if (spaceIndex > -1) {
|
|
1014
1085
|
format = format.slice(0, spaceIndex);
|
|
1015
1086
|
}
|
|
1016
|
-
result[nameKey] = (
|
|
1087
|
+
result[nameKey] = dayjs(name).format(format);
|
|
1017
1088
|
}
|
|
1018
|
-
} else if (
|
|
1089
|
+
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
1019
1090
|
const {
|
|
1020
1091
|
result_type,
|
|
1021
1092
|
array_type
|
|
1022
1093
|
} = columnData || {};
|
|
1023
|
-
if (result_type ===
|
|
1094
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1024
1095
|
const valueNumber = parseFloat(name);
|
|
1025
|
-
result[nameKey] =
|
|
1026
|
-
} else if (result_type ===
|
|
1027
|
-
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)) {
|
|
1028
1099
|
result[nameKey] = name.map(email => {
|
|
1029
|
-
let user = array_type ===
|
|
1100
|
+
let user = array_type === CellType.COLLABORATOR ? getKnownCollaboratorByEmail(email) : getKnownCollaboratorByEmail(email);
|
|
1030
1101
|
return (user || {}).name;
|
|
1031
1102
|
});
|
|
1032
1103
|
}
|
|
1033
1104
|
}
|
|
1034
|
-
} else if (columnType ===
|
|
1035
|
-
result[nameKey] =
|
|
1105
|
+
} else if (columnType === CellType.LINK) {
|
|
1106
|
+
result[nameKey] = getClientFormulaDisplayString([name], columnData) || null;
|
|
1036
1107
|
}
|
|
1037
1108
|
};
|
|
1038
1109
|
// theme
|
|
1039
1110
|
BaseUtils.getCurrentTheme = themeName => {
|
|
1040
1111
|
if (themeName) {
|
|
1041
|
-
const currentColorTheme =
|
|
1112
|
+
const currentColorTheme = STYLE_COLORS.find(item => item.name === themeName);
|
|
1042
1113
|
return currentColorTheme;
|
|
1043
1114
|
}
|
|
1044
|
-
return
|
|
1115
|
+
return STYLE_COLORS[0];
|
|
1045
1116
|
};
|
|
1046
1117
|
BaseUtils.getSummaryExplanation = chart => {
|
|
1047
1118
|
const {
|
|
@@ -1051,43 +1122,43 @@ BaseUtils.getSummaryExplanation = chart => {
|
|
|
1051
1122
|
type
|
|
1052
1123
|
} = config;
|
|
1053
1124
|
switch (type) {
|
|
1054
|
-
case
|
|
1055
|
-
case
|
|
1056
|
-
case
|
|
1057
|
-
case
|
|
1125
|
+
case CHART_TYPE.PIE:
|
|
1126
|
+
case CHART_TYPE.LINE:
|
|
1127
|
+
case CHART_TYPE.LINE_GROUP:
|
|
1128
|
+
case CHART_TYPE.RING:
|
|
1058
1129
|
{
|
|
1059
1130
|
return {
|
|
1060
|
-
count:
|
|
1061
|
-
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')
|
|
1062
1133
|
};
|
|
1063
1134
|
}
|
|
1064
|
-
case
|
|
1065
|
-
case
|
|
1135
|
+
case CHART_TYPE.BAR:
|
|
1136
|
+
case CHART_TYPE.BAR_GROUP:
|
|
1066
1137
|
{
|
|
1067
1138
|
return {
|
|
1068
|
-
count:
|
|
1069
|
-
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')
|
|
1070
1141
|
};
|
|
1071
1142
|
}
|
|
1072
1143
|
default:
|
|
1073
1144
|
{
|
|
1074
1145
|
return {
|
|
1075
|
-
count:
|
|
1076
|
-
advanced:
|
|
1146
|
+
count: intl.get('Count_the_records'),
|
|
1147
|
+
advanced: intl.get('Compute_sum_max_min')
|
|
1077
1148
|
};
|
|
1078
1149
|
}
|
|
1079
1150
|
}
|
|
1080
1151
|
};
|
|
1081
1152
|
BaseUtils.getLabelFontSize = labelFontSize => {
|
|
1082
|
-
return
|
|
1153
|
+
return isNumber(labelFontSize) ? labelFontSize : DEFAULT_LABEL_FONT_SIZE;
|
|
1083
1154
|
};
|
|
1084
1155
|
BaseUtils.imEmptyChartResult = chartResult => {
|
|
1085
1156
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1086
1157
|
};
|
|
1087
1158
|
BaseUtils.getPrecisionNumber = (value, data) => {
|
|
1088
|
-
const valueString =
|
|
1159
|
+
const valueString = getPrecisionNumber(value, data);
|
|
1089
1160
|
const valueNumber = parseFloat(valueString);
|
|
1090
|
-
return
|
|
1161
|
+
return isNumber(valueNumber) ? valueNumber : 0;
|
|
1091
1162
|
};
|
|
1092
1163
|
BaseUtils.isValidCellValue = function (cellValue) {
|
|
1093
1164
|
let includeEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1099,7 +1170,7 @@ BaseUtils.convertConfig = config => {
|
|
|
1099
1170
|
const {
|
|
1100
1171
|
type
|
|
1101
1172
|
} = config;
|
|
1102
|
-
if (type ===
|
|
1173
|
+
if (type === CHART_TYPE.HORIZONTAL_BAR || type === CHART_TYPE.HORIZONTAL_GROUP_BAR || type === CHART_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
1103
1174
|
const {
|
|
1104
1175
|
vertical_axis_column_key,
|
|
1105
1176
|
vertical_axis_date_granularity,
|
|
@@ -1136,6 +1207,32 @@ BaseUtils.convertConfig = config => {
|
|
|
1136
1207
|
}
|
|
1137
1208
|
return config;
|
|
1138
1209
|
};
|
|
1210
|
+
BaseUtils.getSummaryType = config => {
|
|
1211
|
+
switch (config.type) {
|
|
1212
|
+
case CHART_TYPE.HORIZONTAL_BAR:
|
|
1213
|
+
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
1214
|
+
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1215
|
+
{
|
|
1216
|
+
return config.horizontal_axis_summary_type;
|
|
1217
|
+
}
|
|
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:
|
|
1226
|
+
{
|
|
1227
|
+
return config.y_axis_summary_type;
|
|
1228
|
+
}
|
|
1229
|
+
case CHART_TYPE.TABLE:
|
|
1230
|
+
default:
|
|
1231
|
+
{
|
|
1232
|
+
return config.summary_type;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1139
1236
|
BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGranularity, value) => {
|
|
1140
1237
|
let {
|
|
1141
1238
|
type,
|
|
@@ -1143,20 +1240,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1143
1240
|
data
|
|
1144
1241
|
} = column || {};
|
|
1145
1242
|
switch (type) {
|
|
1146
|
-
case
|
|
1243
|
+
case CellType.TEXT:
|
|
1147
1244
|
{
|
|
1148
1245
|
return cellValue || null;
|
|
1149
1246
|
}
|
|
1150
|
-
case
|
|
1247
|
+
case CellType.NUMBER:
|
|
1151
1248
|
{
|
|
1152
1249
|
if (!cellValue && cellValue !== 0) {
|
|
1153
1250
|
return null;
|
|
1154
1251
|
}
|
|
1155
|
-
const number =
|
|
1252
|
+
const number = getPrecisionNumber(cellValue, data);
|
|
1156
1253
|
let valueNumber = parseFloat(number);
|
|
1157
|
-
return
|
|
1254
|
+
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
1158
1255
|
}
|
|
1159
|
-
case
|
|
1256
|
+
case CellType.SINGLE_SELECT:
|
|
1160
1257
|
{
|
|
1161
1258
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
1162
1259
|
if (isInvalidValue) {
|
|
@@ -1164,20 +1261,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1164
1261
|
}
|
|
1165
1262
|
return cellValue;
|
|
1166
1263
|
}
|
|
1167
|
-
case
|
|
1168
|
-
case
|
|
1169
|
-
case
|
|
1264
|
+
case CellType.DATE:
|
|
1265
|
+
case CellType.CTIME:
|
|
1266
|
+
case CellType.MTIME:
|
|
1170
1267
|
{
|
|
1171
1268
|
if (!dateGranularity) {
|
|
1172
|
-
return
|
|
1269
|
+
return getDateDisplayString(cellValue);
|
|
1173
1270
|
}
|
|
1271
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1174
1272
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
1175
|
-
|
|
1176
|
-
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
1273
|
+
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1177
1274
|
}
|
|
1178
|
-
return
|
|
1275
|
+
return DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1179
1276
|
}
|
|
1180
|
-
case
|
|
1277
|
+
case CellType.MULTIPLE_SELECT:
|
|
1181
1278
|
{
|
|
1182
1279
|
let options = data && data.options;
|
|
1183
1280
|
if (!Array.isArray(cellValue)) {
|
|
@@ -1186,18 +1283,18 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1186
1283
|
const newCellValue = cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
1187
1284
|
return newCellValue.sort();
|
|
1188
1285
|
}
|
|
1189
|
-
case
|
|
1286
|
+
case CellType.COLLABORATOR:
|
|
1190
1287
|
{
|
|
1191
1288
|
if (!Array.isArray(cellValue)) return [];
|
|
1192
|
-
return cellValue.filter(email =>
|
|
1289
|
+
return cellValue.filter(email => isValidCollaboratorEmail(email));
|
|
1193
1290
|
}
|
|
1194
|
-
case
|
|
1195
|
-
case
|
|
1291
|
+
case CellType.CREATOR:
|
|
1292
|
+
case CellType.LAST_MODIFIER:
|
|
1196
1293
|
{
|
|
1197
1294
|
return cellValue ? cellValue : null;
|
|
1198
1295
|
}
|
|
1199
|
-
case
|
|
1200
|
-
case
|
|
1296
|
+
case CellType.LINK_FORMULA:
|
|
1297
|
+
case CellType.FORMULA:
|
|
1201
1298
|
{
|
|
1202
1299
|
if (!formulaRow) return '';
|
|
1203
1300
|
let formulaCellValue = formulaRow[key];
|
|
@@ -1205,33 +1302,34 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1205
1302
|
result_type,
|
|
1206
1303
|
array_type
|
|
1207
1304
|
} = data || {};
|
|
1208
|
-
if (result_type ===
|
|
1305
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1209
1306
|
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1210
1307
|
const dateCellValue = formulaCellValue[0];
|
|
1211
|
-
if (!dateGranularity) return
|
|
1212
|
-
|
|
1213
|
-
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);
|
|
1214
1312
|
}
|
|
1215
|
-
return
|
|
1313
|
+
return getFormulaDisplayString(formulaCellValue, data, {
|
|
1216
1314
|
tables: value.tables
|
|
1217
1315
|
}) || null;
|
|
1218
1316
|
}
|
|
1219
|
-
if (result_type ===
|
|
1220
|
-
return
|
|
1317
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1318
|
+
return getPrecisionNumber(formulaCellValue, data);
|
|
1221
1319
|
}
|
|
1222
1320
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
1223
1321
|
}
|
|
1224
|
-
case
|
|
1322
|
+
case CellType.GEOLOCATION:
|
|
1225
1323
|
{
|
|
1226
1324
|
const {
|
|
1227
1325
|
geo_format
|
|
1228
1326
|
} = data || {};
|
|
1229
1327
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
1230
|
-
return
|
|
1328
|
+
return getGeolocationDisplayString(cellValue, data);
|
|
1231
1329
|
}
|
|
1232
1330
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
1233
1331
|
}
|
|
1234
|
-
case
|
|
1332
|
+
case CellType.LINK:
|
|
1235
1333
|
{
|
|
1236
1334
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
1237
1335
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -1239,11 +1337,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1239
1337
|
}
|
|
1240
1338
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
1241
1339
|
}
|
|
1242
|
-
case
|
|
1340
|
+
case CellType.CHECKBOX:
|
|
1243
1341
|
{
|
|
1244
1342
|
return String(!!cellValue);
|
|
1245
1343
|
}
|
|
1246
|
-
case
|
|
1344
|
+
case CellType.RATE:
|
|
1247
1345
|
{
|
|
1248
1346
|
if (!cellValue) return null;
|
|
1249
1347
|
return cellValue + '';
|
|
@@ -1259,9 +1357,9 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1259
1357
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1260
1358
|
let rowsLength = rows.length;
|
|
1261
1359
|
let total;
|
|
1262
|
-
if (summary_type ===
|
|
1360
|
+
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1263
1361
|
total = rowsLength;
|
|
1264
|
-
} else if (summary_type ===
|
|
1362
|
+
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1265
1363
|
switch (summary_method) {
|
|
1266
1364
|
case 'Distinct_values':
|
|
1267
1365
|
{
|
|
@@ -1269,7 +1367,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1269
1367
|
let existMap = {};
|
|
1270
1368
|
rows.forEach(r => {
|
|
1271
1369
|
let num;
|
|
1272
|
-
if (
|
|
1370
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1273
1371
|
const formulaRow = formula_rows[r._id] || {};
|
|
1274
1372
|
num = formulaRow[summary_column_key];
|
|
1275
1373
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -1298,14 +1396,14 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1298
1396
|
let validNumbersCount = 0;
|
|
1299
1397
|
rows.forEach(r => {
|
|
1300
1398
|
let num;
|
|
1301
|
-
if (
|
|
1399
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1302
1400
|
let formulaRow = formula_rows[r._id] || {};
|
|
1303
1401
|
num = formulaRow[summary_column_key];
|
|
1304
1402
|
num = Array.isArray(num) ? num[0] : num;
|
|
1305
1403
|
} else {
|
|
1306
1404
|
num = r[summary_column_key];
|
|
1307
1405
|
}
|
|
1308
|
-
if (
|
|
1406
|
+
if (isNumber(num)) {
|
|
1309
1407
|
validNumbersCount++;
|
|
1310
1408
|
sum += num;
|
|
1311
1409
|
}
|
|
@@ -1323,7 +1421,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1323
1421
|
if (rowsLength > 0) {
|
|
1324
1422
|
let result = rows.reduce((current, next) => {
|
|
1325
1423
|
let currentValue, nextValue;
|
|
1326
|
-
if (
|
|
1424
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1327
1425
|
let currentFormulaRow = formula_rows[current._id];
|
|
1328
1426
|
let nextFormulaRow = formula_rows[next._id];
|
|
1329
1427
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -1344,7 +1442,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1344
1442
|
return isNextGreater ? next : current;
|
|
1345
1443
|
}
|
|
1346
1444
|
});
|
|
1347
|
-
if (
|
|
1445
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1348
1446
|
let formulaRow = formula_rows[result._id];
|
|
1349
1447
|
total = formulaRow && formulaRow[summary_column_key];
|
|
1350
1448
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -1366,42 +1464,42 @@ BaseUtils.getFormattedValue = (value, column, summaryMethod) => {
|
|
|
1366
1464
|
if (!column) {
|
|
1367
1465
|
return value;
|
|
1368
1466
|
}
|
|
1369
|
-
if (summaryMethod ===
|
|
1467
|
+
if (summaryMethod === CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
|
|
1370
1468
|
return value;
|
|
1371
1469
|
}
|
|
1372
1470
|
const {
|
|
1373
1471
|
type,
|
|
1374
1472
|
data
|
|
1375
1473
|
} = column;
|
|
1376
|
-
if (
|
|
1377
|
-
return
|
|
1474
|
+
if (isNumericColumn(column)) {
|
|
1475
|
+
return getNumberDisplayString(value, data);
|
|
1378
1476
|
}
|
|
1379
|
-
if (
|
|
1380
|
-
return
|
|
1477
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
1478
|
+
return getClientFormulaDisplayString(value, data);
|
|
1381
1479
|
}
|
|
1382
1480
|
return value;
|
|
1383
1481
|
};
|
|
1384
1482
|
BaseUtils.getSummaryResult = function (results, summaryMethod) {
|
|
1385
1483
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
1386
|
-
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)) : [];
|
|
1387
1485
|
switch (summaryMethod) {
|
|
1388
|
-
case
|
|
1486
|
+
case CHART_SUMMARY_TYPE.MAX:
|
|
1389
1487
|
{
|
|
1390
1488
|
return _BaseUtils.getMax(numericResults);
|
|
1391
1489
|
}
|
|
1392
|
-
case
|
|
1490
|
+
case CHART_SUMMARY_TYPE.MIN:
|
|
1393
1491
|
{
|
|
1394
1492
|
return _BaseUtils.getMin(numericResults);
|
|
1395
1493
|
}
|
|
1396
|
-
case
|
|
1494
|
+
case CHART_SUMMARY_TYPE.SUM:
|
|
1397
1495
|
{
|
|
1398
1496
|
return _BaseUtils.getSum(numericResults, precision);
|
|
1399
1497
|
}
|
|
1400
|
-
case
|
|
1498
|
+
case CHART_SUMMARY_TYPE.MEAN:
|
|
1401
1499
|
{
|
|
1402
1500
|
return _BaseUtils.getMean(numericResults, precision);
|
|
1403
1501
|
}
|
|
1404
|
-
case
|
|
1502
|
+
case CHART_SUMMARY_TYPE.Distinct_values:
|
|
1405
1503
|
{
|
|
1406
1504
|
let count = 0;
|
|
1407
1505
|
let existMap = {};
|
|
@@ -1450,15 +1548,15 @@ BaseUtils.getMean = function (list) {
|
|
|
1450
1548
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
1451
1549
|
};
|
|
1452
1550
|
BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
|
|
1453
|
-
const currentTime = (
|
|
1551
|
+
const currentTime = dayjs();
|
|
1454
1552
|
const days = duration === 'days_30' ? 30 : 7;
|
|
1455
1553
|
// set date to start of the day
|
|
1456
1554
|
const formattedEndDate = currentTime.format('YYYY-MM-DD');
|
|
1457
1555
|
const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
1458
|
-
const formattedStartDate = (
|
|
1459
|
-
const endDate = (
|
|
1460
|
-
const middleDate = (
|
|
1461
|
-
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);
|
|
1462
1560
|
let compareValue = [];
|
|
1463
1561
|
let comparedValue = [];
|
|
1464
1562
|
if (useDataDb) {
|
|
@@ -1466,7 +1564,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1466
1564
|
const days2 = [];
|
|
1467
1565
|
for (let index = 0; index < result.length; index++) {
|
|
1468
1566
|
const item = result[index];
|
|
1469
|
-
const key = (
|
|
1567
|
+
const key = dayjs(item[dbDateKey]);
|
|
1470
1568
|
if (!key.isValid()) continue;
|
|
1471
1569
|
if (key >= startDate && key < middleDate) {
|
|
1472
1570
|
comparedValue.push(item[valueKey]);
|
|
@@ -1495,7 +1593,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1495
1593
|
// }
|
|
1496
1594
|
// }
|
|
1497
1595
|
// }
|
|
1498
|
-
if (summaryType ===
|
|
1596
|
+
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1499
1597
|
comparedValue = _BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
1500
1598
|
compareValue = _BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
1501
1599
|
} else {
|
|
@@ -1521,13 +1619,13 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1521
1619
|
sqlColumnGroupbyColumnKey
|
|
1522
1620
|
} = chartSQLMap;
|
|
1523
1621
|
let newSqlRows = JSON.parse(JSON.stringify(sqlRows));
|
|
1524
|
-
if (config.summary_type ===
|
|
1622
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1525
1623
|
// has column group
|
|
1526
1624
|
if (sqlColumnGroupbyColumnKey) {
|
|
1527
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1625
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1528
1626
|
return newSqlRows;
|
|
1529
1627
|
}
|
|
1530
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1628
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1531
1629
|
return newSqlRows;
|
|
1532
1630
|
}
|
|
1533
1631
|
}
|
|
@@ -1553,7 +1651,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1553
1651
|
newSqlRows = Object.values(collaboratorsRowsMap);
|
|
1554
1652
|
}
|
|
1555
1653
|
}
|
|
1556
|
-
if (config.summary_type ===
|
|
1654
|
+
if (config.summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1557
1655
|
let summarySQLColumnName2ColumnKeys;
|
|
1558
1656
|
if (summarySQLColumnName2ColumnKey) {
|
|
1559
1657
|
summarySQLColumnName2ColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
@@ -1566,10 +1664,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1566
1664
|
|
|
1567
1665
|
// has column group
|
|
1568
1666
|
if (sqlColumnGroupbyColumnKey) {
|
|
1569
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1667
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1570
1668
|
return newSqlRows;
|
|
1571
1669
|
}
|
|
1572
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
1670
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1573
1671
|
return newSqlRows;
|
|
1574
1672
|
}
|
|
1575
1673
|
|
|
@@ -1577,10 +1675,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1577
1675
|
newSqlRows.forEach(item => {
|
|
1578
1676
|
summarySQLColumnName2ColumnKeys.forEach(key => {
|
|
1579
1677
|
if (key.startsWith('AVG')) {
|
|
1580
|
-
item[
|
|
1678
|
+
item[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1581
1679
|
// Update avg
|
|
1582
1680
|
const newKey = 'SUM' + key.slice(3);
|
|
1583
|
-
item[key] = item[newKey] / item[
|
|
1681
|
+
item[key] = item[newKey] / item[`COUNT(${key.slice(3)})`];
|
|
1584
1682
|
}
|
|
1585
1683
|
});
|
|
1586
1684
|
});
|
|
@@ -1592,7 +1690,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1592
1690
|
newSqlRows.forEach(item => {
|
|
1593
1691
|
summarySQLColumnName2ColumnKeys.forEach(key => {
|
|
1594
1692
|
if (key.startsWith('AVG')) {
|
|
1595
|
-
item[
|
|
1693
|
+
item[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1596
1694
|
}
|
|
1597
1695
|
});
|
|
1598
1696
|
});
|
|
@@ -1613,7 +1711,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1613
1711
|
// Avg: The avg is calculated by sum / count
|
|
1614
1712
|
if (key.startsWith('AVG')) {
|
|
1615
1713
|
newKey = 'SUM' + key.slice(3);
|
|
1616
|
-
newSqlRows[rowIndex][
|
|
1714
|
+
newSqlRows[rowIndex][`COUNT(${key.slice(3)})`] = newSqlRows[rowIndex][`COUNT(${key.slice(3)})`] + item['COUNT(*)'];
|
|
1617
1715
|
}
|
|
1618
1716
|
// Sum
|
|
1619
1717
|
if (newKey.startsWith('SUM') && newSqlRows[rowIndex][newKey]) {
|
|
@@ -1647,7 +1745,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1647
1745
|
// Avg: The avg is calculated by sum / count
|
|
1648
1746
|
if (key.startsWith('AVG')) {
|
|
1649
1747
|
newKey = 'SUM' + key.slice(3);
|
|
1650
|
-
obj[
|
|
1748
|
+
obj[`COUNT(${key.slice(3)})`] = item['COUNT(*)'];
|
|
1651
1749
|
}
|
|
1652
1750
|
// Sum
|
|
1653
1751
|
if (newKey.startsWith('SUM')) {
|
|
@@ -1667,7 +1765,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1667
1765
|
// Update avg
|
|
1668
1766
|
if (key.startsWith('AVG')) {
|
|
1669
1767
|
const newKey = 'SUM' + key.slice(3);
|
|
1670
|
-
item[key] = item[newKey] / item[
|
|
1768
|
+
item[key] = item[newKey] / item[`COUNT(${key.slice(3)})`];
|
|
1671
1769
|
}
|
|
1672
1770
|
});
|
|
1673
1771
|
});
|
|
@@ -1711,16 +1809,16 @@ BaseUtils.getDateGranularityByType = chart => {
|
|
|
1711
1809
|
const {
|
|
1712
1810
|
type
|
|
1713
1811
|
} = chart;
|
|
1714
|
-
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)) {
|
|
1715
1813
|
return chart['x_axis_date_granularity'];
|
|
1716
1814
|
}
|
|
1717
|
-
if ([
|
|
1815
|
+
if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
|
|
1718
1816
|
return chart['date_granularity'];
|
|
1719
1817
|
}
|
|
1720
|
-
if ([
|
|
1818
|
+
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1721
1819
|
return chart['vertical_axis_date_granularity'];
|
|
1722
1820
|
}
|
|
1723
|
-
if ([
|
|
1821
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1724
1822
|
return chart['groupby_date_granularity'];
|
|
1725
1823
|
}
|
|
1726
1824
|
return null;
|
|
@@ -1749,7 +1847,7 @@ BaseUtils.updateCollaboratorAndMultipleAvg = (pivot_rows, all) => {
|
|
|
1749
1847
|
let allSum = 0;
|
|
1750
1848
|
let allCount = 0;
|
|
1751
1849
|
cell.rows.forEach(r => {
|
|
1752
|
-
allSum = allSum + r[
|
|
1850
|
+
allSum = allSum + r[`SUM(${avgColumnName})`];
|
|
1753
1851
|
allCount = allCount + r['COUNT(*)'];
|
|
1754
1852
|
});
|
|
1755
1853
|
|
|
@@ -1771,13 +1869,13 @@ BaseUtils.isCollaboratorColumnOrMultipleColumn = columnMap => {
|
|
|
1771
1869
|
columnGroupbyColumn,
|
|
1772
1870
|
groupbyColumn
|
|
1773
1871
|
} = columnMap || {};
|
|
1774
|
-
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) {
|
|
1775
1873
|
return true;
|
|
1776
1874
|
}
|
|
1777
|
-
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) {
|
|
1778
1876
|
return true;
|
|
1779
1877
|
}
|
|
1780
|
-
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)) {
|
|
1781
1879
|
return true;
|
|
1782
1880
|
}
|
|
1783
1881
|
return false;
|
|
@@ -1791,10 +1889,10 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1791
1889
|
} = chart.config;
|
|
1792
1890
|
if (!column_groupby_multiple_numeric_column) {
|
|
1793
1891
|
if (groupColumn) {
|
|
1794
|
-
if ([
|
|
1892
|
+
if ([CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1795
1893
|
data.forEach(item => {
|
|
1796
1894
|
const option = groupColumn.data.options.find(option => option.name === item[groupKey]);
|
|
1797
|
-
if (option
|
|
1895
|
+
if (option === null || option === void 0 ? void 0 : option.id) {
|
|
1798
1896
|
item['group_name_id'] = option.id;
|
|
1799
1897
|
item['oldName'] = item.name;
|
|
1800
1898
|
item.name = item['group_name_id'];
|
|
@@ -1802,7 +1900,9 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1802
1900
|
});
|
|
1803
1901
|
_BaseUtils.sortCharts(data, groupColumn, 'name');
|
|
1804
1902
|
data.forEach(item => {
|
|
1805
|
-
item
|
|
1903
|
+
if (Object.prototype.hasOwnProperty.call(item, 'oldName')) {
|
|
1904
|
+
item.name = item['oldName'];
|
|
1905
|
+
}
|
|
1806
1906
|
});
|
|
1807
1907
|
return data;
|
|
1808
1908
|
}
|
|
@@ -1812,4 +1912,4 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1812
1912
|
}
|
|
1813
1913
|
return data;
|
|
1814
1914
|
};
|
|
1815
|
-
|
|
1915
|
+
export default BaseUtils;
|