sea-chart 2.0.36 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +49 -57
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +65 -73
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { FORMULA_COLUMN_TYPES_MAP, isNumber, isDateColumn, isNumericColumn, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import { isObject } from 'lodash';
|
|
3
|
+
import { CHART_SUMMARY_TYPE, TABLE_DIMENSIONS } from '../../../constants';
|
|
4
|
+
import { isArrayCellValue } from '../../cell-value-utils';
|
|
5
|
+
import { getFormattedLabel, isValidRow } from '../../row-utils';
|
|
6
|
+
import BaseUtils from '../base-utils';
|
|
7
|
+
import { summaryMethodColumn2SqlColumn } from '../../sql/column-2-sql-column';
|
|
2
8
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _dtableUtils = require("dtable-utils");
|
|
9
|
-
var _lodash = require("lodash");
|
|
10
|
-
var _constants = require("../../../constants");
|
|
11
|
-
var _cellValueUtils = require("../../cell-value-utils");
|
|
12
|
-
var _rowUtils = require("../../row-utils");
|
|
13
|
-
var _baseUtils = _interopRequireDefault(require("../base-utils"));
|
|
14
|
-
var _column2SqlColumn = require("../../sql/column-2-sql-column");
|
|
15
9
|
// one
|
|
16
10
|
async function calculateOneDimensionTable(chart, value, _ref) {
|
|
17
11
|
let {
|
|
@@ -30,11 +24,11 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
30
24
|
groupby_geolocation_granularity,
|
|
31
25
|
summary_columns
|
|
32
26
|
} = chart;
|
|
33
|
-
const table =
|
|
34
|
-
const view = table &&
|
|
35
|
-
const column =
|
|
27
|
+
const table = getTableById(value.tables, table_id);
|
|
28
|
+
const view = table && getViewById(table.views, view_id);
|
|
29
|
+
const column = getTableColumnByKey(table, groupby_column_key);
|
|
36
30
|
if (!column) return {};
|
|
37
|
-
const isColumnDataAsAnArray =
|
|
31
|
+
const isColumnDataAsAnArray = isArrayCellValue(column);
|
|
38
32
|
const statRows = await getViewRows(view, table);
|
|
39
33
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
40
34
|
let pivot_rows = [];
|
|
@@ -43,8 +37,8 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
43
37
|
_id: rowId
|
|
44
38
|
} = row;
|
|
45
39
|
const formulaRow = formulaRows[rowId];
|
|
46
|
-
if (
|
|
47
|
-
const name =
|
|
40
|
+
if (isValidRow(row, formulaRow, column, include_empty)) {
|
|
41
|
+
const name = BaseUtils.getGroupLabel(row[column.key], formulaRow, column, groupby_date_granularity, groupby_geolocation_granularity, value);
|
|
48
42
|
let pivotRowIndex;
|
|
49
43
|
if (isColumnDataAsAnArray) {
|
|
50
44
|
if (name.length === 0 && include_empty) {
|
|
@@ -68,7 +62,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
68
62
|
const statisticColumnKeys = [summary_column_key, ...summary_columns_option_keys];
|
|
69
63
|
const validStatisticColumnKeys = statisticColumnKeys;
|
|
70
64
|
let statisticColumns = validStatisticColumnKeys.map(key => {
|
|
71
|
-
const column =
|
|
65
|
+
const column = getTableColumnByKey(table, key);
|
|
72
66
|
return column ? {
|
|
73
67
|
...column
|
|
74
68
|
} : null;
|
|
@@ -84,23 +78,23 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
84
78
|
const {
|
|
85
79
|
pivot_columns_total
|
|
86
80
|
} = getOneDimensionTotal(statisticColumns, summary_type, formulaRows, pivot_rows);
|
|
87
|
-
|
|
88
|
-
const pivot_columns = summary_type ===
|
|
81
|
+
BaseUtils.sortCharts(pivot_rows, column, 'name');
|
|
82
|
+
const pivot_columns = summary_type === CHART_SUMMARY_TYPE.COUNT ? [] : statisticColumns.map(column => {
|
|
89
83
|
return {
|
|
90
84
|
key: column.key,
|
|
91
85
|
method: column.method
|
|
92
86
|
};
|
|
93
|
-
}).filter(item =>
|
|
87
|
+
}).filter(item => getTableColumnByKey(table, item.key));
|
|
94
88
|
pivot_rows.forEach(row => {
|
|
95
89
|
row.original_name = row.name;
|
|
96
|
-
row.name =
|
|
90
|
+
row.name = getFormattedLabel(column, row.name, value.collaborators, chart.type);
|
|
97
91
|
});
|
|
98
92
|
return {
|
|
99
93
|
pivot_columns_total,
|
|
100
94
|
pivot_rows,
|
|
101
95
|
pivot_columns,
|
|
102
96
|
formulaRows,
|
|
103
|
-
dimensions:
|
|
97
|
+
dimensions: TABLE_DIMENSIONS.ONE
|
|
104
98
|
};
|
|
105
99
|
}
|
|
106
100
|
function updateOneDimensionRows(pivot_rows, index, name, row) {
|
|
@@ -123,7 +117,7 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
123
117
|
let dateColumnsTotalArr = {};
|
|
124
118
|
if (Array.isArray(columns) && columns.length > 0) {
|
|
125
119
|
columns.forEach(column => {
|
|
126
|
-
if (column &&
|
|
120
|
+
if (column && isDateColumn(column)) {
|
|
127
121
|
dateColumnsTotalArr[column.key] = [];
|
|
128
122
|
}
|
|
129
123
|
});
|
|
@@ -136,7 +130,7 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
136
130
|
...item
|
|
137
131
|
};
|
|
138
132
|
let totalMap = {};
|
|
139
|
-
if (summary_type ===
|
|
133
|
+
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
140
134
|
totalMap['total'] = rows.length;
|
|
141
135
|
pivot_columns_total.total = (pivot_columns_total['total'] || 0) + rows.length;
|
|
142
136
|
} else {
|
|
@@ -148,8 +142,8 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
148
142
|
method
|
|
149
143
|
} = summaryColumn;
|
|
150
144
|
const total = getTotal(summaryColumn, summary_type, method, rows, formula_rows);
|
|
151
|
-
if (summaryColumn &&
|
|
152
|
-
if (method ===
|
|
145
|
+
if (summaryColumn && isDateColumn(summaryColumn)) {
|
|
146
|
+
if (method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
153
147
|
totalMap['total'] = total;
|
|
154
148
|
} else {
|
|
155
149
|
totalMap['total'] = total === 0 ? 0 : total.date;
|
|
@@ -157,11 +151,11 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
157
151
|
dateColumnsTotalArr[key].push(total);
|
|
158
152
|
}
|
|
159
153
|
}
|
|
160
|
-
if (method ===
|
|
161
|
-
pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key],
|
|
162
|
-
} else if (method ===
|
|
163
|
-
pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key],
|
|
164
|
-
} else if (method ===
|
|
154
|
+
if (method === CHART_SUMMARY_TYPE.MAX) {
|
|
155
|
+
pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], CHART_SUMMARY_TYPE.MAX).date;
|
|
156
|
+
} else if (method === CHART_SUMMARY_TYPE.MIN) {
|
|
157
|
+
pivot_columns_total['total'] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], CHART_SUMMARY_TYPE.MIN).date;
|
|
158
|
+
} else if (method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
165
159
|
const pivotColumnTotal = (pivot_columns_total['total'] ? pivot_columns_total['total'] - 0 : 0) + total;
|
|
166
160
|
pivot_columns_total['total'] = Number.parseFloat(pivotColumnTotal.toFixed(8));
|
|
167
161
|
}
|
|
@@ -179,8 +173,8 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
179
173
|
} = column;
|
|
180
174
|
const totalKey = key;
|
|
181
175
|
const total = getTotal(column, summary_type, method, rows, formula_rows);
|
|
182
|
-
if (column &&
|
|
183
|
-
if (method ===
|
|
176
|
+
if (column && isDateColumn(column)) {
|
|
177
|
+
if (method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
184
178
|
totalMap[totalKey] = total;
|
|
185
179
|
} else {
|
|
186
180
|
totalMap[totalKey] = total === 0 ? 0 : total.date;
|
|
@@ -188,11 +182,11 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
188
182
|
dateColumnsTotalArr[key].push(total);
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
|
-
if (method ===
|
|
192
|
-
pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key],
|
|
193
|
-
} else if (method ===
|
|
194
|
-
pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key],
|
|
195
|
-
} else if (method ===
|
|
185
|
+
if (method === CHART_SUMMARY_TYPE.MAX) {
|
|
186
|
+
pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], CHART_SUMMARY_TYPE.MAX).date;
|
|
187
|
+
} else if (method === CHART_SUMMARY_TYPE.MIN) {
|
|
188
|
+
pivot_columns_total[totalKey] = dateColumnsTotalArr[key].length === 0 ? 0 : getDateMaxOrMinTotal(dateColumnsTotalArr[key], CHART_SUMMARY_TYPE.MIN).date;
|
|
189
|
+
} else if (method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
196
190
|
const pivotColumnTotal = (pivot_columns_total[totalKey] ? pivot_columns_total[totalKey] - 0 : 0) + total;
|
|
197
191
|
pivot_columns_total[totalKey] = Number.parseFloat(pivotColumnTotal.toFixed(8));
|
|
198
192
|
}
|
|
@@ -235,20 +229,20 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
235
229
|
column_groupby_geolocation_granularity,
|
|
236
230
|
summary_columns
|
|
237
231
|
} = chart;
|
|
238
|
-
const table =
|
|
239
|
-
const view = table &&
|
|
232
|
+
const table = getTableById(value.tables, table_id);
|
|
233
|
+
const view = table && getViewById(table.views, view_id);
|
|
240
234
|
if (!view) return;
|
|
241
|
-
const groupbyColumn =
|
|
235
|
+
const groupbyColumn = getTableColumnByKey(table, groupby_column_key);
|
|
242
236
|
if (!groupbyColumn) return;
|
|
243
|
-
const isGroupbyColumnDataAsAnArray =
|
|
244
|
-
const rowGroupbyColumn =
|
|
237
|
+
const isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
238
|
+
const rowGroupbyColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
245
239
|
if (!rowGroupbyColumn) {
|
|
246
240
|
return calculateOneDimensionTable(chart, value, {
|
|
247
241
|
getViewRows,
|
|
248
242
|
getTableFormulaResults
|
|
249
243
|
});
|
|
250
244
|
}
|
|
251
|
-
const isRowGroupbyColumnDataAsAnArray =
|
|
245
|
+
const isRowGroupbyColumnDataAsAnArray = isArrayCellValue(rowGroupbyColumn);
|
|
252
246
|
const statRows = await getViewRows(view, table);
|
|
253
247
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
254
248
|
let pivot_columns = [];
|
|
@@ -258,12 +252,12 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
258
252
|
_id: rowId
|
|
259
253
|
} = row;
|
|
260
254
|
const formulaRow = formulaRows[rowId];
|
|
261
|
-
const cellValueForColumn =
|
|
262
|
-
if (
|
|
255
|
+
const cellValueForColumn = BaseUtils.getGroupLabel(row[rowGroupbyColumn.key], formulaRow, rowGroupbyColumn, column_groupby_date_granularity, column_groupby_geolocation_granularity, value);
|
|
256
|
+
if (isValidRow(row, formulaRow, rowGroupbyColumn, include_empty)) {
|
|
263
257
|
updateTwoDimensionColumns(value, pivot_columns, rowGroupbyColumn, row, formulaRow, include_empty, column_groupby_date_granularity, column_groupby_geolocation_granularity, isRowGroupbyColumnDataAsAnArray);
|
|
264
258
|
}
|
|
265
|
-
if (
|
|
266
|
-
const name =
|
|
259
|
+
if (isValidRow(row, formulaRow, groupbyColumn, include_empty)) {
|
|
260
|
+
const name = BaseUtils.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupby_date_granularity, groupby_geolocation_granularity, value);
|
|
267
261
|
let pivotRowIndex;
|
|
268
262
|
if (isGroupbyColumnDataAsAnArray) {
|
|
269
263
|
if (name.length === 0 && include_empty) {
|
|
@@ -285,7 +279,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
285
279
|
});
|
|
286
280
|
let summaryColumn = null;
|
|
287
281
|
if (summary_column_key) {
|
|
288
|
-
summaryColumn =
|
|
282
|
+
summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
// Single field
|
|
@@ -302,7 +296,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
302
296
|
column_key,
|
|
303
297
|
summary_method
|
|
304
298
|
} = item;
|
|
305
|
-
const itemSummaryColumn =
|
|
299
|
+
const itemSummaryColumn = getTableColumnByKey(table, column_key);
|
|
306
300
|
const itemSummaryMethod = summary_method;
|
|
307
301
|
if (itemSummaryColumn && itemSummaryMethod) {
|
|
308
302
|
// The index of a single field is 0, so the index of a multiple-select field starts at 1.
|
|
@@ -321,18 +315,18 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
321
315
|
}
|
|
322
316
|
});
|
|
323
317
|
}
|
|
324
|
-
|
|
325
|
-
|
|
318
|
+
BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
319
|
+
BaseUtils.sortCharts(pivot_columns, rowGroupbyColumn, 'key');
|
|
326
320
|
|
|
327
321
|
// format shown label(name)
|
|
328
322
|
const map = {};
|
|
329
323
|
pivot_columns.forEach(column => {
|
|
330
|
-
const name =
|
|
324
|
+
const name = getFormattedLabel(rowGroupbyColumn, column.key, value.collaborators, chart.type);
|
|
331
325
|
map[column.key] = name;
|
|
332
326
|
column.key = name;
|
|
333
327
|
});
|
|
334
328
|
pivot_rows.forEach(row => {
|
|
335
|
-
row.name =
|
|
329
|
+
row.name = getFormattedLabel(groupbyColumn, row.name, value.collaborators, chart.type);
|
|
336
330
|
const cells = {};
|
|
337
331
|
Object.keys(row.cells).forEach(key => {
|
|
338
332
|
cells[map[key]] = row.cells[key];
|
|
@@ -349,13 +343,13 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
349
343
|
pivot_columns_total: new_pivot_columns_total,
|
|
350
344
|
pivot_table_total,
|
|
351
345
|
formulaRows,
|
|
352
|
-
dimensions:
|
|
346
|
+
dimensions: TABLE_DIMENSIONS.TWO,
|
|
353
347
|
summary_columns: getAllSummaryColumns(summaryColumn, summary_columns, table),
|
|
354
348
|
isSingleNumericColumn: !summary_columns.length ? 'true' : 'false'
|
|
355
349
|
};
|
|
356
350
|
}
|
|
357
351
|
function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
|
|
358
|
-
let key =
|
|
352
|
+
let key = BaseUtils.getGroupLabel(row[column.key], formulaRow, column, dateGranularity, geolocationGranularity, value);
|
|
359
353
|
let pivotColumnIndex;
|
|
360
354
|
if (isRowGroupbyColumnDataAsAnArray) {
|
|
361
355
|
if (key.length === 0 && isIncludeEmpty) {
|
|
@@ -397,7 +391,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
397
391
|
summary_column_key,
|
|
398
392
|
summary_method
|
|
399
393
|
} = chart;
|
|
400
|
-
const isCount = summary_type ===
|
|
394
|
+
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
401
395
|
let summarySQLColumnName2ColumnKey = {};
|
|
402
396
|
let numericColumns = [];
|
|
403
397
|
if (summary_column_key) {
|
|
@@ -412,11 +406,11 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
412
406
|
summary_method: item_summary_method
|
|
413
407
|
} = item;
|
|
414
408
|
const summaryMethod = item_summary_method.toUpperCase();
|
|
415
|
-
const column =
|
|
416
|
-
if (column && (
|
|
409
|
+
const column = getTableColumnByKey(table, column_key);
|
|
410
|
+
if (column && (BaseUtils.isDateSummaryColumn(column) || BaseUtils.isNumericSummaryColumn(column))) {
|
|
417
411
|
const {
|
|
418
412
|
key: sqlNumericColumnKey
|
|
419
|
-
} =
|
|
413
|
+
} = summaryMethodColumn2SqlColumn(summaryMethod, column);
|
|
420
414
|
const {
|
|
421
415
|
key: summaryColumnKey
|
|
422
416
|
} = column;
|
|
@@ -424,12 +418,12 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
424
418
|
}
|
|
425
419
|
});
|
|
426
420
|
const summarySQLColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
|
|
427
|
-
const summaryColumn =
|
|
421
|
+
const summaryColumn = getTableColumnByKey(table, summary_column_key) || {};
|
|
428
422
|
const singleNumeriColumnWithMethod = {
|
|
429
423
|
column: summaryColumn,
|
|
430
424
|
summary_method
|
|
431
425
|
};
|
|
432
|
-
const summaryColumnsWithMethod =
|
|
426
|
+
const summaryColumnsWithMethod = BaseUtils.getSummaryColumnsWithMethod(table, {
|
|
433
427
|
config: chart
|
|
434
428
|
});
|
|
435
429
|
const multipleNumericColumnsWithMethod = summaryColumnsWithMethod;
|
|
@@ -443,7 +437,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
443
437
|
let {
|
|
444
438
|
key
|
|
445
439
|
} = c;
|
|
446
|
-
if (
|
|
440
|
+
if (BaseUtils.isSameGroup(isColumnDataAsAnArray, cellValue, key)) {
|
|
447
441
|
if (cells[key]) {
|
|
448
442
|
cells[key].rows.push(row);
|
|
449
443
|
if (isCount) {
|
|
@@ -453,7 +447,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
453
447
|
const current = all.find(item => item.column.key === columnKey);
|
|
454
448
|
const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
|
|
455
449
|
const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
|
|
456
|
-
const computedValue =
|
|
450
|
+
const computedValue = BaseUtils.getSummaryValue({
|
|
457
451
|
summaryMethod: current.summary_method.toUpperCase(),
|
|
458
452
|
summaryColumn: current.column
|
|
459
453
|
}, currentValue, nextValue, true);
|
|
@@ -492,7 +486,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
492
486
|
} else {
|
|
493
487
|
updatedPivotRow.total = Object.values(cells).reduce((acc, item) => {
|
|
494
488
|
item.total.forEach(t => {
|
|
495
|
-
|
|
489
|
+
isNumber(t[1]) && (acc += t[1]);
|
|
496
490
|
});
|
|
497
491
|
return acc;
|
|
498
492
|
}, 0);
|
|
@@ -508,7 +502,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
508
502
|
let {
|
|
509
503
|
key
|
|
510
504
|
} = c;
|
|
511
|
-
if (
|
|
505
|
+
if (BaseUtils.isSameGroup(isColumnDataAsAnArray, cellValue, key)) {
|
|
512
506
|
let total;
|
|
513
507
|
if (isCount) {
|
|
514
508
|
total = row[groupbyColumn.key];
|
|
@@ -530,9 +524,9 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
530
524
|
const cellList = Object.values(cells);
|
|
531
525
|
total = cellList.reduce((acc, item) => {
|
|
532
526
|
let num;
|
|
533
|
-
if (
|
|
527
|
+
if (isObject(item.total)) {
|
|
534
528
|
num = item.total.reduce((acc, item) => {
|
|
535
|
-
|
|
529
|
+
isNumber(item[1]) && (acc += item[1]);
|
|
536
530
|
return acc;
|
|
537
531
|
}, 0);
|
|
538
532
|
} else {
|
|
@@ -558,7 +552,7 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
558
552
|
let {
|
|
559
553
|
type: summary_column_type
|
|
560
554
|
} = summaryColumn || {};
|
|
561
|
-
const isSummaryDateColumn = summaryColumn &&
|
|
555
|
+
const isSummaryDateColumn = summaryColumn && isDateColumn(summaryColumn);
|
|
562
556
|
let date_summary_column_format = isSummaryDateColumn ? summaryColumn.data.format : '';
|
|
563
557
|
Array.isArray(pivot_rows) && pivot_rows.forEach(pivotRow => {
|
|
564
558
|
let {
|
|
@@ -606,8 +600,8 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
606
600
|
pivot_table_total += total;
|
|
607
601
|
}
|
|
608
602
|
});
|
|
609
|
-
if (summaryColumn &&
|
|
610
|
-
if (summary_method ===
|
|
603
|
+
if (summaryColumn && isDateColumn(summaryColumn)) {
|
|
604
|
+
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
611
605
|
pivot_columns_total = Number.parseFloat(pivot_table_total.toFixed(8));
|
|
612
606
|
} else {
|
|
613
607
|
pivot_columns_total = showTwoDimensionDateColumnsAndRowsTotal(dateColumnsTotalArr, pivot_rows, date_summary_column_format, pivot_columns, summary_method);
|
|
@@ -628,7 +622,7 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
628
622
|
|
|
629
623
|
// utils
|
|
630
624
|
function isSameName(prevName, currName) {
|
|
631
|
-
if (
|
|
625
|
+
if (isNumber(prevName) && isNumber(currName)) {
|
|
632
626
|
return prevName === currName;
|
|
633
627
|
}
|
|
634
628
|
if (!prevName && !currName) {
|
|
@@ -651,15 +645,15 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
651
645
|
const summary_column_type = summary_column ? summary_column.type : '';
|
|
652
646
|
const rowsLength = rows.length;
|
|
653
647
|
let total;
|
|
654
|
-
if (summary_type ===
|
|
648
|
+
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
655
649
|
total = rowsLength;
|
|
656
|
-
} else if (summary_type ===
|
|
657
|
-
if (summary_method ===
|
|
650
|
+
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
651
|
+
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values || summary_method === 'Distinct_values') {
|
|
658
652
|
total = 0;
|
|
659
653
|
let existMap = {};
|
|
660
654
|
rows.forEach(row => {
|
|
661
655
|
let num;
|
|
662
|
-
if (
|
|
656
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
663
657
|
const formulaRow = formula_rows[row._id] || {};
|
|
664
658
|
num = formulaRow[summary_column_key];
|
|
665
659
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -681,14 +675,14 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
681
675
|
total = getTotalByType(oldTotal, total, index);
|
|
682
676
|
return total;
|
|
683
677
|
}
|
|
684
|
-
if (summary_column &&
|
|
678
|
+
if (summary_column && isDateColumn(summary_column)) {
|
|
685
679
|
if (rowsLength === 0) return;
|
|
686
680
|
let dateArr = [];
|
|
687
681
|
rows.forEach(r => {
|
|
688
682
|
let formatDate = {};
|
|
689
683
|
let formatDateData;
|
|
690
684
|
let value = r[summary_column_key];
|
|
691
|
-
if (
|
|
685
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
692
686
|
let formulaRow = formula_rows[r._id] || {};
|
|
693
687
|
value = formulaRow[summary_column_key] || '';
|
|
694
688
|
value = Array.isArray(value) && value.length !== 0 ? value[0] : '';
|
|
@@ -706,21 +700,21 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
706
700
|
formatDate.value = Date.parse(formatDateData);
|
|
707
701
|
dateArr.push(formatDate);
|
|
708
702
|
});
|
|
709
|
-
if (summary_method ===
|
|
710
|
-
total = getDateMaxOrMinTotal(dateArr,
|
|
711
|
-
} else if (summary_method ===
|
|
712
|
-
total = getDateMaxOrMinTotal(dateArr,
|
|
703
|
+
if (summary_method === CHART_SUMMARY_TYPE.MAX) {
|
|
704
|
+
total = getDateMaxOrMinTotal(dateArr, CHART_SUMMARY_TYPE.MAX);
|
|
705
|
+
} else if (summary_method === CHART_SUMMARY_TYPE.MIN) {
|
|
706
|
+
total = getDateMaxOrMinTotal(dateArr, CHART_SUMMARY_TYPE.MIN);
|
|
713
707
|
}
|
|
714
708
|
} else {
|
|
715
709
|
switch (summary_method) {
|
|
716
|
-
case
|
|
717
|
-
case
|
|
710
|
+
case CHART_SUMMARY_TYPE.SUM:
|
|
711
|
+
case CHART_SUMMARY_TYPE.MEAN:
|
|
718
712
|
{
|
|
719
713
|
let sum = 0;
|
|
720
714
|
let validNumbersCount = 0;
|
|
721
715
|
rows.forEach(r => {
|
|
722
716
|
let num;
|
|
723
|
-
if (
|
|
717
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
724
718
|
let formulaRow = formula_rows[r._id] || {};
|
|
725
719
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
726
720
|
num = formulaRow[summary_column_key][0];
|
|
@@ -730,7 +724,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
730
724
|
} else {
|
|
731
725
|
num = r[summary_column_key];
|
|
732
726
|
}
|
|
733
|
-
if (
|
|
727
|
+
if (isNumber(num)) {
|
|
734
728
|
validNumbersCount++;
|
|
735
729
|
sum += num;
|
|
736
730
|
}
|
|
@@ -743,13 +737,13 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
743
737
|
}
|
|
744
738
|
break;
|
|
745
739
|
}
|
|
746
|
-
case
|
|
747
|
-
case
|
|
740
|
+
case CHART_SUMMARY_TYPE.MAX:
|
|
741
|
+
case CHART_SUMMARY_TYPE.MIN:
|
|
748
742
|
{
|
|
749
743
|
if (rowsLength > 0) {
|
|
750
744
|
let result = rows.reduce((current, next) => {
|
|
751
745
|
let currentValue, nextValue;
|
|
752
|
-
if (
|
|
746
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
753
747
|
let currentFormulaRow = formula_rows[current._id] || {};
|
|
754
748
|
let nextFormulaRow = formula_rows[next._id] || {};
|
|
755
749
|
currentValue = currentFormulaRow[summary_column_key];
|
|
@@ -768,7 +762,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
768
762
|
return isNextGreater ? next : current;
|
|
769
763
|
}
|
|
770
764
|
});
|
|
771
|
-
if (
|
|
765
|
+
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
772
766
|
let formulaRow = formula_rows[result._id];
|
|
773
767
|
if (formulaRow) {
|
|
774
768
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
@@ -862,8 +856,8 @@ function getAllSummaryColumns(singleSummaryColumn, multipleSummaryColumns, table
|
|
|
862
856
|
allSummaryColumns.push(singleSummaryColumn);
|
|
863
857
|
}
|
|
864
858
|
multipleSummaryColumns && multipleSummaryColumns.forEach(item => {
|
|
865
|
-
if (item
|
|
866
|
-
allSummaryColumns.push(
|
|
859
|
+
if (item === null || item === void 0 ? void 0 : item.column_key) {
|
|
860
|
+
allSummaryColumns.push(getTableColumnByKey(table, item.column_key));
|
|
867
861
|
}
|
|
868
862
|
});
|
|
869
863
|
return allSummaryColumns;
|
|
@@ -893,4 +887,4 @@ function calculator(chart, value, _ref3) {
|
|
|
893
887
|
getTableFormulaResults
|
|
894
888
|
});
|
|
895
889
|
}
|
|
896
|
-
|
|
890
|
+
export default calculator;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _dtableUtils = require("dtable-utils");
|
|
9
|
-
var _baseUtils = _interopRequireDefault(require("../base-utils"));
|
|
10
|
-
var _cellValueUtils = require("../../cell-value-utils");
|
|
11
|
-
var _rowUtils = require("../../row-utils");
|
|
12
|
-
var _constants = require("../../../constants");
|
|
1
|
+
import { isNumber, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import BaseUtils from '../base-utils';
|
|
3
|
+
import { isArrayCellValue } from '../../cell-value-utils';
|
|
4
|
+
import { getCellValue, getFormattedLabel } from '../../row-utils';
|
|
5
|
+
import { CHART_SUMMARY_TYPE } from '../../../constants';
|
|
13
6
|
function updateBasicChartRows(results, index, name, dataItem, row) {
|
|
14
7
|
let updatedResult;
|
|
15
8
|
if (index > -1) {
|
|
@@ -26,11 +19,11 @@ function updateBasicChartRows(results, index, name, dataItem, row) {
|
|
|
26
19
|
}
|
|
27
20
|
function getColumnValue(data, formulaRow, column, dtableValue) {
|
|
28
21
|
const tempValue = data[column.key];
|
|
29
|
-
let value =
|
|
30
|
-
if (
|
|
22
|
+
let value = BaseUtils.getGroupLabel(tempValue, formulaRow, column, CHART_SUMMARY_TYPE.DAY, '', dtableValue);
|
|
23
|
+
if (isArrayCellValue(column)) {
|
|
31
24
|
value = value[0];
|
|
32
25
|
}
|
|
33
|
-
value =
|
|
26
|
+
value = getFormattedLabel(column, value, dtableValue.collaborators);
|
|
34
27
|
return value;
|
|
35
28
|
}
|
|
36
29
|
async function calculator(chart, value, _ref) {
|
|
@@ -45,14 +38,14 @@ async function calculator(chart, value, _ref) {
|
|
|
45
38
|
y_axis_column_key,
|
|
46
39
|
column_groupby_column_key
|
|
47
40
|
} = chart;
|
|
48
|
-
const table =
|
|
49
|
-
const view = table &&
|
|
41
|
+
const table = getTableById(value.tables, table_id);
|
|
42
|
+
const view = table && getViewById(table.views, view_id);
|
|
50
43
|
if (!view) {
|
|
51
44
|
return [];
|
|
52
45
|
}
|
|
53
|
-
const selectedXAxisColumn =
|
|
54
|
-
const selectedYAxisColumn =
|
|
55
|
-
const selectedGroupColumn =
|
|
46
|
+
const selectedXAxisColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
47
|
+
const selectedYAxisColumn = getTableColumnByKey(table, y_axis_column_key);
|
|
48
|
+
const selectedGroupColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
56
49
|
const statRows = await getViewRows(view, table);
|
|
57
50
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
58
51
|
const data = [];
|
|
@@ -61,10 +54,10 @@ async function calculator(chart, value, _ref) {
|
|
|
61
54
|
_id: rowId
|
|
62
55
|
} = row;
|
|
63
56
|
const formulaRow = formulaRows[rowId] || {};
|
|
64
|
-
let x_axis =
|
|
65
|
-
let y_axis =
|
|
66
|
-
x_axis =
|
|
67
|
-
y_axis =
|
|
57
|
+
let x_axis = getCellValue(row, formulaRow, selectedXAxisColumn);
|
|
58
|
+
let y_axis = getCellValue(row, formulaRow, selectedYAxisColumn);
|
|
59
|
+
x_axis = isNumber(x_axis) ? x_axis : 0;
|
|
60
|
+
y_axis = isNumber(y_axis) ? y_axis : 0;
|
|
68
61
|
const name = getColumnValue(row, formulaRow, selectedGroupColumn, value);
|
|
69
62
|
const nameIndex = data.findIndex(r => r.name === name && r.x_axis === x_axis && r.y_axis === y_axis);
|
|
70
63
|
const dataItem = {
|
|
@@ -74,7 +67,7 @@ async function calculator(chart, value, _ref) {
|
|
|
74
67
|
};
|
|
75
68
|
updateBasicChartRows(data, nameIndex, name, dataItem, row);
|
|
76
69
|
});
|
|
77
|
-
|
|
70
|
+
BaseUtils.sortCharts(data, selectedXAxisColumn, 'name');
|
|
78
71
|
return data;
|
|
79
72
|
}
|
|
80
|
-
|
|
73
|
+
export default calculator;
|