sea-chart 2.0.36 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +49 -57
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +65 -73
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,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 _constants = require("../../../constants");
|
|
12
|
-
var _rowUtils = require("../../row-utils");
|
|
1
|
+
import { isNumber, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import BaseUtils from '../base-utils';
|
|
3
|
+
import { isArrayCellValue } from '../../cell-value-utils';
|
|
4
|
+
import { CHART_SUMMARY_TYPE, STYLE_COLORS } from '../../../constants';
|
|
5
|
+
import { getCellValue, getFormattedLabel } from '../../row-utils';
|
|
13
6
|
async function calculator(chart, value, _ref) {
|
|
14
7
|
let {
|
|
15
8
|
getViewRows,
|
|
@@ -32,42 +25,42 @@ async function calculator(chart, value, _ref) {
|
|
|
32
25
|
y_axis_left_group_by_numeric_columns,
|
|
33
26
|
type
|
|
34
27
|
} = chart;
|
|
35
|
-
const table =
|
|
36
|
-
const view = table &&
|
|
28
|
+
const table = getTableById(value.tables, table_id);
|
|
29
|
+
const view = table && getViewById(table.views, view_id);
|
|
37
30
|
if (!view) {
|
|
38
31
|
return [];
|
|
39
32
|
}
|
|
40
|
-
const xAxisColumn =
|
|
33
|
+
const xAxisColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
41
34
|
if (!xAxisColumn) return [];
|
|
42
35
|
const statRows = await getViewRows(view, table);
|
|
43
36
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
44
|
-
const column1 =
|
|
45
|
-
const column2 =
|
|
37
|
+
const column1 = getTableColumnByKey(table, y_axis_left_summary_column);
|
|
38
|
+
const column2 = getTableColumnByKey(table, y_axis_right_summary_column);
|
|
46
39
|
const leftResultMap = new Map();
|
|
47
40
|
const rightResultMap = new Map();
|
|
48
|
-
let isColumnDataAsAnArray =
|
|
41
|
+
let isColumnDataAsAnArray = isArrayCellValue(xAxisColumn);
|
|
49
42
|
let leftSummaryColumn = {};
|
|
50
43
|
let leftSummaryColumnKeys = [];
|
|
51
|
-
if (y_axis_left_summary_type ===
|
|
44
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
52
45
|
if (column1) {
|
|
53
46
|
leftSummaryColumn[y_axis_left_summary_column] = {
|
|
54
47
|
method: y_axis_left_summary_method,
|
|
55
48
|
column_name: column1.name,
|
|
56
49
|
type: column1.type,
|
|
57
50
|
data: column1.data,
|
|
58
|
-
color:
|
|
51
|
+
color: STYLE_COLORS[0].colors[0]
|
|
59
52
|
};
|
|
60
53
|
}
|
|
61
54
|
if (y_axis_left_group_by_multiple_numeric_column) {
|
|
62
55
|
y_axis_left_group_by_numeric_columns.forEach((item, index) => {
|
|
63
|
-
const summaryColumn =
|
|
56
|
+
const summaryColumn = getTableColumnByKey(table, item.column_key);
|
|
64
57
|
if (summaryColumn) {
|
|
65
58
|
leftSummaryColumn[item.column_key] = {
|
|
66
59
|
method: item.summary_method,
|
|
67
60
|
column_name: summaryColumn.name,
|
|
68
61
|
type: summaryColumn.type,
|
|
69
62
|
data: summaryColumn.data,
|
|
70
|
-
color:
|
|
63
|
+
color: STYLE_COLORS[0].colors[index % 12]
|
|
71
64
|
};
|
|
72
65
|
}
|
|
73
66
|
});
|
|
@@ -80,10 +73,10 @@ async function calculator(chart, value, _ref) {
|
|
|
80
73
|
} = row;
|
|
81
74
|
let formulaRow = formulaRows[rowId];
|
|
82
75
|
const currentValue = row[xAxisColumn.key];
|
|
83
|
-
let label =
|
|
76
|
+
let label = BaseUtils.getGroupLabel(currentValue, formulaRow, xAxisColumn, groupby_date_granularity, groupby_geolocation_granularity, value);
|
|
84
77
|
|
|
85
78
|
// collect left y axis data
|
|
86
|
-
if (y_axis_left_summary_type ===
|
|
79
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
87
80
|
if (isColumnDataAsAnArray) {
|
|
88
81
|
if (label.length > 0) {
|
|
89
82
|
label.forEach(name => {
|
|
@@ -105,18 +98,18 @@ async function calculator(chart, value, _ref) {
|
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
|
-
if (y_axis_left_summary_type ===
|
|
101
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
109
102
|
if (isColumnDataAsAnArray) {
|
|
110
103
|
if (label.length > 0) {
|
|
111
104
|
label.forEach(name => {
|
|
112
105
|
const currentLabelMap = leftResultMap.get(name) || {};
|
|
113
106
|
leftSummaryColumnKeys.forEach(key => {
|
|
114
|
-
const cellValue =
|
|
107
|
+
const cellValue = getCellValue(row, formulaRow, {
|
|
115
108
|
...leftSummaryColumn[key],
|
|
116
109
|
key
|
|
117
110
|
});
|
|
118
111
|
const currentLabelList = currentLabelMap[key] || [];
|
|
119
|
-
if (
|
|
112
|
+
if (isNumber(cellValue)) {
|
|
120
113
|
currentLabelList.push(cellValue);
|
|
121
114
|
}
|
|
122
115
|
currentLabelMap[key] = currentLabelList;
|
|
@@ -127,12 +120,12 @@ async function calculator(chart, value, _ref) {
|
|
|
127
120
|
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
128
121
|
let currentValue = leftResultMap.get(null) || {};
|
|
129
122
|
leftSummaryColumnKeys.forEach(key => {
|
|
130
|
-
const cellValue =
|
|
123
|
+
const cellValue = getCellValue(row, formulaRow, {
|
|
131
124
|
...leftSummaryColumn[key],
|
|
132
125
|
key
|
|
133
126
|
});
|
|
134
127
|
const currentLabelList = currentValue[key] || [];
|
|
135
|
-
if (
|
|
128
|
+
if (isNumber(cellValue)) {
|
|
136
129
|
currentLabelList.push(cellValue);
|
|
137
130
|
}
|
|
138
131
|
currentValue[key] = currentLabelList;
|
|
@@ -143,12 +136,12 @@ async function calculator(chart, value, _ref) {
|
|
|
143
136
|
if (x_axis_include_empty_cells || label) {
|
|
144
137
|
const currentValue = leftResultMap.get(label) || {};
|
|
145
138
|
leftSummaryColumnKeys.forEach(key => {
|
|
146
|
-
const cellValue =
|
|
139
|
+
const cellValue = getCellValue(row, formulaRow, {
|
|
147
140
|
...leftSummaryColumn[key],
|
|
148
141
|
key
|
|
149
142
|
});
|
|
150
143
|
const currentList = currentValue[key] || [];
|
|
151
|
-
if (
|
|
144
|
+
if (isNumber(cellValue)) {
|
|
152
145
|
currentList.push(cellValue);
|
|
153
146
|
}
|
|
154
147
|
currentValue[key] = currentList;
|
|
@@ -159,7 +152,7 @@ async function calculator(chart, value, _ref) {
|
|
|
159
152
|
}
|
|
160
153
|
|
|
161
154
|
// collect right y axis data
|
|
162
|
-
if (y_axis_right_summary_type ===
|
|
155
|
+
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
163
156
|
if (isColumnDataAsAnArray) {
|
|
164
157
|
if (label.length > 0) {
|
|
165
158
|
label.forEach(name => {
|
|
@@ -181,13 +174,13 @@ async function calculator(chart, value, _ref) {
|
|
|
181
174
|
}
|
|
182
175
|
}
|
|
183
176
|
}
|
|
184
|
-
if (y_axis_right_summary_column && y_axis_right_summary_type ===
|
|
185
|
-
const cellValue =
|
|
177
|
+
if (y_axis_right_summary_column && y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
178
|
+
const cellValue = getCellValue(row, formulaRow, column2);
|
|
186
179
|
if (isColumnDataAsAnArray) {
|
|
187
180
|
if (label.length > 0) {
|
|
188
181
|
label.forEach(name => {
|
|
189
182
|
const currentLabelList = rightResultMap.get(name) || [];
|
|
190
|
-
if (
|
|
183
|
+
if (isNumber(cellValue)) {
|
|
191
184
|
currentLabelList.push(cellValue);
|
|
192
185
|
}
|
|
193
186
|
rightResultMap.set(name, currentLabelList);
|
|
@@ -195,7 +188,7 @@ async function calculator(chart, value, _ref) {
|
|
|
195
188
|
}
|
|
196
189
|
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
197
190
|
let currentValue = rightResultMap.get(null) || [];
|
|
198
|
-
if (
|
|
191
|
+
if (isNumber(cellValue)) {
|
|
199
192
|
currentValue.push(cellValue);
|
|
200
193
|
}
|
|
201
194
|
rightResultMap.set(null, currentValue);
|
|
@@ -203,7 +196,7 @@ async function calculator(chart, value, _ref) {
|
|
|
203
196
|
} else {
|
|
204
197
|
if (x_axis_include_empty_cells || label) {
|
|
205
198
|
const currentLabelList = rightResultMap.get(label) || [];
|
|
206
|
-
if (
|
|
199
|
+
if (isNumber(cellValue)) {
|
|
207
200
|
currentLabelList.push(cellValue);
|
|
208
201
|
}
|
|
209
202
|
rightResultMap.set(label, currentLabelList);
|
|
@@ -215,7 +208,7 @@ async function calculator(chart, value, _ref) {
|
|
|
215
208
|
// Summary collect data
|
|
216
209
|
let results = [];
|
|
217
210
|
let targetMap = leftResultMap;
|
|
218
|
-
if (leftSummaryColumnKeys.length === 0 && y_axis_left_summary_type ===
|
|
211
|
+
if (leftSummaryColumnKeys.length === 0 && y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
219
212
|
targetMap = rightResultMap;
|
|
220
213
|
}
|
|
221
214
|
for (let item of targetMap) {
|
|
@@ -226,23 +219,23 @@ async function calculator(chart, value, _ref) {
|
|
|
226
219
|
let formattedValueLeft = value1;
|
|
227
220
|
let formattedValueRight = value2;
|
|
228
221
|
const rightValue = rightResultMap.get(key);
|
|
229
|
-
if (y_axis_right_summary_type ===
|
|
222
|
+
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
230
223
|
value2 = rightValue;
|
|
231
224
|
formattedValueRight = value2;
|
|
232
225
|
}
|
|
233
|
-
if (y_axis_right_summary_type ===
|
|
234
|
-
value2 =
|
|
235
|
-
formattedValueRight =
|
|
226
|
+
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
227
|
+
value2 = BaseUtils.getSummaryResult(rightValue, y_axis_right_summary_method);
|
|
228
|
+
formattedValueRight = BaseUtils.getFormattedValue(value2, column2, y_axis_right_summary_method);
|
|
236
229
|
}
|
|
237
230
|
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
238
|
-
if (y_axis_left_summary_type ===
|
|
231
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
239
232
|
value1 = leftValue;
|
|
240
233
|
formattedValueLeft = value1;
|
|
241
234
|
}
|
|
242
|
-
if (y_axis_left_summary_type ===
|
|
235
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
243
236
|
const list = leftValue[column1.key];
|
|
244
|
-
value1 =
|
|
245
|
-
formattedValueLeft =
|
|
237
|
+
value1 = BaseUtils.getSummaryResult(list, y_axis_left_summary_method);
|
|
238
|
+
formattedValueLeft = BaseUtils.getFormattedValue(value1, column1, y_axis_left_summary_method);
|
|
246
239
|
}
|
|
247
240
|
results.push({
|
|
248
241
|
name: key,
|
|
@@ -256,14 +249,14 @@ async function calculator(chart, value, _ref) {
|
|
|
256
249
|
const summaryColumn = leftSummaryColumn[columnKey];
|
|
257
250
|
const summaryMethod = summaryColumn.method;
|
|
258
251
|
const list = leftValue[columnKey];
|
|
259
|
-
const value =
|
|
260
|
-
formattedValueLeft =
|
|
252
|
+
const value = BaseUtils.getSummaryResult(list, summaryMethod);
|
|
253
|
+
formattedValueLeft = BaseUtils.getFormattedValue(value, summaryColumn, summaryMethod);
|
|
261
254
|
results.push({
|
|
262
255
|
name: key,
|
|
263
256
|
value_left: value,
|
|
264
257
|
group_name: summaryColumn.column_name,
|
|
265
258
|
// color: leftSummaryColumn[columnKey].color,
|
|
266
|
-
color:
|
|
259
|
+
color: STYLE_COLORS[0].colors[index % 12],
|
|
267
260
|
value_right: value2,
|
|
268
261
|
formatted_value_left: formattedValueLeft,
|
|
269
262
|
formatted_value_right: formattedValueRight
|
|
@@ -271,10 +264,10 @@ async function calculator(chart, value, _ref) {
|
|
|
271
264
|
});
|
|
272
265
|
}
|
|
273
266
|
}
|
|
274
|
-
|
|
267
|
+
BaseUtils.sortCharts(results, xAxisColumn, 'name');
|
|
275
268
|
results.forEach(item => {
|
|
276
|
-
item.name =
|
|
269
|
+
item.name = getFormattedLabel(xAxisColumn, item.name, value.collaborators, type);
|
|
277
270
|
});
|
|
278
271
|
return results;
|
|
279
272
|
}
|
|
280
|
-
|
|
273
|
+
export default calculator;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _dtableUtils = require("dtable-utils");
|
|
9
|
-
var _baseUtils = _interopRequireDefault(require("../base-utils"));
|
|
10
|
-
var _rowUtils = require("../../row-utils");
|
|
11
|
-
var _constants = require("../../../constants");
|
|
1
|
+
import { getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import BaseUtils from '../base-utils';
|
|
3
|
+
import { getCellValue } from '../../row-utils';
|
|
4
|
+
import { CHART_SUMMARY_TYPE } from '../../../constants';
|
|
12
5
|
async function calculator(chart, value, _ref) {
|
|
13
6
|
let {
|
|
14
7
|
getViewRows,
|
|
@@ -28,25 +21,25 @@ async function calculator(chart, value, _ref) {
|
|
|
28
21
|
x_axis_compared_date_range_end,
|
|
29
22
|
display_increase
|
|
30
23
|
} = chart;
|
|
31
|
-
const groupName1 =
|
|
32
|
-
const groupName2 =
|
|
33
|
-
const table =
|
|
34
|
-
const view = table &&
|
|
24
|
+
const groupName1 = `${x_axis_date_range_start} - ${x_axis_date_range_end}`;
|
|
25
|
+
const groupName2 = `${x_axis_compared_date_range_start} - ${x_axis_compared_date_range_end}`;
|
|
26
|
+
const table = getTableById(value.tables, table_id);
|
|
27
|
+
const view = table && getViewById(table.views, view_id);
|
|
35
28
|
if (!view || !x_axis_column_key) {
|
|
36
29
|
return [];
|
|
37
30
|
}
|
|
38
|
-
const groupbyColumn =
|
|
31
|
+
const groupbyColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
39
32
|
if (!groupbyColumn) {
|
|
40
33
|
return [];
|
|
41
34
|
}
|
|
42
|
-
const summaryColumn =
|
|
35
|
+
const summaryColumn = getTableColumnByKey(table, y_axis_summary_column_key) || {};
|
|
43
36
|
const statRows = await getViewRows(view, table);
|
|
44
37
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
45
38
|
const dateRangeResultMap = new Map();
|
|
46
39
|
const comparedDateRangeResultMap = new Map();
|
|
47
40
|
const dateRangeRowMap = new Map();
|
|
48
41
|
const comparedDateRangeRowMap = new Map();
|
|
49
|
-
const isAdvance = y_axis_summary_type ===
|
|
42
|
+
const isAdvance = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
50
43
|
statRows.forEach(row => {
|
|
51
44
|
const {
|
|
52
45
|
_id: rowId
|
|
@@ -55,11 +48,11 @@ async function calculator(chart, value, _ref) {
|
|
|
55
48
|
const formulaRow = formulaRows[rowId];
|
|
56
49
|
if (!cellValue) return;
|
|
57
50
|
if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end || cellValue >= x_axis_compared_date_range_start && cellValue <= x_axis_compared_date_range_end) {
|
|
58
|
-
const name =
|
|
51
|
+
const name = BaseUtils.getGroupLabel(cellValue, formulaRow, groupbyColumn, x_axis_date_granularity, '', value);
|
|
59
52
|
if (cellValue >= x_axis_date_range_start && cellValue <= x_axis_date_range_end) {
|
|
60
53
|
if (isAdvance) {
|
|
61
54
|
const currentValue = dateRangeResultMap.get(name);
|
|
62
|
-
const _cellValue =
|
|
55
|
+
const _cellValue = getCellValue(row, formulaRow, summaryColumn);
|
|
63
56
|
if (!currentValue) {
|
|
64
57
|
dateRangeResultMap.set(name, [_cellValue]);
|
|
65
58
|
dateRangeRowMap.set(name, [row]);
|
|
@@ -79,7 +72,7 @@ async function calculator(chart, value, _ref) {
|
|
|
79
72
|
} else {
|
|
80
73
|
if (isAdvance) {
|
|
81
74
|
const currentValue = comparedDateRangeResultMap.get(name);
|
|
82
|
-
const _cellValue =
|
|
75
|
+
const _cellValue = getCellValue(row, formulaRow, summaryColumn);
|
|
83
76
|
if (!currentValue && summaryColumn) {
|
|
84
77
|
comparedDateRangeResultMap.set(name, [_cellValue]);
|
|
85
78
|
comparedDateRangeRowMap.set(name, [row]);
|
|
@@ -107,8 +100,8 @@ async function calculator(chart, value, _ref) {
|
|
|
107
100
|
let value = item[1];
|
|
108
101
|
let formatted_value = value;
|
|
109
102
|
if (isAdvance) {
|
|
110
|
-
value =
|
|
111
|
-
formatted_value =
|
|
103
|
+
value = BaseUtils.getSummaryResult(value, y_axis_summary_method, data.precision);
|
|
104
|
+
formatted_value = BaseUtils.getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
112
105
|
}
|
|
113
106
|
dateRangeResult.push({
|
|
114
107
|
name: key,
|
|
@@ -119,14 +112,14 @@ async function calculator(chart, value, _ref) {
|
|
|
119
112
|
rows: dateRangeRowMap.get(key)
|
|
120
113
|
});
|
|
121
114
|
}
|
|
122
|
-
|
|
115
|
+
BaseUtils.sortCharts(dateRangeResult, groupbyColumn, 'name');
|
|
123
116
|
for (let item of comparedDateRangeResultMap) {
|
|
124
117
|
const key = item[0];
|
|
125
118
|
let value = item[1];
|
|
126
119
|
let formatted_value = value;
|
|
127
120
|
if (isAdvance) {
|
|
128
|
-
value =
|
|
129
|
-
formatted_value =
|
|
121
|
+
value = BaseUtils.getSummaryResult(value, y_axis_summary_method, data.precision);
|
|
122
|
+
formatted_value = BaseUtils.getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
130
123
|
}
|
|
131
124
|
comparedDateRangeResult.push({
|
|
132
125
|
name: key,
|
|
@@ -137,7 +130,7 @@ async function calculator(chart, value, _ref) {
|
|
|
137
130
|
rows: comparedDateRangeRowMap.get(key)
|
|
138
131
|
});
|
|
139
132
|
}
|
|
140
|
-
|
|
133
|
+
BaseUtils.sortCharts(comparedDateRangeResult, groupbyColumn, 'name');
|
|
141
134
|
for (let i = 0; i < dateRangeResult.length; i++) {
|
|
142
135
|
if (!comparedDateRangeResult[i]) break;
|
|
143
136
|
comparedDateRangeResult[i].name = dateRangeResult[i].name;
|
|
@@ -156,4 +149,4 @@ async function calculator(chart, value, _ref) {
|
|
|
156
149
|
}
|
|
157
150
|
return [...comparedDateRangeResult, ...dateRangeResult];
|
|
158
151
|
}
|
|
159
|
-
|
|
152
|
+
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 _cellValueUtils = require("../../cell-value-utils");
|
|
10
|
-
var _rowUtils = require("../../row-utils");
|
|
11
|
-
var _baseUtils = _interopRequireDefault(require("../base-utils"));
|
|
12
|
-
var _constants = require("../../../constants");
|
|
1
|
+
import { FORMULA_COLUMN_TYPES_MAP, isNumber, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import { isArrayCellValue } from '../../cell-value-utils';
|
|
3
|
+
import { getCellValue, getFormattedLabel } from '../../row-utils';
|
|
4
|
+
import BaseUtils from '../base-utils';
|
|
5
|
+
import { PIE_CHART_COLORS } from '../../../constants';
|
|
13
6
|
async function calculator(chart, value, _ref) {
|
|
14
7
|
let {
|
|
15
8
|
getViewRows,
|
|
@@ -25,22 +18,22 @@ async function calculator(chart, value, _ref) {
|
|
|
25
18
|
date_granularity,
|
|
26
19
|
geolocation_granularity
|
|
27
20
|
} = chart;
|
|
28
|
-
const table =
|
|
29
|
-
const view = table &&
|
|
21
|
+
const table = getTableById(value.tables, table_id);
|
|
22
|
+
const view = table && getViewById(table.views, view_id);
|
|
30
23
|
if (!view) {
|
|
31
24
|
return [];
|
|
32
25
|
}
|
|
33
|
-
const nameColumn =
|
|
26
|
+
const nameColumn = getTableColumnByKey(table, groupby_column_key);
|
|
34
27
|
if (!nameColumn) return [];
|
|
35
28
|
const statRows = await getViewRows(view, table);
|
|
36
29
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
37
|
-
const groupColumn =
|
|
38
|
-
const isColumnDataAsAnArray =
|
|
30
|
+
const groupColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
31
|
+
const isColumnDataAsAnArray = isArrayCellValue(nameColumn);
|
|
39
32
|
const isGroupChart = !!groupColumn;
|
|
40
33
|
let result = [];
|
|
41
34
|
if (!isGroupChart) {
|
|
42
|
-
const completedColumn =
|
|
43
|
-
const targetColumn =
|
|
35
|
+
const completedColumn = getTableColumnByKey(table, completed_column_key);
|
|
36
|
+
const targetColumn = getTableColumnByKey(table, target_column_key);
|
|
44
37
|
let labelCountMap = {};
|
|
45
38
|
let labels = [];
|
|
46
39
|
statRows.forEach(row => {
|
|
@@ -50,15 +43,15 @@ async function calculator(chart, value, _ref) {
|
|
|
50
43
|
let formulaRow = formulaRows[rowId] || {};
|
|
51
44
|
const name = row[nameColumn.key];
|
|
52
45
|
if (name || Number.isFinite(name)) {
|
|
53
|
-
let label =
|
|
46
|
+
let label = BaseUtils.getGroupLabel(name, formulaRow, nameColumn, '', '', value);
|
|
54
47
|
if (isColumnDataAsAnArray) {
|
|
55
48
|
label = label[0];
|
|
56
49
|
}
|
|
57
|
-
label =
|
|
58
|
-
let currentValue =
|
|
59
|
-
let targetValue =
|
|
60
|
-
currentValue =
|
|
61
|
-
targetValue =
|
|
50
|
+
label = getFormattedLabel(nameColumn, label, value.collaborators);
|
|
51
|
+
let currentValue = getCellValue(row, formulaRow, completedColumn);
|
|
52
|
+
let targetValue = getCellValue(row, formulaRow, targetColumn);
|
|
53
|
+
currentValue = isNumber(currentValue) ? currentValue : 0;
|
|
54
|
+
targetValue = isNumber(targetValue) ? targetValue : 0;
|
|
62
55
|
if (labelCountMap[label]) {
|
|
63
56
|
labelCountMap[label].currentValue = currentValue + labelCountMap[label].currentValue;
|
|
64
57
|
labelCountMap[label].targetValue = targetValue + labelCountMap[label].targetValue;
|
|
@@ -107,14 +100,14 @@ async function calculator(chart, value, _ref) {
|
|
|
107
100
|
}
|
|
108
101
|
});
|
|
109
102
|
} else {
|
|
110
|
-
const completedColumn =
|
|
111
|
-
const targetColumn =
|
|
103
|
+
const completedColumn = getTableColumnByKey(table, completed_column_key);
|
|
104
|
+
const targetColumn = getTableColumnByKey(table, target_column_key);
|
|
112
105
|
let labelCountMap = {};
|
|
113
106
|
let colorMap = {};
|
|
114
107
|
let labelGroups = [];
|
|
115
108
|
let colorIndex = 0;
|
|
116
|
-
let isFormulaType =
|
|
117
|
-
const isGroupColumnDataAsAnArray =
|
|
109
|
+
let isFormulaType = FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
|
|
110
|
+
const isGroupColumnDataAsAnArray = isArrayCellValue(groupColumn);
|
|
118
111
|
statRows.forEach(row => {
|
|
119
112
|
let {
|
|
120
113
|
_id: rowId
|
|
@@ -123,28 +116,28 @@ async function calculator(chart, value, _ref) {
|
|
|
123
116
|
const name = row[nameColumn.key],
|
|
124
117
|
groupLabelName = !isFormulaType ? row[groupColumn.key] : formulaRow[rowId][groupColumn.key];
|
|
125
118
|
if ((name || Number.isFinite(name)) && (groupLabelName || Number.isFinite(groupLabelName))) {
|
|
126
|
-
let label =
|
|
127
|
-
groupLabel =
|
|
119
|
+
let label = BaseUtils.getGroupLabel(name, formulaRow, nameColumn, '', '', value),
|
|
120
|
+
groupLabel = BaseUtils.getGroupLabel(groupLabelName, formulaRow, groupColumn, date_granularity, geolocation_granularity, value);
|
|
128
121
|
if (isColumnDataAsAnArray) {
|
|
129
122
|
label = label[0];
|
|
130
123
|
}
|
|
131
124
|
if (isGroupColumnDataAsAnArray) {
|
|
132
125
|
groupLabel = groupLabel[0];
|
|
133
126
|
}
|
|
134
|
-
label =
|
|
135
|
-
groupLabel =
|
|
127
|
+
label = getFormattedLabel(nameColumn, label, value.collaborators);
|
|
128
|
+
groupLabel = getFormattedLabel(groupColumn, groupLabel, value.collaborators);
|
|
136
129
|
let color = colorMap[groupLabel];
|
|
137
130
|
if (!color) {
|
|
138
|
-
color =
|
|
131
|
+
color = PIE_CHART_COLORS[colorIndex % 12];
|
|
139
132
|
colorMap[groupLabel] = color;
|
|
140
133
|
colorIndex++;
|
|
141
134
|
}
|
|
142
135
|
if (groupLabel) {
|
|
143
|
-
let currentValue =
|
|
144
|
-
let targetValue =
|
|
145
|
-
currentValue =
|
|
146
|
-
targetValue =
|
|
147
|
-
const concatLabel =
|
|
136
|
+
let currentValue = getCellValue(row, formulaRow, completedColumn);
|
|
137
|
+
let targetValue = getCellValue(row, formulaRow, targetColumn);
|
|
138
|
+
currentValue = isNumber(currentValue) ? currentValue : 0;
|
|
139
|
+
targetValue = isNumber(targetValue) ? targetValue : 0;
|
|
140
|
+
const concatLabel = `${label}_${groupLabel}`;
|
|
148
141
|
if (labelCountMap[concatLabel]) {
|
|
149
142
|
labelCountMap[concatLabel].currentValue = currentValue + labelCountMap[concatLabel].currentValue;
|
|
150
143
|
labelCountMap[concatLabel].targetValue = targetValue + labelCountMap[concatLabel].targetValue;
|
|
@@ -211,4 +204,4 @@ async function calculator(chart, value, _ref) {
|
|
|
211
204
|
}
|
|
212
205
|
return result;
|
|
213
206
|
}
|
|
214
|
-
|
|
207
|
+
export default calculator;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 _rowUtils = require("../../row-utils");
|
|
1
|
+
import { isNumber, isNumericColumn, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import BaseUtils from '../base-utils';
|
|
3
|
+
import { getCellValue } from '../../row-utils';
|
|
11
4
|
async function calculator(chart, value, _ref) {
|
|
12
5
|
let {
|
|
13
6
|
getViewRows,
|
|
@@ -21,10 +14,10 @@ async function calculator(chart, value, _ref) {
|
|
|
21
14
|
total_value_column_key,
|
|
22
15
|
total_value_column_summary_method
|
|
23
16
|
} = chart;
|
|
24
|
-
const selectedTable =
|
|
25
|
-
const selectedView = selectedTable &&
|
|
26
|
-
const selectedColumn1 =
|
|
27
|
-
const selectedColumn2 =
|
|
17
|
+
const selectedTable = getTableById(value.tables, table_id);
|
|
18
|
+
const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
|
|
19
|
+
const selectedColumn1 = getTableColumnByKey(selectedTable, target_value_column_key);
|
|
20
|
+
const selectedColumn2 = getTableColumnByKey(selectedTable, total_value_column_key);
|
|
28
21
|
const statRows = await getViewRows(selectedView, selectedTable);
|
|
29
22
|
if (statRows.length === 0) {
|
|
30
23
|
return {
|
|
@@ -32,8 +25,8 @@ async function calculator(chart, value, _ref) {
|
|
|
32
25
|
rows: []
|
|
33
26
|
};
|
|
34
27
|
}
|
|
35
|
-
const isNumericColumn1 = selectedColumn1 &&
|
|
36
|
-
const isNumericColumn2 = selectedColumn2 &&
|
|
28
|
+
const isNumericColumn1 = selectedColumn1 && isNumericColumn(selectedColumn1);
|
|
29
|
+
const isNumericColumn2 = selectedColumn2 && isNumericColumn(selectedColumn2);
|
|
37
30
|
const formulaRows = isNumericColumn1 || isNumericColumn2 ? await getTableFormulaResults(selectedTable, statRows) : {};
|
|
38
31
|
let result1;
|
|
39
32
|
let result2;
|
|
@@ -42,14 +35,14 @@ async function calculator(chart, value, _ref) {
|
|
|
42
35
|
statRows.forEach(row => {
|
|
43
36
|
const formulaRow = formulaRows[row._id];
|
|
44
37
|
if (isNumericColumn1) {
|
|
45
|
-
const cellValue1 =
|
|
46
|
-
if (
|
|
38
|
+
const cellValue1 = getCellValue(row, formulaRow, selectedColumn1);
|
|
39
|
+
if (isNumber(cellValue1)) {
|
|
47
40
|
numberList1.push(cellValue1);
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
43
|
if (isNumericColumn2) {
|
|
51
|
-
const cellValue2 =
|
|
52
|
-
if (
|
|
44
|
+
const cellValue2 = getCellValue(row, formulaRow, selectedColumn2);
|
|
45
|
+
if (isNumber(cellValue2)) {
|
|
53
46
|
numberList2.push(cellValue2);
|
|
54
47
|
}
|
|
55
48
|
}
|
|
@@ -57,12 +50,12 @@ async function calculator(chart, value, _ref) {
|
|
|
57
50
|
if (target_value_column_summary_method === 'Row_count') {
|
|
58
51
|
result1 = statRows.length;
|
|
59
52
|
} else {
|
|
60
|
-
result1 =
|
|
53
|
+
result1 = BaseUtils.getSummaryResult(numberList1, target_value_column_summary_method);
|
|
61
54
|
}
|
|
62
55
|
if (total_value_column_summary_method === 'Row_count') {
|
|
63
56
|
result2 = statRows.length;
|
|
64
57
|
} else {
|
|
65
|
-
result2 =
|
|
58
|
+
result2 = BaseUtils.getSummaryResult(numberList2, total_value_column_summary_method);
|
|
66
59
|
}
|
|
67
60
|
if (result2 === 0) {
|
|
68
61
|
return {
|
|
@@ -75,4 +68,4 @@ async function calculator(chart, value, _ref) {
|
|
|
75
68
|
rows: statRows
|
|
76
69
|
};
|
|
77
70
|
}
|
|
78
|
-
|
|
71
|
+
export default calculator;
|