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