sea-chart 2.0.47 → 2.0.49
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 +11 -4
- 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 +18 -10
- package/dist/components/color-popover/color-rules-popover.js +34 -26
- 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 +11 -4
- package/dist/components/index.js +48 -7
- package/dist/components/loading/index.js +13 -6
- package/dist/components/number-input/index.js +11 -4
- package/dist/components/pixel-editor/index.js +23 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +15 -8
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +33 -25
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +18 -9
- package/dist/components/popover/sort-popover/sort-popover.js +64 -54
- 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 +64 -56
- package/dist/components/tooltip/index.js +22 -15
- package/dist/components/types-dialog/index.js +64 -56
- 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 +274 -145
- 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 +18 -11
- package/dist/editor/index.js +15 -8
- package/dist/index.js +104 -13
- package/dist/intl.js +17 -10
- package/dist/locale/index.js +23 -16
- package/dist/locale/lang/de.js +7 -1
- package/dist/locale/lang/en.js +7 -1
- package/dist/locale/lang/es.js +7 -1
- package/dist/locale/lang/fr.js +7 -1
- package/dist/locale/lang/pt.js +7 -1
- package/dist/locale/lang/ru.js +7 -1
- package/dist/locale/lang/zh_CN.js +7 -1
- package/dist/model/area-group.js +19 -12
- package/dist/model/area.js +19 -12
- package/dist/model/bar-custom.js +18 -11
- package/dist/model/bar-group.js +19 -12
- package/dist/model/bar-stack.js +17 -10
- package/dist/model/bar.js +18 -11
- package/dist/model/base-model.js +11 -4
- package/dist/model/basic-number-card.js +20 -13
- package/dist/model/chart.js +13 -7
- package/dist/model/combination.js +22 -15
- package/dist/model/compare-bar.js +21 -14
- package/dist/model/completeness-group.js +18 -11
- package/dist/model/completeness.js +17 -10
- package/dist/model/dashboard.js +14 -7
- package/dist/model/funnel.js +21 -14
- package/dist/model/generic-model.js +143 -135
- package/dist/model/heat-map.js +16 -9
- package/dist/model/horizontal-bar.js +18 -11
- package/dist/model/horizontal-group-bar.js +17 -10
- package/dist/model/index.js +93 -69
- package/dist/model/line-group.js +20 -13
- package/dist/model/line.js +19 -12
- package/dist/model/map-bubble.js +19 -12
- package/dist/model/map.js +19 -12
- package/dist/model/mirror.js +20 -13
- package/dist/model/pie.js +19 -12
- package/dist/model/ring.js +19 -12
- package/dist/model/scatter.js +17 -10
- package/dist/model/stacked-horizontal-bar.js +18 -11
- package/dist/model/table-element.js +12 -5
- package/dist/model/table.js +14 -7
- package/dist/model/tree-map.js +14 -7
- package/dist/model/trend.js +18 -11
- package/dist/model/user.js +7 -1
- package/dist/model/world-map-bubble.js +19 -12
- package/dist/model/world-map.js +19 -12
- package/dist/services/map-json.js +13 -7
- package/dist/settings/advance-bar-settings/data-settings.js +44 -36
- package/dist/settings/advance-bar-settings/index.js +20 -3
- package/dist/settings/advance-bar-settings/style-settings.js +74 -66
- package/dist/settings/bar-settings/data-settings.js +47 -39
- package/dist/settings/bar-settings/index.js +20 -3
- package/dist/settings/bar-settings/style-settings.js +60 -52
- 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 +63 -55
- package/dist/settings/combination-settings/index.js +20 -3
- package/dist/settings/combination-settings/style-settings.js +77 -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 +28 -20
- package/dist/settings/funnel-settings/data-settings.js +31 -23
- package/dist/settings/funnel-settings/index.js +20 -3
- package/dist/settings/funnel-settings/style-settings.js +19 -11
- package/dist/settings/heat-map-settings/data-settings.js +26 -18
- package/dist/settings/heat-map-settings/index.js +20 -3
- package/dist/settings/heat-map-settings/style-settings.js +26 -18
- package/dist/settings/horizontal-bar-settings/data-settings.js +19 -12
- package/dist/settings/horizontal-bar-settings/index.js +20 -3
- package/dist/settings/horizontal-bar-settings/style-settings.js +19 -12
- package/dist/settings/index.js +70 -52
- package/dist/settings/map-settings/components/location-field-selector.js +17 -10
- package/dist/settings/map-settings/components/map-level-selector.js +18 -11
- package/dist/settings/map-settings/components/map-province-city-selector.js +26 -19
- package/dist/settings/map-settings/index.js +20 -3
- package/dist/settings/map-settings/map-data-settings.js +30 -23
- package/dist/settings/map-settings/map-style-settings.js +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 +38 -30
- package/dist/settings/table-element-settings/data-settings.js +29 -21
- package/dist/settings/table-element-settings/index.js +13 -2
- package/dist/settings/table-settings/data-settings.js +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 +53 -45
- 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/axis-title-font-settings/index.js +17 -10
- package/dist/settings/widgets/basic-summary/index.js +63 -55
- package/dist/settings/widgets/chart-type/index.js +26 -18
- package/dist/settings/widgets/color-settings/index.js +80 -72
- package/dist/settings/widgets/common-data-settings.js +29 -21
- package/dist/settings/widgets/data-filter/index.js +43 -35
- package/dist/settings/widgets/data-sort.js +24 -16
- package/dist/settings/widgets/date-summary-item.js +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 +28 -18
- package/dist/utils/cell-value-utils.js +12 -5
- package/dist/utils/chart-utils/base-utils.js +345 -337
- package/dist/utils/chart-utils/index.js +41 -28
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +85 -78
- 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 +28 -21
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +97 -91
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +38 -31
- package/dist/utils/chart-utils/sql-statistics-utils.js +240 -232
- 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 +92 -65
- package/dist/utils/common-utils.js +52 -27
- package/dist/utils/concurrency-manager.js +7 -1
- package/dist/utils/contexts.js +12 -5
- 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 +221 -54
- 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 +180 -168
- 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 +156 -146
- package/dist/utils/sql/index.js +27 -3
- package/dist/utils/trend-utils.js +47 -39
- package/dist/view/index.js +95 -89
- package/dist/view/title/index.js +23 -15
- package/dist/view/wrapper/area-group.js +47 -39
- package/dist/view/wrapper/area.js +45 -37
- package/dist/view/wrapper/bar-compare.js +41 -33
- package/dist/view/wrapper/bar-custom-stack.js +39 -31
- package/dist/view/wrapper/bar-group.js +48 -40
- package/dist/view/wrapper/bar-stack.js +51 -43
- package/dist/view/wrapper/bar.js +43 -35
- package/dist/view/wrapper/basic-number-card.js +26 -18
- package/dist/view/wrapper/chart-component.js +112 -104
- package/dist/view/wrapper/combination.js +55 -47
- package/dist/view/wrapper/completeness-group.js +38 -30
- package/dist/view/wrapper/completeness.js +36 -28
- package/dist/view/wrapper/dashboard.js +33 -25
- package/dist/view/wrapper/funnel.js +38 -30
- package/dist/view/wrapper/heat-map.js +64 -56
- package/dist/view/wrapper/horizontal-bar-group.js +55 -47
- package/dist/view/wrapper/horizontal-bar-stack.js +49 -41
- package/dist/view/wrapper/horizontal-bar.js +43 -35
- package/dist/view/wrapper/index.js +115 -107
- package/dist/view/wrapper/line-group.js +45 -37
- package/dist/view/wrapper/line.js +44 -36
- package/dist/view/wrapper/map-bubble.js +46 -38
- package/dist/view/wrapper/map-world-bubble.js +45 -37
- package/dist/view/wrapper/map-world.js +47 -39
- package/dist/view/wrapper/map.js +48 -40
- package/dist/view/wrapper/mirror.js +41 -33
- package/dist/view/wrapper/pie.js +47 -39
- package/dist/view/wrapper/ring.js +50 -42
- package/dist/view/wrapper/scatter.js +45 -37
- 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 +91 -83
- 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 +105 -96
- 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 +15 -7
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +16 -8
- package/dist/view/wrapper/table-element/components/records.js +29 -21
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +12 -5
- package/dist/view/wrapper/table-element/components/utils.js +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 +26 -18
- package/dist/view/wrapper/treemap.js +41 -33
- package/dist/view/wrapper/trend.js +49 -41
- package/package.json +7 -2
|
@@ -1,57 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "BaseUtils", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _baseUtils.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.ChartUtils = void 0;
|
|
14
|
+
var _lodash = require("lodash");
|
|
15
|
+
var _context = _interopRequireDefault(require("../../context"));
|
|
16
|
+
var _ = require("..");
|
|
17
|
+
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
+
var _concurrencyManager = _interopRequireDefault(require("../concurrency-manager"));
|
|
19
|
+
var _baseUtils = _interopRequireDefault(require("./base-utils"));
|
|
20
|
+
var _sqlStatisticsUtils = _interopRequireDefault(require("./sql-statistics-utils"));
|
|
21
|
+
var _originalDataUtils = _interopRequireDefault(require("./original-data-utils"));
|
|
9
22
|
class ChartUtils {}
|
|
23
|
+
exports.ChartUtils = ChartUtils;
|
|
10
24
|
ChartUtils.calculateChart = async (chart, value, callback) => {
|
|
11
|
-
if (!
|
|
12
|
-
const roleId =
|
|
13
|
-
const isEditAppPage =
|
|
25
|
+
if (!_baseUtils.default.isValidExistChart(value.tables, chart)) {
|
|
26
|
+
const roleId = _context.default.getSetting('roleId');
|
|
27
|
+
const isEditAppPage = _context.default.getSetting('isEditAppPage');
|
|
14
28
|
const tip_message = !roleId && !isEditAppPage ? 'The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations' : 'Please_complete_the_chart_configuration_first';
|
|
15
29
|
return callback && callback('', tip_message, null);
|
|
16
30
|
}
|
|
17
|
-
const id = uniqueId();
|
|
31
|
+
const id = (0, _lodash.uniqueId)();
|
|
18
32
|
const requestData = () => {
|
|
19
|
-
|
|
33
|
+
_context.default.queryChartResult({
|
|
20
34
|
chart,
|
|
21
35
|
tables: value.tables,
|
|
22
36
|
isCalculateByView: value.isCalculateByView,
|
|
23
37
|
onSuccess: async function (res) {
|
|
24
38
|
var _res$data;
|
|
25
|
-
let dataSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
39
|
+
let dataSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _sqlStatisticsUtils.default.DATA_SOURCE;
|
|
26
40
|
// reolve request and start next request
|
|
27
|
-
|
|
41
|
+
_concurrencyManager.default.removeRequest(id);
|
|
28
42
|
const {
|
|
29
43
|
success,
|
|
30
44
|
error_message
|
|
31
45
|
} = res.data;
|
|
32
46
|
if (!success) {
|
|
33
|
-
const errMsg =
|
|
47
|
+
const errMsg = _intl.default.get(error_message);
|
|
34
48
|
callback && callback(errMsg, '', null);
|
|
35
49
|
return;
|
|
36
50
|
}
|
|
37
|
-
if (dataSources ===
|
|
38
|
-
|
|
51
|
+
if (dataSources === _originalDataUtils.default.DATA_SOURCE) {
|
|
52
|
+
_originalDataUtils.default.calculateChart(chart, value, callback);
|
|
39
53
|
return;
|
|
40
54
|
}
|
|
41
|
-
await
|
|
55
|
+
await _sqlStatisticsUtils.default.calculateChart(chart, value, callback, (res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.results) || []);
|
|
42
56
|
},
|
|
43
57
|
onFail: err => {
|
|
44
|
-
|
|
45
|
-
let errorMessage = getErrorMessage(err);
|
|
58
|
+
_concurrencyManager.default.removeRequest(id);
|
|
59
|
+
let errorMessage = (0, _.getErrorMessage)(err);
|
|
46
60
|
callback && callback(errorMessage, '', null);
|
|
47
61
|
}
|
|
48
62
|
});
|
|
49
63
|
};
|
|
50
64
|
requestData.id = id;
|
|
51
|
-
|
|
65
|
+
_concurrencyManager.default.applyRequest(requestData);
|
|
52
66
|
};
|
|
53
67
|
ChartUtils.calculateStaticChart = (chart, value, statisticalResult, callback) => {
|
|
54
|
-
if (!
|
|
68
|
+
if (!_baseUtils.default.isValidExistChart(value.tables, chart)) {
|
|
55
69
|
const tip_message = 'Please_complete_the_chart_configuration_first';
|
|
56
70
|
return callback && callback('', tip_message, null);
|
|
57
71
|
}
|
|
@@ -63,10 +77,9 @@ ChartUtils.calculateStaticChart = (chart, value, statisticalResult, callback) =>
|
|
|
63
77
|
data_sources: dataSources,
|
|
64
78
|
refreshCache
|
|
65
79
|
} = statisticalResult;
|
|
66
|
-
if (dataSources ===
|
|
67
|
-
|
|
80
|
+
if (dataSources === _originalDataUtils.default.DATA_SOURCE) {
|
|
81
|
+
_originalDataUtils.default.calculateChart(chart, value, callback, refreshCache);
|
|
68
82
|
} else {
|
|
69
|
-
|
|
83
|
+
_sqlStatisticsUtils.default.calculateStaticChart(chart, value, statisticalResult, callback);
|
|
70
84
|
}
|
|
71
|
-
};
|
|
72
|
-
export { BaseUtils, ChartUtils };
|
|
85
|
+
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
+
var _dtableUtils = require("dtable-utils");
|
|
10
|
+
var _constants = require("../../../constants");
|
|
11
|
+
var _columnUtils = require("../../column-utils");
|
|
12
|
+
var _cellValueUtils = require("../../cell-value-utils");
|
|
13
|
+
var _rowUtils = require("../../row-utils");
|
|
14
|
+
var _map = require("../../map");
|
|
15
|
+
var _baseUtils = _interopRequireDefault(require("../base-utils"));
|
|
16
|
+
const MAP_CHART_TYPES = [_constants.CHART_TYPE.MAP, _constants.CHART_TYPE.WORLD_MAP, _constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE];
|
|
10
17
|
async function calculateBasicChart(chart, value, _ref) {
|
|
11
18
|
let {
|
|
12
19
|
getViewRows,
|
|
@@ -24,7 +31,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
24
31
|
let groupby_date_granularity;
|
|
25
32
|
let include_empty;
|
|
26
33
|
let groupby_geolocation_granularity;
|
|
27
|
-
if (chart.type === CHART_TYPE.PIE || chart.type === CHART_TYPE.RING || chart.type === CHART_TYPE.TREE_MAP) {
|
|
34
|
+
if (chart.type === _constants.CHART_TYPE.PIE || chart.type === _constants.CHART_TYPE.RING || chart.type === _constants.CHART_TYPE.TREE_MAP) {
|
|
28
35
|
groupby_column_key = chart.groupby_column_key;
|
|
29
36
|
summary_type = chart.summary_type;
|
|
30
37
|
summary_method = chart.summary_method;
|
|
@@ -32,7 +39,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
32
39
|
groupby_date_granularity = chart.groupby_date_granularity;
|
|
33
40
|
include_empty = chart.groupby_include_empty_cells;
|
|
34
41
|
groupby_geolocation_granularity = chart.groupby_geolocation_granularity;
|
|
35
|
-
} else if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR].includes(chart.type)) {
|
|
42
|
+
} else if ([_constants.CHART_TYPE.HORIZONTAL_BAR, _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR].includes(chart.type)) {
|
|
36
43
|
groupby_column_key = chart.vertical_axis_column_key;
|
|
37
44
|
summary_type = chart.horizontal_axis_summary_type;
|
|
38
45
|
summary_method = chart.horizontal_axis_summary_method;
|
|
@@ -40,7 +47,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
40
47
|
groupby_date_granularity = chart.vertical_axis_date_granularity;
|
|
41
48
|
groupby_geolocation_granularity = chart.vertical_axis_geolocation_granularity;
|
|
42
49
|
include_empty = chart.vertical_axis_include_empty;
|
|
43
|
-
} else if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
50
|
+
} else if ([_constants.CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
44
51
|
groupby_column_key = chart.time_column_key;
|
|
45
52
|
summary_type = chart.summary_type;
|
|
46
53
|
summary_method = chart.summary_method;
|
|
@@ -54,43 +61,43 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
54
61
|
groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
55
62
|
include_empty = chart.x_axis_include_empty_cells;
|
|
56
63
|
}
|
|
57
|
-
const table = getTableById(value.tables, table_id);
|
|
58
|
-
const view = table && getViewById(table.views, view_id);
|
|
64
|
+
const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
|
|
65
|
+
const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
|
|
59
66
|
if (!view) {
|
|
60
67
|
return;
|
|
61
68
|
}
|
|
62
|
-
const groupbyColumn = groupby_column_key && getTableColumnByKey(table, groupby_column_key);
|
|
69
|
+
const groupbyColumn = groupby_column_key && (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
|
|
63
70
|
if (!groupbyColumn) {
|
|
64
71
|
return;
|
|
65
72
|
}
|
|
66
|
-
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
73
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
67
74
|
const {
|
|
68
75
|
type: groupby_column_type
|
|
69
76
|
} = groupbyColumn;
|
|
70
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || isDateFormulaColumn(groupbyColumn)) && !groupby_date_granularity) {
|
|
71
|
-
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
72
|
-
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
73
|
-
groupby_date_granularity = CHART_SUMMARY_TYPE.DAY;
|
|
77
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupby_date_granularity) {
|
|
78
|
+
groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.MONTH;
|
|
79
|
+
if ([_constants.CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
80
|
+
groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.DAY;
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
|
-
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
77
|
-
groupby_geolocation_granularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
83
|
+
if (groupby_column_type === _dtableUtils.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
84
|
+
groupby_geolocation_granularity = _constants.CHART_SUMMARY_TYPE.PROVINCE;
|
|
78
85
|
}
|
|
79
86
|
const yAxisType = null;
|
|
80
87
|
const statRows = await getViewRows(view, table);
|
|
81
88
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
82
|
-
const isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
89
|
+
const isGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(groupbyColumn);
|
|
83
90
|
let results = getBasicChartResults(statRows, formulaRows, groupbyColumn, include_empty, isGroupbyColumnDataAsAnArray, groupby_date_granularity, groupby_geolocation_granularity, summaryColumn, summary_type, summary_method, yAxisType, value);
|
|
84
91
|
if (sort_type) {
|
|
85
|
-
|
|
92
|
+
_baseUtils.default.sortChartData(results, sort_type); // sortby statistic value
|
|
86
93
|
} else {
|
|
87
|
-
|
|
94
|
+
_baseUtils.default.sortCharts(results, groupbyColumn, 'name'); // sortby statistic label
|
|
88
95
|
}
|
|
89
96
|
results.forEach(item => {
|
|
90
97
|
item.group_name = item.name;
|
|
91
|
-
item.name = getFormattedLabel(groupbyColumn, item.name, value.collaborators);
|
|
98
|
+
item.name = (0, _rowUtils.getFormattedLabel)(groupbyColumn, item.name, value.collaborators);
|
|
92
99
|
});
|
|
93
|
-
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
100
|
+
if ([_constants.CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
94
101
|
let data = [];
|
|
95
102
|
let years = [];
|
|
96
103
|
results.forEach(item => {
|
|
@@ -98,7 +105,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
98
105
|
data.push(item);
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
|
-
const year =
|
|
108
|
+
const year = (0, _dayjs.default)(item.name).year();
|
|
102
109
|
data.push({
|
|
103
110
|
...item,
|
|
104
111
|
year
|
|
@@ -142,7 +149,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
142
149
|
let groupby_date_granularity = chart.x_axis_date_granularity;
|
|
143
150
|
let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
144
151
|
let column_groupby_numeric_columns = chart.summary_columns || [];
|
|
145
|
-
if ([CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(chart.type)) {
|
|
152
|
+
if ([_constants.CHART_TYPE.HORIZONTAL_GROUP_BAR, _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(chart.type)) {
|
|
146
153
|
groupby_column_key = chart.vertical_axis_column_key;
|
|
147
154
|
groupby_date_granularity = chart.vertical_axis_date_granularity;
|
|
148
155
|
groupby_geolocation_granularity = chart.vertical_axis_geolocation_granularity;
|
|
@@ -151,56 +158,56 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
151
158
|
y_axis_summary_type = chart.horizontal_axis_summary_type;
|
|
152
159
|
y_axis_summary_method = chart.horizontal_axis_summary_method;
|
|
153
160
|
}
|
|
154
|
-
const table = getTableById(value.tables, table_id);
|
|
155
|
-
const view = table && getViewById(table.views, view_id);
|
|
161
|
+
const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
|
|
162
|
+
const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
|
|
156
163
|
if (!view) {
|
|
157
164
|
return;
|
|
158
165
|
}
|
|
159
|
-
const groupbyColumn = groupby_column_key && getTableColumnByKey(table, groupby_column_key);
|
|
166
|
+
const groupbyColumn = groupby_column_key && (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
|
|
160
167
|
if (!groupbyColumn) {
|
|
161
168
|
return;
|
|
162
169
|
}
|
|
163
170
|
const {
|
|
164
171
|
type: groupby_column_type
|
|
165
172
|
} = groupbyColumn;
|
|
166
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || isDateFormulaColumn(groupbyColumn)) && !groupby_date_granularity) {
|
|
167
|
-
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
173
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupby_column_type) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupby_date_granularity) {
|
|
174
|
+
groupby_date_granularity = _constants.CHART_SUMMARY_TYPE.MONTH;
|
|
168
175
|
}
|
|
169
|
-
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
170
|
-
groupby_geolocation_granularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
176
|
+
if (groupby_column_type === _dtableUtils.CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
177
|
+
groupby_geolocation_granularity = _constants.CHART_SUMMARY_TYPE.PROVINCE;
|
|
171
178
|
}
|
|
172
179
|
const yAxisType = null;
|
|
173
180
|
const statRows = await getViewRows(view, table);
|
|
174
181
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
175
182
|
let results = getGroupingChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupby_date_granularity, groupby_geolocation_granularity, column_groupby_column_key, column_groupby_date_granularity, column_groupby_geolocation_granularity, y_axis_summary_column_key, y_axis_summary_type, y_axis_summary_method, column_groupby_multiple_numeric_column, column_groupby_numeric_columns, yAxisType, table, value);
|
|
176
|
-
|
|
183
|
+
_baseUtils.default.sortCharts(results, groupbyColumn, 'name');
|
|
177
184
|
results = results.map(result => {
|
|
178
185
|
return {
|
|
179
186
|
...result,
|
|
180
|
-
group_color: result.color || CHART_STYLE_COLORS[0],
|
|
181
|
-
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
187
|
+
group_color: result.color || _constants.CHART_STYLE_COLORS[0],
|
|
188
|
+
name: (0, _rowUtils.getFormattedLabel)(groupbyColumn, result.name, value.collaborators)
|
|
182
189
|
};
|
|
183
190
|
});
|
|
184
191
|
return results;
|
|
185
192
|
}
|
|
186
193
|
function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
|
|
187
|
-
let columnGroupbyColumn = getTableColumnByKey(table, groupColumnKey);
|
|
194
|
+
let columnGroupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, groupColumnKey);
|
|
188
195
|
if (!columnGroupbyColumn) {
|
|
189
196
|
return [];
|
|
190
197
|
}
|
|
191
198
|
let result = [];
|
|
192
|
-
let isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
193
|
-
let isColumnGroupbyColumnDataAsAnArray = isArrayCellValue(columnGroupbyColumn);
|
|
199
|
+
let isGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(groupbyColumn);
|
|
200
|
+
let isColumnGroupbyColumnDataAsAnArray = (0, _cellValueUtils.isArrayCellValue)(columnGroupbyColumn);
|
|
194
201
|
statRows.forEach(row => {
|
|
195
202
|
let {
|
|
196
203
|
_id: rowId
|
|
197
204
|
} = row;
|
|
198
205
|
let formulaRow = formulaRows[rowId];
|
|
199
|
-
if (isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
200
|
-
let name =
|
|
206
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
207
|
+
let name = _baseUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
201
208
|
let groupName = columnGroupbyColumn.name;
|
|
202
209
|
if (!columnGroupbyMultipleNumericColumn) {
|
|
203
|
-
groupName =
|
|
210
|
+
groupName = _baseUtils.default.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, value);
|
|
204
211
|
}
|
|
205
212
|
if (isGroupbyColumnDataAsAnArray) {
|
|
206
213
|
if (name.length === 0 && includeEmpty) {
|
|
@@ -245,7 +252,7 @@ function groupChartRows(results, name, row, isColumnGroupbyColumnDataAsAnArray,
|
|
|
245
252
|
});
|
|
246
253
|
}
|
|
247
254
|
} else {
|
|
248
|
-
if (isEmpty(groupName) && !include_empty) {
|
|
255
|
+
if ((0, _dtableUtils.isEmpty)(groupName) && !include_empty) {
|
|
249
256
|
return;
|
|
250
257
|
}
|
|
251
258
|
updateGroupingChartRows(results, name, groupName, row, yAxisType);
|
|
@@ -289,9 +296,9 @@ function updateChartValue(summaryColumn, summary_type, summary_method, formula_r
|
|
|
289
296
|
let updated = {
|
|
290
297
|
...item
|
|
291
298
|
};
|
|
292
|
-
const value =
|
|
299
|
+
const value = _baseUtils.default.getTotal(summaryColumnKey, summaryColumnType, summary_type, summary_method, rows, formula_rows);
|
|
293
300
|
updated.value = value;
|
|
294
|
-
updated.formatted_value =
|
|
301
|
+
updated.formatted_value = _baseUtils.default.getFormattedValue(value, summaryColumn, summary_method);
|
|
295
302
|
results[index] = updated;
|
|
296
303
|
});
|
|
297
304
|
}
|
|
@@ -302,8 +309,8 @@ function getBasicChartResults(rows, formulaRows, groupbyColumn, includeEmpty, is
|
|
|
302
309
|
_id: rowId
|
|
303
310
|
} = row;
|
|
304
311
|
const formulaRow = formulaRows[rowId];
|
|
305
|
-
if (!isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
306
|
-
const name =
|
|
312
|
+
if (!(0, _rowUtils.isValidRow)(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
313
|
+
const name = _baseUtils.default.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
307
314
|
if (isGroupbyColumnDataAsAnArray) {
|
|
308
315
|
if (name.length === 0 && includeEmpty) {
|
|
309
316
|
const nameIndex = results.findIndex(result => !result.name);
|
|
@@ -346,25 +353,25 @@ function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeE
|
|
|
346
353
|
return results;
|
|
347
354
|
}
|
|
348
355
|
function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumnKey, summaryType, summaryMethod, yAxisType, table, value) {
|
|
349
|
-
const summaryColumn = getTableColumnByKey(table, summaryColumnKey);
|
|
356
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summaryColumnKey);
|
|
350
357
|
const columnGroupbyMultipleNumericColumn = false;
|
|
351
358
|
let results = getGroupChartStatResult(table, value, groupbyColumn, columnGroupbyColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
352
|
-
const columnGroupByColumn = getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
359
|
+
const columnGroupByColumn = (0, _dtableUtils.getTableColumnByKey)(table, columnGroupbyColumnKey);
|
|
353
360
|
results = results.map(result => {
|
|
354
361
|
const groupName = result.group_name;
|
|
355
362
|
let formattedResult = {
|
|
356
363
|
...result
|
|
357
364
|
};
|
|
358
|
-
if (columnGroupByColumn.type === CellType.SINGLE_SELECT) {
|
|
359
|
-
formattedResult.color = getColorFromSingleSelectColumn(columnGroupByColumn, groupName);
|
|
365
|
+
if (columnGroupByColumn.type === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
366
|
+
formattedResult.color = (0, _columnUtils.getColorFromSingleSelectColumn)(columnGroupByColumn, groupName);
|
|
360
367
|
}
|
|
361
|
-
formattedResult.group_name = getFormattedLabel(columnGroupByColumn, groupName, value.collaborators);
|
|
368
|
+
formattedResult.group_name = (0, _rowUtils.getFormattedLabel)(columnGroupByColumn, groupName, value.collaborators);
|
|
362
369
|
return formattedResult;
|
|
363
370
|
});
|
|
364
371
|
return results;
|
|
365
372
|
}
|
|
366
373
|
function getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, numericSummaryColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryType, summaryMethod, yAxisType, table, value) {
|
|
367
|
-
const summaryColumn = getTableColumnByKey(table, numericSummaryColumnKey);
|
|
374
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, numericSummaryColumnKey);
|
|
368
375
|
const columnGroupbyMultipleNumericColumn = true;
|
|
369
376
|
return getGroupChartStatResult(table, value, groupbyColumn, numericSummaryColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
370
377
|
}
|
|
@@ -382,22 +389,22 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
382
389
|
summary_column_key,
|
|
383
390
|
summary_method
|
|
384
391
|
} = chart;
|
|
385
|
-
const table = getTableById(value.tables, table_id);
|
|
386
|
-
const view = table && getViewById(table.views, view_id);
|
|
392
|
+
const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
|
|
393
|
+
const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
|
|
387
394
|
if (!view) {
|
|
388
395
|
return;
|
|
389
396
|
}
|
|
390
|
-
const geoColumn = geo_column_key && getTableColumnByKey(table, geo_column_key);
|
|
397
|
+
const geoColumn = geo_column_key && (0, _dtableUtils.getTableColumnByKey)(table, geo_column_key);
|
|
391
398
|
if (!geoColumn) {
|
|
392
399
|
return;
|
|
393
400
|
}
|
|
394
401
|
let geolocationGranularity = null;
|
|
395
402
|
if (type && type.includes('world')) {
|
|
396
|
-
geolocationGranularity = geoColumn.type === CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
403
|
+
geolocationGranularity = geoColumn.type === _dtableUtils.CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
397
404
|
} else {
|
|
398
|
-
geolocationGranularity = fixGeoGranularity(chart.map_level, chart.map_location);
|
|
405
|
+
geolocationGranularity = (0, _map.fixGeoGranularity)(chart.map_level, chart.map_location);
|
|
399
406
|
}
|
|
400
|
-
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
407
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
401
408
|
const statRows = await getViewRows(view, table);
|
|
402
409
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
403
410
|
const geoColumnType = geoColumn.type;
|
|
@@ -407,8 +414,8 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
407
414
|
_id: rowId
|
|
408
415
|
} = row;
|
|
409
416
|
const formulaRow = formulaRows[rowId];
|
|
410
|
-
if (isValidRow(row, formulaRow, geoColumn, false)) {
|
|
411
|
-
if (FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
417
|
+
if ((0, _rowUtils.isValidRow)(row, formulaRow, geoColumn, false)) {
|
|
418
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
412
419
|
const list = formulaRow[geoColumn.key];
|
|
413
420
|
list.forEach(n => {
|
|
414
421
|
const nameIndex = results.findIndex(r => {
|
|
@@ -451,12 +458,12 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
451
458
|
x_axis_include_empty_cells,
|
|
452
459
|
y_axises
|
|
453
460
|
} = statItem;
|
|
454
|
-
const table = getTableById(value.tables, table_id);
|
|
455
|
-
const view = table && getViewById(table.views, view_id);
|
|
461
|
+
const table = (0, _dtableUtils.getTableById)(value.tables, table_id);
|
|
462
|
+
const view = table && (0, _dtableUtils.getViewById)(table.views, view_id);
|
|
456
463
|
if (!view || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
|
|
457
464
|
return [];
|
|
458
465
|
}
|
|
459
|
-
const groupbyColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
466
|
+
const groupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
460
467
|
if (!groupbyColumn) {
|
|
461
468
|
return [];
|
|
462
469
|
}
|
|
@@ -465,11 +472,11 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
465
472
|
} = groupbyColumn;
|
|
466
473
|
let groupbyDateGranularity = x_axis_date_granularity;
|
|
467
474
|
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
468
|
-
if ((DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || isDateFormulaColumn(groupbyColumn)) && !groupbyDateGranularity) {
|
|
469
|
-
groupbyDateGranularity = CHART_SUMMARY_TYPE.MONTH;
|
|
475
|
+
if ((_dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || (0, _columnUtils.isDateFormulaColumn)(groupbyColumn)) && !groupbyDateGranularity) {
|
|
476
|
+
groupbyDateGranularity = _constants.CHART_SUMMARY_TYPE.MONTH;
|
|
470
477
|
}
|
|
471
|
-
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
472
|
-
groupbyGeolocationGranularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
478
|
+
if (groupbyColumnType === _dtableUtils.CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
479
|
+
groupbyGeolocationGranularity = _constants.CHART_SUMMARY_TYPE.PROVINCE;
|
|
473
480
|
}
|
|
474
481
|
const columnGroupbyDateGranularity = null;
|
|
475
482
|
const columnGroupbyGeolocationGranularity = null;
|
|
@@ -481,27 +488,27 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
481
488
|
type: yAxisType,
|
|
482
489
|
column_groupby_numeric_columns
|
|
483
490
|
} = yAxis;
|
|
484
|
-
if (yAxisType === CHART_TYPE.BAR_STACK) {
|
|
491
|
+
if (yAxisType === _constants.CHART_TYPE.BAR_STACK) {
|
|
485
492
|
// just support summary numeric columns.
|
|
486
493
|
if (!Array.isArray(column_groupby_numeric_columns) || column_groupby_numeric_columns.length === 0) {
|
|
487
494
|
return;
|
|
488
495
|
}
|
|
489
|
-
const yAxisType = `${Y_AXIS_TYPE_PREFIX}${index}`;
|
|
496
|
+
const yAxisType = `${_constants.Y_AXIS_TYPE_PREFIX}${index}`;
|
|
490
497
|
column_groupby_numeric_columns.forEach(numericSummaryColumn => {
|
|
491
498
|
const {
|
|
492
499
|
column_key: summary_column_key,
|
|
493
500
|
summary_method
|
|
494
501
|
} = numericSummaryColumn;
|
|
495
|
-
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, CHART_SUMMARY_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
502
|
+
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, _constants.CHART_SUMMARY_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
496
503
|
results = results.concat(currentResults);
|
|
497
504
|
});
|
|
498
505
|
}
|
|
499
506
|
});
|
|
500
|
-
|
|
507
|
+
_baseUtils.default.sortCharts(results, groupbyColumn, 'name');
|
|
501
508
|
results = results.map(result => {
|
|
502
509
|
return {
|
|
503
510
|
...result,
|
|
504
|
-
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators, type)
|
|
511
|
+
name: (0, _rowUtils.getFormattedLabel)(groupbyColumn, result.name, value.collaborators, type)
|
|
505
512
|
};
|
|
506
513
|
});
|
|
507
514
|
return results;
|
|
@@ -520,7 +527,7 @@ function calculator(chart, value, _ref5) {
|
|
|
520
527
|
getTableFormulaResults
|
|
521
528
|
});
|
|
522
529
|
}
|
|
523
|
-
if (type === CHART_TYPE.BAR_CUSTOM) {
|
|
530
|
+
if (type === _constants.CHART_TYPE.BAR_CUSTOM) {
|
|
524
531
|
return calculateCustomBar(chart, value, {
|
|
525
532
|
getViewRows,
|
|
526
533
|
getTableFormulaResults
|
|
@@ -542,4 +549,4 @@ function calculator(chart, value, _ref5) {
|
|
|
542
549
|
getTableFormulaResults
|
|
543
550
|
});
|
|
544
551
|
}
|
|
545
|
-
|
|
552
|
+
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, dtableValue, _ref) {
|
|
6
13
|
let {
|
|
7
14
|
getViewRows,
|
|
@@ -14,29 +21,29 @@ async function calculator(chart, dtableValue, _ref) {
|
|
|
14
21
|
summary_method,
|
|
15
22
|
summary_type
|
|
16
23
|
} = chart;
|
|
17
|
-
const selectedTable = getTableById(dtableValue.tables, table_id);
|
|
18
|
-
const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
|
|
19
|
-
const selectedColumn = getTableColumnByKey(selectedTable, numeric_column_key);
|
|
20
|
-
const _isNumericColumn = selectedColumn && isNumericColumn(selectedColumn);
|
|
24
|
+
const selectedTable = (0, _dtableUtils.getTableById)(dtableValue.tables, table_id);
|
|
25
|
+
const selectedView = selectedTable && (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
|
|
26
|
+
const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, numeric_column_key);
|
|
27
|
+
const _isNumericColumn = selectedColumn && (0, _dtableUtils.isNumericColumn)(selectedColumn);
|
|
21
28
|
const statRows = await getViewRows(selectedView, selectedTable);
|
|
22
29
|
const formulaRows = _isNumericColumn ? await getTableFormulaResults(selectedTable, statRows) : {};
|
|
23
30
|
const numberList = [];
|
|
24
31
|
_isNumericColumn && statRows.forEach(row => {
|
|
25
32
|
const formulaRow = formulaRows[row._id];
|
|
26
|
-
const cellValue = getCellValue(row, formulaRow, selectedColumn);
|
|
27
|
-
if (isNumber(cellValue)) {
|
|
33
|
+
const cellValue = (0, _rowUtils.getCellValue)(row, formulaRow, selectedColumn);
|
|
34
|
+
if ((0, _dtableUtils.isNumber)(cellValue)) {
|
|
28
35
|
numberList.push(cellValue);
|
|
29
36
|
}
|
|
30
37
|
});
|
|
31
38
|
let value;
|
|
32
|
-
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
39
|
+
if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
33
40
|
value = statRows.length;
|
|
34
41
|
} else {
|
|
35
|
-
value =
|
|
42
|
+
value = _baseUtils.default.getSummaryResult(numberList, summary_method);
|
|
36
43
|
}
|
|
37
44
|
return {
|
|
38
45
|
value,
|
|
39
46
|
rows: statRows
|
|
40
47
|
};
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
var _default = exports.default = calculator;
|