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