sea-chart 1.1.65 → 2.0.0
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 +13 -6
- package/dist/assets/css/sea-chart-d3-tooltip.css +64 -0
- package/dist/components/cell-factory/FormatterConfig.js +62 -55
- package/dist/components/cell-factory/SimpleCellFormatter.js +11 -4
- 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 +35 -27
- 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 +18 -11
- package/dist/components/color-popover/color-rules/color-rule.js +33 -25
- package/dist/components/color-popover/color-rules/index.js +14 -6
- 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 +33 -25
- package/dist/components/color-popover/color-selector-popover.js +18 -10
- package/dist/components/color-setting/color-group-selector.js +20 -12
- package/dist/components/common-add-tool/index.js +13 -6
- package/dist/components/data-process-setter/data-setting-header.js +14 -7
- package/dist/components/data-process-setter/hide-column-setter.js +19 -12
- package/dist/components/data-process-setter/index.js +27 -4
- package/dist/components/data-process-setter/sort-setter.js +24 -16
- 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 +14 -7
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +35 -27
- 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 +22 -15
- package/dist/components/row-card/row-card-header.js +21 -14
- package/dist/components/row-card/row-card-item.js +41 -33
- package/dist/components/row-card/row-card.js +23 -15
- package/dist/components/statistic-record-dialog/index.js +63 -55
- package/dist/components/types-dialog/index.js +63 -55
- 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 +19 -12
- package/dist/editor/index.js +15 -12
- 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 +17 -10
- 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 +13 -7
- package/dist/settings/advance-bar-settings/data-settings.js +46 -42
- package/dist/settings/advance-bar-settings/index.js +20 -3
- package/dist/settings/advance-bar-settings/style-settings.js +73 -69
- package/dist/settings/bar-settings/data-settings.js +49 -45
- package/dist/settings/bar-settings/index.js +20 -3
- package/dist/settings/bar-settings/style-settings.js +59 -55
- 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 +26 -18
- package/dist/settings/combination-settings/data-settings.js +65 -60
- package/dist/settings/combination-settings/index.js +20 -3
- package/dist/settings/combination-settings/style-settings.js +74 -69
- 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 +30 -22
- 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 +75 -58
- 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 +34 -26
- 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 +72 -64
- package/dist/settings/table-element-settings/components/data-filter.js +37 -29
- 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 +119 -111
- 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 +25 -17
- package/dist/settings/widgets/basic-summary/index.js +66 -66
- package/dist/settings/widgets/chart-type/index.js +34 -19
- package/dist/settings/widgets/color-settings/index.js +80 -72
- package/dist/settings/widgets/common-data-settings.js +30 -25
- package/dist/settings/widgets/data-filter/index.js +40 -32
- package/dist/settings/widgets/data-sort.js +24 -16
- package/dist/settings/widgets/date-summary-item.js +32 -24
- 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 +31 -23
- 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 +80 -72
- package/dist/settings/widgets/switch/index.js +15 -8
- 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 +71 -63
- package/dist/utils/cell-format-utils.js +29 -19
- package/dist/utils/cell-value-utils.js +11 -4
- package/dist/utils/chart-utils/base-utils.js +290 -279
- package/dist/utils/chart-utils/index.js +39 -26
- 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 +26 -19
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +39 -32
- 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 +25 -18
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +34 -27
- 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 +30 -18
- package/dist/utils/collaborator.js +13 -4
- package/dist/utils/color-utils.js +29 -18
- package/dist/utils/column-utils.js +88 -63
- package/dist/utils/common-utils.js +52 -27
- package/dist/utils/concurrency-manager.js +7 -1
- package/dist/utils/contexts.js +11 -4
- package/dist/utils/custom-g2.js +241 -212
- package/dist/utils/date-translate.js +19 -11
- 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 +219 -53
- package/dist/utils/key-generator.js +9 -2
- package/dist/utils/map.js +31 -22
- package/dist/utils/object-utils.js +7 -1
- package/dist/utils/options-utils.js +16 -8
- package/dist/utils/row-record-utils.js +164 -152
- package/dist/utils/row-utils.js +38 -27
- package/dist/utils/search.js +32 -24
- package/dist/utils/sql/chart-data-sql.js +55 -49
- package/dist/utils/sql/column-2-sql-column.js +153 -143
- package/dist/utils/sql/index.js +27 -3
- package/dist/utils/trend-utils.js +45 -37
- package/dist/view/index.js +96 -87
- package/dist/view/title/index.js +23 -15
- package/dist/view/wrapper/area.js +46 -39
- package/dist/view/wrapper/bar-custom.js +40 -33
- package/dist/view/wrapper/bar-group.js +58 -51
- package/dist/view/wrapper/bar.js +42 -35
- package/dist/view/wrapper/basic-number-card.js +25 -17
- package/dist/view/wrapper/chart-component.js +116 -54
- package/dist/view/wrapper/combination.js +82 -75
- package/dist/view/wrapper/compare.js +57 -50
- package/dist/view/wrapper/completeness.js +32 -24
- package/dist/view/wrapper/dashboard.js +21 -14
- package/dist/view/wrapper/funnel.js +26 -19
- package/dist/view/wrapper/heat-map.js +60 -53
- package/dist/view/wrapper/horizontal-bar-group.js +48 -41
- package/dist/view/wrapper/horizontal-bar.js +39 -32
- package/dist/view/wrapper/horizontal-component.js +23 -15
- package/dist/view/wrapper/index.js +148 -96
- package/dist/view/wrapper/line-group.js +41 -34
- package/dist/view/wrapper/line.js +39 -32
- package/dist/view/wrapper/map.js +54 -46
- package/dist/view/wrapper/mirror.js +38 -31
- package/dist/view/wrapper/pie.js +50 -43
- package/dist/view/wrapper/ring.js +59 -52
- package/dist/view/wrapper/scatter.js +30 -22
- package/dist/view/wrapper/table/index.js +21 -13
- 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 +58 -50
- package/dist/view/wrapper/table/pivot-table-display-name.js +90 -82
- package/dist/view/wrapper/table/two-dimension-table.js +84 -76
- package/dist/view/wrapper/table-element/components/dataset-utils.js +36 -23
- package/dist/view/wrapper/table-element/components/formatter.js +98 -89
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +31 -22
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/record.js +17 -10
- package/dist/view/wrapper/table-element/components/records-body.js +17 -9
- package/dist/view/wrapper/table-element/components/records-header/index.js +16 -8
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +16 -8
- package/dist/view/wrapper/table-element/components/records.js +29 -21
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +13 -6
- package/dist/view/wrapper/table-element/components/utils.js +15 -5
- 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 +24 -16
- package/dist/view/wrapper/treemap.js +43 -36
- package/dist/view/wrapper/trend.js +47 -39
- package/dist/view/wrapper/world-map.js +60 -52
- package/dist/view/wrapper/wrappers-d3/bar.js +262 -0
- package/package.json +15 -17
|
@@ -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,17 +235,17 @@ 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
|
}
|
|
242
|
-
const isRowGroupbyColumnDataAsAnArray = isArrayCellValue(rowGroupbyColumn);
|
|
248
|
+
const isRowGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(rowGroupbyColumn);
|
|
243
249
|
const statRows = await getViewRows(view, table);
|
|
244
250
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
245
251
|
let pivot_columns = [];
|
|
@@ -249,12 +255,12 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
249
255
|
_id: rowId
|
|
250
256
|
} = row;
|
|
251
257
|
const formulaRow = formulaRows[rowId];
|
|
252
|
-
const cellValueForColumn =
|
|
253
|
-
if (isValidRow(row, formulaRow, rowGroupbyColumn, include_empty)) {
|
|
258
|
+
const cellValueForColumn = _baseUtils.default.getGroupLabel(row[rowGroupbyColumn.key], formulaRow, rowGroupbyColumn, column_groupby_date_granularity, column_groupby_geolocation_granularity, value);
|
|
259
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, rowGroupbyColumn, include_empty)) {
|
|
254
260
|
updateTwoDimensionColumns(value, pivot_columns, rowGroupbyColumn, row, formulaRow, include_empty, column_groupby_date_granularity, column_groupby_geolocation_granularity, isRowGroupbyColumnDataAsAnArray);
|
|
255
261
|
}
|
|
256
|
-
if (isValidRow(row, formulaRow, groupbyColumn, include_empty)) {
|
|
257
|
-
const name =
|
|
262
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, groupbyColumn, include_empty)) {
|
|
263
|
+
const name = _baseUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupby_date_granularity, groupby_geolocation_granularity, value);
|
|
258
264
|
let pivotRowIndex;
|
|
259
265
|
if (isGroupbyColumnDataAsAnArray) {
|
|
260
266
|
if (name.length === 0 && include_empty) {
|
|
@@ -276,7 +282,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
276
282
|
});
|
|
277
283
|
let summaryColumn = null;
|
|
278
284
|
if (summary_column_key) {
|
|
279
|
-
summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
285
|
+
summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
// Single field
|
|
@@ -293,7 +299,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
293
299
|
column_key,
|
|
294
300
|
summary_method
|
|
295
301
|
} = item;
|
|
296
|
-
const itemSummaryColumn = getTableColumnByKey(table, column_key);
|
|
302
|
+
const itemSummaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, column_key);
|
|
297
303
|
const itemSummaryMethod = summary_method;
|
|
298
304
|
if (itemSummaryColumn && itemSummaryMethod) {
|
|
299
305
|
// The index of a single field is 0, so the index of a multiple-select field starts at 1.
|
|
@@ -312,18 +318,18 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
312
318
|
}
|
|
313
319
|
});
|
|
314
320
|
}
|
|
315
|
-
|
|
316
|
-
|
|
321
|
+
_baseUtils.default.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
322
|
+
_baseUtils.default.sortCharts(pivot_columns, rowGroupbyColumn, 'key');
|
|
317
323
|
|
|
318
324
|
// format shown label(name)
|
|
319
325
|
const map = {};
|
|
320
326
|
pivot_columns.forEach(column => {
|
|
321
|
-
const name = getFormattedLabel(rowGroupbyColumn, column.key, value.collaborators, chart.type);
|
|
327
|
+
const name = (0, _rowUtils.getFormattedLabel)(rowGroupbyColumn, column.key, value.collaborators, chart.type);
|
|
322
328
|
map[column.key] = name;
|
|
323
329
|
column.key = name;
|
|
324
330
|
});
|
|
325
331
|
pivot_rows.forEach(row => {
|
|
326
|
-
row.name = getFormattedLabel(groupbyColumn, row.name, value.collaborators, chart.type);
|
|
332
|
+
row.name = (0, _rowUtils.getFormattedLabel)(groupbyColumn, row.name, value.collaborators, chart.type);
|
|
327
333
|
const cells = {};
|
|
328
334
|
Object.keys(row.cells).forEach(key => {
|
|
329
335
|
cells[map[key]] = row.cells[key];
|
|
@@ -340,13 +346,13 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
340
346
|
pivot_columns_total: new_pivot_columns_total,
|
|
341
347
|
pivot_table_total,
|
|
342
348
|
formulaRows,
|
|
343
|
-
dimensions: TABLE_DIMENSIONS.TWO,
|
|
349
|
+
dimensions: _constants.TABLE_DIMENSIONS.TWO,
|
|
344
350
|
summary_columns: getAllSummaryColumns(summaryColumn, summary_columns, table),
|
|
345
351
|
isSingleNumericColumn: !summary_columns.length ? 'true' : 'false'
|
|
346
352
|
};
|
|
347
353
|
}
|
|
348
354
|
function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
|
|
349
|
-
let key =
|
|
355
|
+
let key = _baseUtils.default.getGroupLabel(row[column.key], formulaRow, column, dateGranularity, geolocationGranularity, value);
|
|
350
356
|
let pivotColumnIndex;
|
|
351
357
|
if (isRowGroupbyColumnDataAsAnArray) {
|
|
352
358
|
if (key.length === 0 && isIncludeEmpty) {
|
|
@@ -388,7 +394,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
388
394
|
summary_column_key,
|
|
389
395
|
summary_method
|
|
390
396
|
} = chart;
|
|
391
|
-
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
397
|
+
const isCount = summary_type === _constants.CHART_SUMMARY_TYPE.COUNT;
|
|
392
398
|
let summarySQLColumnName2ColumnKey = {};
|
|
393
399
|
let numericColumns = [];
|
|
394
400
|
if (summary_column_key) {
|
|
@@ -403,11 +409,11 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
403
409
|
summary_method: item_summary_method
|
|
404
410
|
} = item;
|
|
405
411
|
const summaryMethod = item_summary_method.toUpperCase();
|
|
406
|
-
const column = getTableColumnByKey(table, column_key);
|
|
407
|
-
if (column && (
|
|
412
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, column_key);
|
|
413
|
+
if (column && (_baseUtils.default.isDateSummaryColumn(column) || _baseUtils.default.isNumericSummaryColumn(column))) {
|
|
408
414
|
const {
|
|
409
415
|
key: sqlNumericColumnKey
|
|
410
|
-
} = summaryMethodColumn2SqlColumn(summaryMethod, column);
|
|
416
|
+
} = (0, _column2SqlColumn.summaryMethodColumn2SqlColumn)(summaryMethod, column);
|
|
411
417
|
const {
|
|
412
418
|
key: summaryColumnKey
|
|
413
419
|
} = column;
|
|
@@ -415,12 +421,12 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
415
421
|
}
|
|
416
422
|
});
|
|
417
423
|
const summarySQLColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
|
|
418
|
-
const summaryColumn = getTableColumnByKey(table, summary_column_key) || {};
|
|
424
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key) || {};
|
|
419
425
|
const singleNumeriColumnWithMethod = {
|
|
420
426
|
column: summaryColumn,
|
|
421
427
|
summary_method
|
|
422
428
|
};
|
|
423
|
-
const summaryColumnsWithMethod =
|
|
429
|
+
const summaryColumnsWithMethod = _baseUtils.default.getSummaryColumnsWithMethod(table, {
|
|
424
430
|
config: chart
|
|
425
431
|
});
|
|
426
432
|
const multipleNumericColumnsWithMethod = summaryColumnsWithMethod;
|
|
@@ -434,7 +440,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
434
440
|
let {
|
|
435
441
|
key
|
|
436
442
|
} = c;
|
|
437
|
-
if (
|
|
443
|
+
if (_baseUtils.default.isSameGroup(isColumnDataAsAnArray, cellValue, key)) {
|
|
438
444
|
if (cells[key]) {
|
|
439
445
|
cells[key].rows.push(row);
|
|
440
446
|
if (isCount) {
|
|
@@ -444,7 +450,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
444
450
|
const current = all.find(item => item.column.key === columnKey);
|
|
445
451
|
const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
|
|
446
452
|
const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
|
|
447
|
-
const computedValue =
|
|
453
|
+
const computedValue = _baseUtils.default.getSummaryValue({
|
|
448
454
|
summaryMethod: current.summary_method.toUpperCase(),
|
|
449
455
|
summaryColumn: current.column
|
|
450
456
|
}, currentValue, nextValue, true);
|
|
@@ -483,7 +489,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
483
489
|
} else {
|
|
484
490
|
updatedPivotRow.total = Object.values(cells).reduce((acc, item) => {
|
|
485
491
|
item.total.forEach(t => {
|
|
486
|
-
isNumber(t[1]) && (acc += t[1]);
|
|
492
|
+
(0, _dtableUtils.isNumber)(t[1]) && (acc += t[1]);
|
|
487
493
|
});
|
|
488
494
|
return acc;
|
|
489
495
|
}, 0);
|
|
@@ -499,7 +505,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
499
505
|
let {
|
|
500
506
|
key
|
|
501
507
|
} = c;
|
|
502
|
-
if (
|
|
508
|
+
if (_baseUtils.default.isSameGroup(isColumnDataAsAnArray, cellValue, key)) {
|
|
503
509
|
let total;
|
|
504
510
|
if (isCount) {
|
|
505
511
|
total = row[groupbyColumn.key];
|
|
@@ -521,9 +527,9 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
521
527
|
const cellList = Object.values(cells);
|
|
522
528
|
total = cellList.reduce((acc, item) => {
|
|
523
529
|
let num;
|
|
524
|
-
if (isObject(item.total)) {
|
|
530
|
+
if ((0, _lodash.isObject)(item.total)) {
|
|
525
531
|
num = item.total.reduce((acc, item) => {
|
|
526
|
-
isNumber(item[1]) && (acc += item[1]);
|
|
532
|
+
(0, _dtableUtils.isNumber)(item[1]) && (acc += item[1]);
|
|
527
533
|
return acc;
|
|
528
534
|
}, 0);
|
|
529
535
|
} else {
|
|
@@ -549,7 +555,7 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
549
555
|
let {
|
|
550
556
|
type: summary_column_type
|
|
551
557
|
} = summaryColumn || {};
|
|
552
|
-
const isSummaryDateColumn = summaryColumn && isDateColumn(summaryColumn);
|
|
558
|
+
const isSummaryDateColumn = summaryColumn && (0, _dtableUtils.isDateColumn)(summaryColumn);
|
|
553
559
|
let date_summary_column_format = isSummaryDateColumn ? summaryColumn.data.format : '';
|
|
554
560
|
Array.isArray(pivot_rows) && pivot_rows.forEach(pivotRow => {
|
|
555
561
|
let {
|
|
@@ -597,8 +603,8 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
597
603
|
pivot_table_total += total;
|
|
598
604
|
}
|
|
599
605
|
});
|
|
600
|
-
if (summaryColumn && isDateColumn(summaryColumn)) {
|
|
601
|
-
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
606
|
+
if (summaryColumn && (0, _dtableUtils.isDateColumn)(summaryColumn)) {
|
|
607
|
+
if (summary_method === _constants.CHART_SUMMARY_TYPE.Distinct_values) {
|
|
602
608
|
pivot_columns_total = Number.parseFloat(pivot_table_total.toFixed(8));
|
|
603
609
|
} else {
|
|
604
610
|
pivot_columns_total = showTwoDimensionDateColumnsAndRowsTotal(dateColumnsTotalArr, pivot_rows, date_summary_column_format, pivot_columns, summary_method);
|
|
@@ -619,7 +625,7 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
619
625
|
|
|
620
626
|
// utils
|
|
621
627
|
function isSameName(prevName, currName) {
|
|
622
|
-
if (isNumber(prevName) && isNumber(currName)) {
|
|
628
|
+
if ((0, _dtableUtils.isNumber)(prevName) && (0, _dtableUtils.isNumber)(currName)) {
|
|
623
629
|
return prevName === currName;
|
|
624
630
|
}
|
|
625
631
|
if (!prevName && !currName) {
|
|
@@ -642,15 +648,15 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
642
648
|
const summary_column_type = summary_column ? summary_column.type : '';
|
|
643
649
|
const rowsLength = rows.length;
|
|
644
650
|
let total;
|
|
645
|
-
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
651
|
+
if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
646
652
|
total = rowsLength;
|
|
647
|
-
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
648
|
-
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values || summary_method === 'Distinct_values') {
|
|
653
|
+
} else if (summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
654
|
+
if (summary_method === _constants.CHART_SUMMARY_TYPE.Distinct_values || summary_method === 'Distinct_values') {
|
|
649
655
|
total = 0;
|
|
650
656
|
let existMap = {};
|
|
651
657
|
rows.forEach(row => {
|
|
652
658
|
let num;
|
|
653
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
659
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
654
660
|
const formulaRow = formula_rows[row._id] || {};
|
|
655
661
|
num = formulaRow[summary_column_key];
|
|
656
662
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -672,14 +678,14 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
672
678
|
total = getTotalByType(oldTotal, total, index);
|
|
673
679
|
return total;
|
|
674
680
|
}
|
|
675
|
-
if (summary_column && isDateColumn(summary_column)) {
|
|
681
|
+
if (summary_column && (0, _dtableUtils.isDateColumn)(summary_column)) {
|
|
676
682
|
if (rowsLength === 0) return;
|
|
677
683
|
let dateArr = [];
|
|
678
684
|
rows.forEach(r => {
|
|
679
685
|
let formatDate = {};
|
|
680
686
|
let formatDateData;
|
|
681
687
|
let value = r[summary_column_key];
|
|
682
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
688
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
683
689
|
let formulaRow = formula_rows[r._id] || {};
|
|
684
690
|
value = formulaRow[summary_column_key] || '';
|
|
685
691
|
value = Array.isArray(value) && value.length !== 0 ? value[0] : '';
|
|
@@ -697,21 +703,21 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
697
703
|
formatDate.value = Date.parse(formatDateData);
|
|
698
704
|
dateArr.push(formatDate);
|
|
699
705
|
});
|
|
700
|
-
if (summary_method === CHART_SUMMARY_TYPE.MAX) {
|
|
701
|
-
total = getDateMaxOrMinTotal(dateArr, CHART_SUMMARY_TYPE.MAX);
|
|
702
|
-
} else if (summary_method === CHART_SUMMARY_TYPE.MIN) {
|
|
703
|
-
total = getDateMaxOrMinTotal(dateArr, CHART_SUMMARY_TYPE.MIN);
|
|
706
|
+
if (summary_method === _constants.CHART_SUMMARY_TYPE.MAX) {
|
|
707
|
+
total = getDateMaxOrMinTotal(dateArr, _constants.CHART_SUMMARY_TYPE.MAX);
|
|
708
|
+
} else if (summary_method === _constants.CHART_SUMMARY_TYPE.MIN) {
|
|
709
|
+
total = getDateMaxOrMinTotal(dateArr, _constants.CHART_SUMMARY_TYPE.MIN);
|
|
704
710
|
}
|
|
705
711
|
} else {
|
|
706
712
|
switch (summary_method) {
|
|
707
|
-
case CHART_SUMMARY_TYPE.SUM:
|
|
708
|
-
case CHART_SUMMARY_TYPE.MEAN:
|
|
713
|
+
case _constants.CHART_SUMMARY_TYPE.SUM:
|
|
714
|
+
case _constants.CHART_SUMMARY_TYPE.MEAN:
|
|
709
715
|
{
|
|
710
716
|
let sum = 0;
|
|
711
717
|
let validNumbersCount = 0;
|
|
712
718
|
rows.forEach(r => {
|
|
713
719
|
let num;
|
|
714
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
720
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
715
721
|
let formulaRow = formula_rows[r._id] || {};
|
|
716
722
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
717
723
|
num = formulaRow[summary_column_key][0];
|
|
@@ -721,7 +727,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
721
727
|
} else {
|
|
722
728
|
num = r[summary_column_key];
|
|
723
729
|
}
|
|
724
|
-
if (isNumber(num)) {
|
|
730
|
+
if ((0, _dtableUtils.isNumber)(num)) {
|
|
725
731
|
validNumbersCount++;
|
|
726
732
|
sum += num;
|
|
727
733
|
}
|
|
@@ -734,13 +740,13 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
734
740
|
}
|
|
735
741
|
break;
|
|
736
742
|
}
|
|
737
|
-
case CHART_SUMMARY_TYPE.MAX:
|
|
738
|
-
case CHART_SUMMARY_TYPE.MIN:
|
|
743
|
+
case _constants.CHART_SUMMARY_TYPE.MAX:
|
|
744
|
+
case _constants.CHART_SUMMARY_TYPE.MIN:
|
|
739
745
|
{
|
|
740
746
|
if (rowsLength > 0) {
|
|
741
747
|
let result = rows.reduce((current, next) => {
|
|
742
748
|
let currentValue, nextValue;
|
|
743
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
749
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
744
750
|
let currentFormulaRow = formula_rows[current._id] || {};
|
|
745
751
|
let nextFormulaRow = formula_rows[next._id] || {};
|
|
746
752
|
currentValue = currentFormulaRow[summary_column_key];
|
|
@@ -759,7 +765,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
759
765
|
return isNextGreater ? next : current;
|
|
760
766
|
}
|
|
761
767
|
});
|
|
762
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
768
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
763
769
|
let formulaRow = formula_rows[result._id];
|
|
764
770
|
if (formulaRow) {
|
|
765
771
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
@@ -853,8 +859,8 @@ function getAllSummaryColumns(singleSummaryColumn, multipleSummaryColumns, table
|
|
|
853
859
|
allSummaryColumns.push(singleSummaryColumn);
|
|
854
860
|
}
|
|
855
861
|
multipleSummaryColumns && multipleSummaryColumns.forEach(item => {
|
|
856
|
-
if (item
|
|
857
|
-
allSummaryColumns.push(getTableColumnByKey(table, item.column_key));
|
|
862
|
+
if (item !== null && item !== void 0 && item.column_key) {
|
|
863
|
+
allSummaryColumns.push((0, _dtableUtils.getTableColumnByKey)(table, item.column_key));
|
|
858
864
|
}
|
|
859
865
|
});
|
|
860
866
|
return allSummaryColumns;
|
|
@@ -884,4 +890,4 @@ function calculator(chart, value, _ref3) {
|
|
|
884
890
|
getTableFormulaResults
|
|
885
891
|
});
|
|
886
892
|
}
|
|
887
|
-
|
|
893
|
+
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 = {
|
|
@@ -69,4 +76,4 @@ async function calculator(chart, value, _ref) {
|
|
|
69
76
|
});
|
|
70
77
|
return data;
|
|
71
78
|
}
|
|
72
|
-
|
|
79
|
+
var _default = exports.default = calculator;
|