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