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