sea-chart 2.0.36 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +49 -57
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +65 -73
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,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 } 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,7 +98,7 @@ 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
|
|
@@ -148,7 +141,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
148
141
|
let groupby_date_granularity = chart.x_axis_date_granularity;
|
|
149
142
|
let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
150
143
|
let column_groupby_numeric_columns = chart.summary_columns || [];
|
|
151
|
-
if ([
|
|
144
|
+
if ([CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(chart.type)) {
|
|
152
145
|
groupby_column_key = chart.vertical_axis_column_key;
|
|
153
146
|
groupby_date_granularity = chart.vertical_axis_date_granularity;
|
|
154
147
|
groupby_geolocation_granularity = chart.vertical_axis_geolocation_granularity;
|
|
@@ -157,56 +150,56 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
157
150
|
y_axis_summary_type = chart.horizontal_axis_summary_type;
|
|
158
151
|
y_axis_summary_method = chart.horizontal_axis_summary_method;
|
|
159
152
|
}
|
|
160
|
-
const table =
|
|
161
|
-
const view = table &&
|
|
153
|
+
const table = getTableById(value.tables, table_id);
|
|
154
|
+
const view = table && getViewById(table.views, view_id);
|
|
162
155
|
if (!view) {
|
|
163
156
|
return;
|
|
164
157
|
}
|
|
165
|
-
const groupbyColumn = groupby_column_key &&
|
|
158
|
+
const groupbyColumn = groupby_column_key && getTableColumnByKey(table, groupby_column_key);
|
|
166
159
|
if (!groupbyColumn) {
|
|
167
160
|
return;
|
|
168
161
|
}
|
|
169
162
|
const {
|
|
170
163
|
type: groupby_column_type
|
|
171
164
|
} = groupbyColumn;
|
|
172
|
-
if ((
|
|
173
|
-
groupby_date_granularity =
|
|
165
|
+
if ((DATE_COLUMN_OPTIONS.includes(groupby_column_type) || isDateFormulaColumn(groupbyColumn)) && !groupby_date_granularity) {
|
|
166
|
+
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
174
167
|
}
|
|
175
|
-
if (groupby_column_type ===
|
|
176
|
-
groupby_geolocation_granularity =
|
|
168
|
+
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
169
|
+
groupby_geolocation_granularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
177
170
|
}
|
|
178
171
|
const yAxisType = null;
|
|
179
172
|
const statRows = await getViewRows(view, table);
|
|
180
173
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
181
174
|
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
|
-
|
|
175
|
+
BaseUtils.sortCharts(results, groupbyColumn, 'name');
|
|
183
176
|
results = results.map(result => {
|
|
184
177
|
return {
|
|
185
178
|
...result,
|
|
186
|
-
group_color: result.color ||
|
|
187
|
-
name:
|
|
179
|
+
group_color: result.color || CHART_STYLE_COLORS[0],
|
|
180
|
+
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators)
|
|
188
181
|
};
|
|
189
182
|
});
|
|
190
183
|
return results;
|
|
191
184
|
}
|
|
192
185
|
function getGroupChartStatResult(table, value, groupbyColumn, groupColumnKey, statRows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType) {
|
|
193
|
-
let columnGroupbyColumn =
|
|
186
|
+
let columnGroupbyColumn = getTableColumnByKey(table, groupColumnKey);
|
|
194
187
|
if (!columnGroupbyColumn) {
|
|
195
188
|
return [];
|
|
196
189
|
}
|
|
197
190
|
let result = [];
|
|
198
|
-
let isGroupbyColumnDataAsAnArray =
|
|
199
|
-
let isColumnGroupbyColumnDataAsAnArray =
|
|
191
|
+
let isGroupbyColumnDataAsAnArray = isArrayCellValue(groupbyColumn);
|
|
192
|
+
let isColumnGroupbyColumnDataAsAnArray = isArrayCellValue(columnGroupbyColumn);
|
|
200
193
|
statRows.forEach(row => {
|
|
201
194
|
let {
|
|
202
195
|
_id: rowId
|
|
203
196
|
} = row;
|
|
204
197
|
let formulaRow = formulaRows[rowId];
|
|
205
|
-
if (
|
|
206
|
-
let name =
|
|
198
|
+
if (isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) {
|
|
199
|
+
let name = BaseUtils.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
207
200
|
let groupName = columnGroupbyColumn.name;
|
|
208
201
|
if (!columnGroupbyMultipleNumericColumn) {
|
|
209
|
-
groupName =
|
|
202
|
+
groupName = BaseUtils.getGroupLabel(row[columnGroupbyColumn.key], formulaRow, columnGroupbyColumn, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, value);
|
|
210
203
|
}
|
|
211
204
|
if (isGroupbyColumnDataAsAnArray) {
|
|
212
205
|
if (name.length === 0 && includeEmpty) {
|
|
@@ -295,9 +288,9 @@ function updateChartValue(summaryColumn, summary_type, summary_method, formula_r
|
|
|
295
288
|
let updated = {
|
|
296
289
|
...item
|
|
297
290
|
};
|
|
298
|
-
const value =
|
|
291
|
+
const value = BaseUtils.getTotal(summaryColumnKey, summaryColumnType, summary_type, summary_method, rows, formula_rows);
|
|
299
292
|
updated.value = value;
|
|
300
|
-
updated.formatted_value =
|
|
293
|
+
updated.formatted_value = BaseUtils.getFormattedValue(value, summaryColumn, summary_method);
|
|
301
294
|
results[index] = updated;
|
|
302
295
|
});
|
|
303
296
|
}
|
|
@@ -308,8 +301,8 @@ function getBasicChartResults(rows, formulaRows, groupbyColumn, includeEmpty, is
|
|
|
308
301
|
_id: rowId
|
|
309
302
|
} = row;
|
|
310
303
|
const formulaRow = formulaRows[rowId];
|
|
311
|
-
if (!
|
|
312
|
-
const name =
|
|
304
|
+
if (!isValidRow(row, formulaRow, groupbyColumn, includeEmpty)) return;
|
|
305
|
+
const name = BaseUtils.getGroupLabel(row[groupbyColumn.key], formulaRow, groupbyColumn, groupbyDateGranularity, groupbyGeolocationGranularity, value);
|
|
313
306
|
if (isGroupbyColumnDataAsAnArray) {
|
|
314
307
|
if (name.length === 0 && includeEmpty) {
|
|
315
308
|
const nameIndex = results.findIndex(result => !result.name);
|
|
@@ -352,25 +345,25 @@ function getGroupingChartResults(rows, formulaRows, groupbyColumn, xAxisIncludeE
|
|
|
352
345
|
return results;
|
|
353
346
|
}
|
|
354
347
|
function getGroupbyOneColumnChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumnKey, summaryType, summaryMethod, yAxisType, table, value) {
|
|
355
|
-
const summaryColumn =
|
|
348
|
+
const summaryColumn = getTableColumnByKey(table, summaryColumnKey);
|
|
356
349
|
const columnGroupbyMultipleNumericColumn = false;
|
|
357
350
|
let results = getGroupChartStatResult(table, value, groupbyColumn, columnGroupbyColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
358
|
-
const columnGroupByColumn =
|
|
351
|
+
const columnGroupByColumn = getTableColumnByKey(table, columnGroupbyColumnKey);
|
|
359
352
|
results = results.map(result => {
|
|
360
353
|
const groupName = result.group_name;
|
|
361
354
|
let formattedResult = {
|
|
362
355
|
...result
|
|
363
356
|
};
|
|
364
|
-
if (columnGroupByColumn.type ===
|
|
365
|
-
formattedResult.color =
|
|
357
|
+
if (columnGroupByColumn.type === CellType.SINGLE_SELECT) {
|
|
358
|
+
formattedResult.color = getColorFromSingleSelectColumn(columnGroupByColumn, groupName);
|
|
366
359
|
}
|
|
367
|
-
formattedResult.group_name =
|
|
360
|
+
formattedResult.group_name = getFormattedLabel(columnGroupByColumn, groupName, value.collaborators);
|
|
368
361
|
return formattedResult;
|
|
369
362
|
});
|
|
370
363
|
return results;
|
|
371
364
|
}
|
|
372
365
|
function getGroupbyNumericColumnsChartResults(rows, formulaRows, groupbyColumn, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, numericSummaryColumnKey, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryType, summaryMethod, yAxisType, table, value) {
|
|
373
|
-
const summaryColumn =
|
|
366
|
+
const summaryColumn = getTableColumnByKey(table, numericSummaryColumnKey);
|
|
374
367
|
const columnGroupbyMultipleNumericColumn = true;
|
|
375
368
|
return getGroupChartStatResult(table, value, groupbyColumn, numericSummaryColumnKey, rows, formulaRows, includeEmpty, groupbyDateGranularity, groupbyGeolocationGranularity, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, summaryColumn, summaryType, summaryMethod, columnGroupbyMultipleNumericColumn, yAxisType);
|
|
376
369
|
}
|
|
@@ -388,22 +381,22 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
388
381
|
summary_column_key,
|
|
389
382
|
summary_method
|
|
390
383
|
} = chart;
|
|
391
|
-
const table =
|
|
392
|
-
const view = table &&
|
|
384
|
+
const table = getTableById(value.tables, table_id);
|
|
385
|
+
const view = table && getViewById(table.views, view_id);
|
|
393
386
|
if (!view) {
|
|
394
387
|
return;
|
|
395
388
|
}
|
|
396
|
-
const geoColumn = geo_column_key &&
|
|
389
|
+
const geoColumn = geo_column_key && getTableColumnByKey(table, geo_column_key);
|
|
397
390
|
if (!geoColumn) {
|
|
398
391
|
return;
|
|
399
392
|
}
|
|
400
393
|
let geolocationGranularity = null;
|
|
401
394
|
if (type && type.includes('world')) {
|
|
402
|
-
geolocationGranularity = geoColumn.type ===
|
|
395
|
+
geolocationGranularity = geoColumn.type === CellType.GEOLOCATION ? chart.geolocation_granularity : null;
|
|
403
396
|
} else {
|
|
404
|
-
geolocationGranularity =
|
|
397
|
+
geolocationGranularity = fixGeoGranularity(chart.map_level, chart.map_location);
|
|
405
398
|
}
|
|
406
|
-
const summaryColumn =
|
|
399
|
+
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
407
400
|
const statRows = await getViewRows(view, table);
|
|
408
401
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
409
402
|
const geoColumnType = geoColumn.type;
|
|
@@ -413,8 +406,8 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
413
406
|
_id: rowId
|
|
414
407
|
} = row;
|
|
415
408
|
const formulaRow = formulaRows[rowId];
|
|
416
|
-
if (
|
|
417
|
-
if (
|
|
409
|
+
if (isValidRow(row, formulaRow, geoColumn, false)) {
|
|
410
|
+
if (FORMULA_COLUMN_TYPES_MAP[geoColumnType]) {
|
|
418
411
|
const list = formulaRow[geoColumn.key];
|
|
419
412
|
list.forEach(n => {
|
|
420
413
|
const nameIndex = results.findIndex(r => {
|
|
@@ -457,12 +450,12 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
457
450
|
x_axis_include_empty_cells,
|
|
458
451
|
y_axises
|
|
459
452
|
} = statItem;
|
|
460
|
-
const table =
|
|
461
|
-
const view = table &&
|
|
453
|
+
const table = getTableById(value.tables, table_id);
|
|
454
|
+
const view = table && getViewById(table.views, view_id);
|
|
462
455
|
if (!view || !x_axis_column_key || !Array.isArray(y_axises) || y_axises.length === 0) {
|
|
463
456
|
return [];
|
|
464
457
|
}
|
|
465
|
-
const groupbyColumn =
|
|
458
|
+
const groupbyColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
466
459
|
if (!groupbyColumn) {
|
|
467
460
|
return [];
|
|
468
461
|
}
|
|
@@ -471,11 +464,11 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
471
464
|
} = groupbyColumn;
|
|
472
465
|
let groupbyDateGranularity = x_axis_date_granularity;
|
|
473
466
|
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
474
|
-
if ((
|
|
475
|
-
groupbyDateGranularity =
|
|
467
|
+
if ((DATE_COLUMN_OPTIONS.includes(groupbyColumnType) || isDateFormulaColumn(groupbyColumn)) && !groupbyDateGranularity) {
|
|
468
|
+
groupbyDateGranularity = CHART_SUMMARY_TYPE.MONTH;
|
|
476
469
|
}
|
|
477
|
-
if (groupbyColumnType ===
|
|
478
|
-
groupbyGeolocationGranularity =
|
|
470
|
+
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
471
|
+
groupbyGeolocationGranularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
479
472
|
}
|
|
480
473
|
const columnGroupbyDateGranularity = null;
|
|
481
474
|
const columnGroupbyGeolocationGranularity = null;
|
|
@@ -487,27 +480,27 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
487
480
|
type: yAxisType,
|
|
488
481
|
column_groupby_numeric_columns
|
|
489
482
|
} = yAxis;
|
|
490
|
-
if (yAxisType ===
|
|
483
|
+
if (yAxisType === CHART_TYPE.BAR_STACK) {
|
|
491
484
|
// just support summary numeric columns.
|
|
492
485
|
if (!Array.isArray(column_groupby_numeric_columns) || column_groupby_numeric_columns.length === 0) {
|
|
493
486
|
return;
|
|
494
487
|
}
|
|
495
|
-
const yAxisType =
|
|
488
|
+
const yAxisType = `${Y_AXIS_TYPE_PREFIX}${index}`;
|
|
496
489
|
column_groupby_numeric_columns.forEach(numericSummaryColumn => {
|
|
497
490
|
const {
|
|
498
491
|
column_key: summary_column_key,
|
|
499
492
|
summary_method
|
|
500
493
|
} = numericSummaryColumn;
|
|
501
|
-
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity,
|
|
494
|
+
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
495
|
results = results.concat(currentResults);
|
|
503
496
|
});
|
|
504
497
|
}
|
|
505
498
|
});
|
|
506
|
-
|
|
499
|
+
BaseUtils.sortCharts(results, groupbyColumn, 'name');
|
|
507
500
|
results = results.map(result => {
|
|
508
501
|
return {
|
|
509
502
|
...result,
|
|
510
|
-
name:
|
|
503
|
+
name: getFormattedLabel(groupbyColumn, result.name, value.collaborators, type)
|
|
511
504
|
};
|
|
512
505
|
});
|
|
513
506
|
return results;
|
|
@@ -526,7 +519,7 @@ function calculator(chart, value, _ref5) {
|
|
|
526
519
|
getTableFormulaResults
|
|
527
520
|
});
|
|
528
521
|
}
|
|
529
|
-
if (type ===
|
|
522
|
+
if (type === CHART_TYPE.BAR_CUSTOM) {
|
|
530
523
|
return calculateCustomBar(chart, value, {
|
|
531
524
|
getViewRows,
|
|
532
525
|
getTableFormulaResults
|
|
@@ -548,4 +541,4 @@ function calculator(chart, value, _ref5) {
|
|
|
548
541
|
getTableFormulaResults
|
|
549
542
|
});
|
|
550
543
|
}
|
|
551
|
-
|
|
544
|
+
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;
|