dtable-statistic 4.4.24-alpha.9 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/dashboard.css +0 -1
- package/es/assets/css/dialog.css +0 -30
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/calculator/base-calculator.js +80 -0
- package/es/calculator/basic-chart-calculator.js +349 -0
- package/es/calculator/combination-calculator.js +246 -0
- package/es/calculator/compare-bar-calculator.js +197 -0
- package/es/calculator/completeness-calculator.js +215 -0
- package/es/calculator/copy-value.js +53 -0
- package/es/calculator/dashboard-calculator.js +70 -0
- package/es/calculator/heat-map-calculator.js +148 -0
- package/es/calculator/horizontal-bar-calculator.js +67 -0
- package/es/calculator/index.js +81 -0
- package/es/calculator/map-calculator.js +103 -0
- package/es/calculator/mirror-calculator.js +146 -0
- package/es/calculator/number-card-calculator.js +60 -0
- package/es/calculator/pivot-table-calculator.js +821 -0
- package/es/calculator/scatter-calculator.js +75 -0
- package/es/calculator/thread-manager.js +57 -0
- package/es/calculator/trend-calculator.js +113 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +495 -0
- package/es/calculator/workers/calculator.worker.js +44 -0
- package/es/calculator/workers/card-calculator-worker.js +40 -0
- package/es/calculator/workers/combination-calculator-worker.js +276 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +150 -0
- package/es/calculator/workers/completeness-calculator-worker.js +208 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +68 -0
- package/es/calculator/workers/mirror-calculator-worker.js +152 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +718 -0
- package/es/calculator/workers/scatter-calculator-worker.js +80 -0
- package/es/calculator/workers/trend-calculator-worker.js +108 -0
- package/es/calculator/world-map-calculator.js +124 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +90 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +259 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +83 -0
- package/es/components/dialog/enlarged-chart-dialog.js +13 -8
- package/es/components/dialog/statistic-record-dialog/index.js +34 -25
- package/es/components/dialog/statistic-types-dialog/index.css +14 -0
- package/es/components/dialog/statistic-types-dialog/index.js +62 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
- package/es/components/popover/color-rules/color-rule.js +183 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +221 -0
- package/es/components/popover/color-rules/rule-filters/index.css +210 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +78 -0
- package/es/components/popover/color-rules-popover.js +218 -0
- package/es/components/popover/color-selector-popover.js +83 -0
- package/es/constants/index.js +2 -1
- package/es/custom-g2.js +644 -0
- package/es/dashboard.js +31 -9
- package/es/desktop-dashboard.js +32 -51
- package/es/mobile-dashboard.js +16 -8
- package/es/model/bar-group.js +58 -0
- package/es/model/bar.js +47 -0
- package/es/model/base-model.js +18 -0
- package/es/model/basic-number-card.js +25 -0
- package/es/model/combination.js +48 -0
- package/es/model/compare-bar.js +56 -0
- package/es/model/completeness-group.js +31 -0
- package/es/model/completeness.js +25 -0
- package/es/model/custom-bar.js +25 -0
- package/es/model/dashboard.js +20 -0
- package/es/model/generic-model.js +222 -0
- package/es/model/heat-map.js +33 -0
- package/es/model/horizontal-bar-group.js +55 -0
- package/es/model/horizontal-bar.js +47 -0
- package/es/model/index.js +187 -0
- package/es/model/map.js +38 -0
- package/es/model/mirror.js +33 -0
- package/es/model/pie.js +38 -0
- package/es/model/ring.js +40 -0
- package/es/model/scatter.js +22 -0
- package/es/model/table.js +32 -0
- package/es/model/trend.js +32 -0
- package/es/model/world-map.js +34 -0
- package/es/service/chart-service.js +15 -8
- package/es/service/dashboard-service.js +29 -25
- package/es/stat-editor/chart-name-editor.js +68 -0
- package/es/stat-editor/index.js +75 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +153 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +422 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +203 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +23 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +104 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +334 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +119 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +240 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +331 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +143 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +144 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +214 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +121 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +172 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +366 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +142 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +473 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +182 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +564 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +112 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +87 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +187 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +300 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +113 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +289 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +58 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +359 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +48 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +121 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +143 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +269 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +104 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +366 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +55 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +130 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +374 -0
- package/es/stat-editor/stat-settings/map/map-level.js +72 -0
- package/es/stat-editor/stat-settings/map/map-province-city.js +151 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +108 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +154 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +125 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +24 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +62 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +61 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +35 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +123 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +33 -0
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +29 -0
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +82 -0
- package/es/stat-list/chart-preview.js +20 -19
- package/es/stat-list/index.js +21 -15
- package/es/stat-view/area-chart.js +551 -0
- package/es/stat-view/bar-chart.js +582 -0
- package/es/stat-view/base-chart.js +132 -0
- package/es/stat-view/basic-number-card.js +201 -0
- package/es/stat-view/combination-chart.js +546 -0
- package/es/stat-view/compare-chart.js +483 -0
- package/es/stat-view/completeness-chart.js +390 -0
- package/es/stat-view/custom-bar.js +418 -0
- package/es/stat-view/dashboard-chart.js +266 -0
- package/es/stat-view/heat-map.js +463 -0
- package/es/stat-view/horizontal-bar-chart.js +562 -0
- package/es/stat-view/index.js +156 -47
- package/es/stat-view/line-chart.js +518 -0
- package/es/stat-view/map.js +448 -0
- package/es/stat-view/mirror.js +275 -0
- package/es/stat-view/pie-chart.js +290 -0
- package/es/stat-view/pivot-table/index.js +196 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +156 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +176 -0
- package/es/stat-view/pivot-table/pivot-table-display-name.js +215 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +384 -0
- package/es/stat-view/ring-chart.js +392 -0
- package/es/stat-view/scatter-chart.js +306 -0
- package/es/stat-view/treemap-chart.js +253 -0
- package/es/stat-view/trend-chart.js +249 -0
- package/es/stat-view/world-map.js +431 -0
- package/es/tabs/tab.js +2 -2
- package/es/utils/basic-chart-utils.js +29 -0
- package/es/utils/cell-format.js +115 -0
- package/es/utils/collaborator.js +50 -0
- package/es/utils/color-utils.js +134 -0
- package/es/utils/column-utils.js +110 -0
- package/es/utils/column.js +20 -0
- package/es/utils/common-utils.js +352 -2
- package/es/utils/date-format.js +71 -0
- package/es/utils/export-table-utils.js +69 -0
- package/es/utils/index.js +89 -12
- package/es/utils/map.js +114 -0
- package/es/utils/model.js +19 -0
- package/es/utils/row-utils.js +134 -0
- package/es/utils/search.js +73 -0
- package/es/utils/sql-utils.js +359 -0
- package/es/utils/stat-utils.js +351 -0
- package/es/utils/trend-utils.js +135 -0
- package/package.json +8 -6
- package/es/components/dialog/chart-edit-dialog.js +0 -93
- package/es/components/dtable-popover.js +0 -97
- package/es/components/dtable-search-input.js +0 -135
- package/es/components/index.js +0 -41
- package/es/components/loading.js +0 -15
- package/es/components/modal-portal.js +0 -26
- package/es/model/conver-statItem.js +0 -124
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
+
var _baseSettings = _interopRequireDefault(require("../public-setting/base-settings"));
|
|
12
|
+
var _groupbySettings = _interopRequireDefault(require("./groupby-settings"));
|
|
13
|
+
var _stacksSettings = _interopRequireDefault(require("./stacks-settings"));
|
|
14
|
+
var _barChartStyleSetting = _interopRequireDefault(require("./style-setting/bar-chart-style-setting"));
|
|
15
|
+
var _constants = require("../../../constants");
|
|
16
|
+
class CustomBarSettings extends _react.Component {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.onSelectGroupbyColumn = (type, groupbyColumnKey, groupbyDateGranularity, groupbyGeolocationGranularity) => {
|
|
20
|
+
let updated = {
|
|
21
|
+
x_axis_column_key: groupbyColumnKey,
|
|
22
|
+
x_axis_date_granularity: groupbyDateGranularity,
|
|
23
|
+
x_axis_geolocation_granularity: groupbyGeolocationGranularity
|
|
24
|
+
};
|
|
25
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
26
|
+
};
|
|
27
|
+
this.onSelectGroupbyDateGranularity = (type, dateGranularity) => {
|
|
28
|
+
let updated = {
|
|
29
|
+
x_axis_date_granularity: dateGranularity
|
|
30
|
+
};
|
|
31
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
32
|
+
};
|
|
33
|
+
this.onSelectGroupbyGeolocationGranularity = (type, geolocationGranularity) => {
|
|
34
|
+
let updated = {
|
|
35
|
+
x_axis_geolocation_granularity: geolocationGranularity
|
|
36
|
+
};
|
|
37
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
38
|
+
};
|
|
39
|
+
this.hasYAxisStack = () => {
|
|
40
|
+
const {
|
|
41
|
+
y_axises
|
|
42
|
+
} = this.props.statItem;
|
|
43
|
+
return Array.isArray(y_axises) && y_axises.some(yAxis => yAxis.type === _constants.STAT_TYPE.BAR_STACK);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
const {
|
|
48
|
+
getTableById,
|
|
49
|
+
getTables,
|
|
50
|
+
getViews,
|
|
51
|
+
statItem,
|
|
52
|
+
labelColorConfigs,
|
|
53
|
+
eventBus,
|
|
54
|
+
selectedTable,
|
|
55
|
+
generalColumnsOptions,
|
|
56
|
+
numericColumnsOptions,
|
|
57
|
+
dateGranularityOptions,
|
|
58
|
+
geolocationGranularityOptions,
|
|
59
|
+
renderIncludeEmpty,
|
|
60
|
+
settingType
|
|
61
|
+
} = this.props;
|
|
62
|
+
const {
|
|
63
|
+
table_id,
|
|
64
|
+
view_id,
|
|
65
|
+
x_axis_column_key,
|
|
66
|
+
x_axis_date_granularity,
|
|
67
|
+
x_axis_geolocation_granularity
|
|
68
|
+
} = statItem || {};
|
|
69
|
+
const hasYAxisStack = this.hasYAxisStack();
|
|
70
|
+
if (settingType === 'style') {
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement(_barChartStyleSetting.default, {
|
|
72
|
+
showRangeSetting: false,
|
|
73
|
+
hideDisplayDataSetting: true,
|
|
74
|
+
enableYAxisCustomTitle: hasYAxisStack,
|
|
75
|
+
isDisplayEachBlockData: hasYAxisStack,
|
|
76
|
+
statItem: statItem,
|
|
77
|
+
labelColorConfigs: labelColorConfigs,
|
|
78
|
+
eventBus: eventBus,
|
|
79
|
+
getTableById: getTableById,
|
|
80
|
+
updateStatItem: this.props.updateStatItem
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_baseSettings.default, {
|
|
84
|
+
statItem: statItem,
|
|
85
|
+
selectedTableId: table_id,
|
|
86
|
+
selectedViewId: view_id,
|
|
87
|
+
getTableById: getTableById,
|
|
88
|
+
getTables: getTables,
|
|
89
|
+
getViews: getViews,
|
|
90
|
+
getConvertedChart: this.props.getConvertedChart,
|
|
91
|
+
updateStatItem: this.props.updateStatItem
|
|
92
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
className: "statistic-chart-parameter-divider"
|
|
94
|
+
}), /*#__PURE__*/_react.default.createElement(_groupbySettings.default, {
|
|
95
|
+
selectedTable: selectedTable,
|
|
96
|
+
columnsOptions: generalColumnsOptions,
|
|
97
|
+
dateGranularityOptions: dateGranularityOptions,
|
|
98
|
+
geolocationGranularityOptions: geolocationGranularityOptions,
|
|
99
|
+
label: _reactIntlUniversal.default.get('X-axis'),
|
|
100
|
+
groupbyColumnKey: x_axis_column_key,
|
|
101
|
+
groupbyDateGranularity: x_axis_date_granularity,
|
|
102
|
+
groupbyGeolocationGranularity: x_axis_geolocation_granularity,
|
|
103
|
+
getSelectedColumnOption: this.props.getSelectedColumnOption,
|
|
104
|
+
onSelectGroupbyColumn: this.onSelectGroupbyColumn.bind(this, _constants.GROUPBY_TYPE.ROW),
|
|
105
|
+
onSelectGroupbyDateGranularity: this.onSelectGroupbyDateGranularity.bind(this, _constants.GROUPBY_TYPE.ROW),
|
|
106
|
+
onSelectGroupbyGeolocationGranularity: this.onSelectGroupbyGeolocationGranularity.bind(this, _constants.GROUPBY_TYPE.ROW),
|
|
107
|
+
renderIncludeEmpty: renderIncludeEmpty
|
|
108
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
className: "statistic-chart-parameter-divider"
|
|
110
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
className: "statistic-chart-parameter-item"
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement("label", null, _reactIntlUniversal.default.get('Y-axis')), /*#__PURE__*/_react.default.createElement("div", {
|
|
113
|
+
className: "statistic-custom-bar-setting-y-axises"
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement(_stacksSettings.default, {
|
|
115
|
+
statItem: statItem,
|
|
116
|
+
numericColumnsOptions: numericColumnsOptions,
|
|
117
|
+
updateStatItem: this.props.updateStatItem
|
|
118
|
+
}))));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var _default = exports.default = CustomBarSettings;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
|
+
var _DTableSelect = _interopRequireDefault(require("dtable-ui-component/lib/DTableSelect"));
|
|
13
|
+
class GroupbySettings extends _react.Component {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.getCustomFilterOption = (option, input) => {
|
|
17
|
+
var _option$data, _option$data$value;
|
|
18
|
+
const labelValue = (option === null || option === void 0 ? void 0 : (_option$data = option.data) === null || _option$data === void 0 ? void 0 : (_option$data$value = _option$data.value) === null || _option$data$value === void 0 ? void 0 : _option$data$value.name) && option.data.value.name.trim().toLowerCase() || '';
|
|
19
|
+
const inputValue = typeof input === 'string' && input.trim().toLowerCase();
|
|
20
|
+
return labelValue.includes(inputValue);
|
|
21
|
+
};
|
|
22
|
+
this.renderGroupby = () => {
|
|
23
|
+
const {
|
|
24
|
+
columnsOptions,
|
|
25
|
+
groupbyColumnKey,
|
|
26
|
+
label
|
|
27
|
+
} = this.props;
|
|
28
|
+
const selectedColumnOption = this.props.getSelectedColumnOption(groupbyColumnKey, columnsOptions);
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("label", null, label), /*#__PURE__*/_react.default.createElement(_DTableSelect.default, {
|
|
30
|
+
isSearchable: true,
|
|
31
|
+
placeholder: _reactIntlUniversal.default.get('Select_column'),
|
|
32
|
+
value: selectedColumnOption,
|
|
33
|
+
onChange: this.onSelectGroupbyColumn,
|
|
34
|
+
options: columnsOptions,
|
|
35
|
+
customFilterOption: this.getCustomFilterOption,
|
|
36
|
+
noOptionsMessage: () => _reactIntlUniversal.default.get('No_options')
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
this.renderGroupbyDateGranularity = () => {
|
|
40
|
+
let {
|
|
41
|
+
dateGranularityOptions,
|
|
42
|
+
groupbyDateGranularity
|
|
43
|
+
} = this.props;
|
|
44
|
+
let selectedDateGranularity = this.getSelectedDateGranularity(groupbyDateGranularity);
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
46
|
+
className: "mt-1"
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement(_DTableSelect.default, {
|
|
48
|
+
value: selectedDateGranularity,
|
|
49
|
+
onChange: this.onSelectGroupbyDateGranularity,
|
|
50
|
+
options: dateGranularityOptions
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
this.renderGroupbyGeolocationGranularity = () => {
|
|
54
|
+
let {
|
|
55
|
+
geolocationGranularityOptions,
|
|
56
|
+
groupbyGeolocationGranularity
|
|
57
|
+
} = this.props;
|
|
58
|
+
geolocationGranularityOptions = this.getGeolocationGranularity();
|
|
59
|
+
let selectedGeolocationGranularity = this.getSelectedGeolocationGranularity(groupbyGeolocationGranularity);
|
|
60
|
+
if (geolocationGranularityOptions.length === 0) return null;
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
className: "mt-1"
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_DTableSelect.default, {
|
|
64
|
+
value: selectedGeolocationGranularity,
|
|
65
|
+
onChange: this.onSelectGroupbyGeolocationGranularity,
|
|
66
|
+
options: geolocationGranularityOptions
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
this.getGeolocationGranularity = () => {
|
|
70
|
+
let {
|
|
71
|
+
geolocationGranularityOptions,
|
|
72
|
+
selectedTable,
|
|
73
|
+
groupbyColumnKey
|
|
74
|
+
} = this.props;
|
|
75
|
+
const column = selectedTable.columns.find(column => column.key === groupbyColumnKey);
|
|
76
|
+
if (column) {
|
|
77
|
+
const {
|
|
78
|
+
geo_format
|
|
79
|
+
} = column.data || {};
|
|
80
|
+
if (geo_format === 'province') {
|
|
81
|
+
geolocationGranularityOptions = geolocationGranularityOptions.filter(option => option.value === 'province');
|
|
82
|
+
}
|
|
83
|
+
if (geo_format === 'province_city') {
|
|
84
|
+
geolocationGranularityOptions = geolocationGranularityOptions.filter(option => option.value !== 'district');
|
|
85
|
+
}
|
|
86
|
+
if (geo_format === 'country_region' || geo_format === 'lng_lat') {
|
|
87
|
+
geolocationGranularityOptions = [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return geolocationGranularityOptions;
|
|
91
|
+
};
|
|
92
|
+
this.getSelectedDateGranularity = dateGranularity => {
|
|
93
|
+
let {
|
|
94
|
+
dateGranularityOptions
|
|
95
|
+
} = this.props;
|
|
96
|
+
return dateGranularityOptions.find(g => g.value === dateGranularity) || dateGranularityOptions[2];
|
|
97
|
+
};
|
|
98
|
+
this.getSelectedGeolocationGranularity = geolocationGranularity => {
|
|
99
|
+
let {
|
|
100
|
+
geolocationGranularityOptions
|
|
101
|
+
} = this.props;
|
|
102
|
+
return geolocationGranularityOptions.find(g => g.value === geolocationGranularity) || geolocationGranularityOptions[2];
|
|
103
|
+
};
|
|
104
|
+
this.onSelectGroupbyColumn = columnOption => {
|
|
105
|
+
let {
|
|
106
|
+
dateGranularityOptions,
|
|
107
|
+
groupbyColumnKey,
|
|
108
|
+
groupbyDateGranularity,
|
|
109
|
+
groupbyGeolocationGranularity,
|
|
110
|
+
selectedTable
|
|
111
|
+
} = this.props;
|
|
112
|
+
let {
|
|
113
|
+
key,
|
|
114
|
+
type
|
|
115
|
+
} = columnOption.value;
|
|
116
|
+
if (key === groupbyColumnKey) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (key !== 'Groupby_null') {
|
|
120
|
+
groupbyColumnKey = key;
|
|
121
|
+
if (type === _dtableUtils.CellType.DATE) {
|
|
122
|
+
groupbyDateGranularity = dateGranularityOptions[2].value;
|
|
123
|
+
}
|
|
124
|
+
if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
125
|
+
const geoColumn = selectedTable.columns.find(column => column.key === key) || {};
|
|
126
|
+
const {
|
|
127
|
+
geo_format
|
|
128
|
+
} = geoColumn.data || {};
|
|
129
|
+
if (geo_format === 'province') {
|
|
130
|
+
groupbyGeolocationGranularity = 'province';
|
|
131
|
+
} else if (geo_format === 'province_city') {
|
|
132
|
+
groupbyGeolocationGranularity = 'city';
|
|
133
|
+
} else if (geo_format === 'geolocation' || !geo_format) {
|
|
134
|
+
groupbyGeolocationGranularity = 'district';
|
|
135
|
+
} else {
|
|
136
|
+
groupbyGeolocationGranularity = null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
groupbyColumnKey = null;
|
|
141
|
+
groupbyDateGranularity = null;
|
|
142
|
+
groupbyGeolocationGranularity = null;
|
|
143
|
+
}
|
|
144
|
+
this.props.onSelectGroupbyColumn(groupbyColumnKey, groupbyDateGranularity, groupbyGeolocationGranularity);
|
|
145
|
+
};
|
|
146
|
+
this.onSelectGroupbyDateGranularity = dateGranularityOption => {
|
|
147
|
+
let newDateGranularity = dateGranularityOption.value;
|
|
148
|
+
if (newDateGranularity === this.props.groupbyDateGranularity) return;
|
|
149
|
+
this.props.onSelectGroupbyDateGranularity(newDateGranularity);
|
|
150
|
+
};
|
|
151
|
+
this.onSelectGroupbyGeolocationGranularity = geolocationGranularityOption => {
|
|
152
|
+
let newGeolocationGranularity = geolocationGranularityOption.value;
|
|
153
|
+
if (newGeolocationGranularity === this.props.groupbyGeolocationGranularity) return;
|
|
154
|
+
this.props.onSelectGroupbyGeolocationGranularity(newGeolocationGranularity);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
render() {
|
|
158
|
+
const {
|
|
159
|
+
selectedTable,
|
|
160
|
+
groupbyColumnKey,
|
|
161
|
+
renderIncludeEmpty
|
|
162
|
+
} = this.props;
|
|
163
|
+
const groupbyColumn = groupbyColumnKey && (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupbyColumnKey);
|
|
164
|
+
const {
|
|
165
|
+
type: groupbyColumnType
|
|
166
|
+
} = groupbyColumn || {};
|
|
167
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
168
|
+
className: "statistic-chart-parameter-item"
|
|
169
|
+
}, this.renderGroupby(), _dtableUtils.DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && this.renderGroupbyDateGranularity(), groupbyColumnType === _dtableUtils.CellType.GEOLOCATION && this.renderGroupbyGeolocationGranularity(), renderIncludeEmpty && renderIncludeEmpty());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
var _default = exports.default = GroupbySettings;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
+
var _DTableSelect = _interopRequireDefault(require("dtable-ui-component/lib/DTableSelect"));
|
|
12
|
+
var _groupbySettings = _interopRequireDefault(require("./groupby-settings"));
|
|
13
|
+
var _summaryMethodSetting = _interopRequireDefault(require("./summary-method-setting"));
|
|
14
|
+
var _numericSummaryItem = _interopRequireDefault(require("../public-setting/numeric-summary-item"));
|
|
15
|
+
var _constants = require("../../../constants");
|
|
16
|
+
const GROUP_TYPES = {
|
|
17
|
+
COUNT: 'count',
|
|
18
|
+
SINGLE_NUMERIC_COLUMN: 'single_numeric_column',
|
|
19
|
+
MULTIPLE_NUMERIC_COLUMN: 'multiple_numeric_column'
|
|
20
|
+
};
|
|
21
|
+
class GroupingSettings extends _react.Component {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.getSummaryMethodsOptions = () => {
|
|
25
|
+
return _constants.SUMMARY_METHOD.map(m => {
|
|
26
|
+
return {
|
|
27
|
+
value: m,
|
|
28
|
+
label: /*#__PURE__*/_react.default.createElement("span", {
|
|
29
|
+
className: 'select-module select-module-name'
|
|
30
|
+
}, _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW[m]))
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
this.getDefaultColumnGroupbyType = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
horizontal_axis_summary_type,
|
|
37
|
+
column_groupby_multiple_numeric_column
|
|
38
|
+
} = _ref;
|
|
39
|
+
if (column_groupby_multiple_numeric_column) {
|
|
40
|
+
return GROUP_TYPES.MULTIPLE_NUMERIC_COLUMN;
|
|
41
|
+
} else if (horizontal_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
42
|
+
return GROUP_TYPES.SINGLE_NUMERIC_COLUMN;
|
|
43
|
+
}
|
|
44
|
+
return GROUP_TYPES.COUNT;
|
|
45
|
+
};
|
|
46
|
+
this.getGroupTypeOptions = () => {
|
|
47
|
+
return [{
|
|
48
|
+
value: GROUP_TYPES.COUNT,
|
|
49
|
+
label: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
+
className: 'select-module select-module-name'
|
|
51
|
+
}, _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW['count'])), /*#__PURE__*/_react.default.createElement("div", {
|
|
52
|
+
className: "summary-type-explanation"
|
|
53
|
+
}, _reactIntlUniversal.default.get('Count_the_number_of_records_in_each_group')))
|
|
54
|
+
}, {
|
|
55
|
+
value: GROUP_TYPES.SINGLE_NUMERIC_COLUMN,
|
|
56
|
+
label: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
+
className: 'select-module select-module-name'
|
|
58
|
+
}, _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW['advanced'])), /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
+
className: "summary-type-explanation"
|
|
60
|
+
}, _reactIntlUniversal.default.get('Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field')))
|
|
61
|
+
}, {
|
|
62
|
+
value: GROUP_TYPES.MULTIPLE_NUMERIC_COLUMN,
|
|
63
|
+
label: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
64
|
+
className: 'select-module select-module-name'
|
|
65
|
+
}, _reactIntlUniversal.default.get('Summarize_multiple_fields')), /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: "summary-type-explanation"
|
|
67
|
+
}, _reactIntlUniversal.default.get('Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_multiple_fields')))
|
|
68
|
+
}];
|
|
69
|
+
};
|
|
70
|
+
this.onChangeGroupType = option => {
|
|
71
|
+
const value = option.value;
|
|
72
|
+
if (value === this.state.columnGroupbyType) return;
|
|
73
|
+
const {
|
|
74
|
+
statItem
|
|
75
|
+
} = this.props;
|
|
76
|
+
let {
|
|
77
|
+
column_groupby_column_key,
|
|
78
|
+
column_groupby_date_granularity,
|
|
79
|
+
column_groupby_geolocation_granularity,
|
|
80
|
+
column_groupby_multiple_numeric_column,
|
|
81
|
+
column_groupby_numeric_columns,
|
|
82
|
+
vertical_axis_column_key,
|
|
83
|
+
horizontal_axis_summary_type,
|
|
84
|
+
horizontal_axis_column_key,
|
|
85
|
+
horizontal_axis_summary_method
|
|
86
|
+
} = this.props.statItem || {};
|
|
87
|
+
if (value === GROUP_TYPES.SINGLE_NUMERIC_COLUMN) {
|
|
88
|
+
column_groupby_multiple_numeric_column = false;
|
|
89
|
+
column_groupby_numeric_columns = [];
|
|
90
|
+
horizontal_axis_summary_type = _constants.SUMMARY_TYPE.ADVANCED;
|
|
91
|
+
horizontal_axis_column_key = null;
|
|
92
|
+
column_groupby_date_granularity = null;
|
|
93
|
+
column_groupby_column_key = null;
|
|
94
|
+
column_groupby_geolocation_granularity = null;
|
|
95
|
+
horizontal_axis_summary_method = _constants.SUMMARY_METHOD[0];
|
|
96
|
+
} else if (value === GROUP_TYPES.COUNT) {
|
|
97
|
+
column_groupby_multiple_numeric_column = false;
|
|
98
|
+
column_groupby_numeric_columns = [];
|
|
99
|
+
const groupColumn = this.props.columnGroupbyColumnsOptions.find(column => {
|
|
100
|
+
const {
|
|
101
|
+
key,
|
|
102
|
+
type
|
|
103
|
+
} = column;
|
|
104
|
+
return key !== vertical_axis_column_key && (type !== 'date' || type !== 'geolocation');
|
|
105
|
+
}) || {};
|
|
106
|
+
column_groupby_column_key = groupColumn.key;
|
|
107
|
+
horizontal_axis_summary_type = _constants.SUMMARY_TYPE.COUNT;
|
|
108
|
+
horizontal_axis_column_key = null;
|
|
109
|
+
column_groupby_date_granularity = null;
|
|
110
|
+
column_groupby_geolocation_granularity = null;
|
|
111
|
+
} else if (value === GROUP_TYPES.MULTIPLE_NUMERIC_COLUMN) {
|
|
112
|
+
horizontal_axis_summary_type = _constants.SUMMARY_TYPE.ADVANCED;
|
|
113
|
+
column_groupby_multiple_numeric_column = true;
|
|
114
|
+
column_groupby_numeric_columns = [];
|
|
115
|
+
horizontal_axis_summary_type = _constants.SUMMARY_TYPE.ADVANCED;
|
|
116
|
+
horizontal_axis_column_key = this.props.numericColumnsOptions.length > 0 ? this.props.numericColumnsOptions[0].value.key : null;
|
|
117
|
+
column_groupby_date_granularity = null;
|
|
118
|
+
column_groupby_geolocation_granularity = null;
|
|
119
|
+
horizontal_axis_summary_method = _constants.SUMMARY_METHOD[0];
|
|
120
|
+
}
|
|
121
|
+
let updated = {
|
|
122
|
+
column_groupby_column_key,
|
|
123
|
+
column_groupby_date_granularity,
|
|
124
|
+
column_groupby_geolocation_granularity,
|
|
125
|
+
column_groupby_multiple_numeric_column,
|
|
126
|
+
column_groupby_numeric_columns,
|
|
127
|
+
horizontal_axis_summary_type,
|
|
128
|
+
horizontal_axis_column_key,
|
|
129
|
+
horizontal_axis_summary_method
|
|
130
|
+
};
|
|
131
|
+
this.setState({
|
|
132
|
+
columnGroupbyType: value
|
|
133
|
+
}, () => {
|
|
134
|
+
this.props.updateStatItem(Object.assign({}, statItem, updated));
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
this.getSelectedGroupType = () => {
|
|
138
|
+
const {
|
|
139
|
+
statItem
|
|
140
|
+
} = this.props;
|
|
141
|
+
const {
|
|
142
|
+
horizontal_axis_summary_type,
|
|
143
|
+
column_groupby_multiple_numeric_column
|
|
144
|
+
} = statItem;
|
|
145
|
+
if (column_groupby_multiple_numeric_column) {
|
|
146
|
+
return this.groupTypeOptions.find(item => item.value === GROUP_TYPES.MULTIPLE_NUMERIC_COLUMN);
|
|
147
|
+
}
|
|
148
|
+
if (horizontal_axis_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
149
|
+
return this.groupTypeOptions[0];
|
|
150
|
+
}
|
|
151
|
+
if (horizontal_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
152
|
+
return this.groupTypeOptions[1];
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
this.onSelectGroupbyColumn = (type, groupbyColumnKey, groupbyDateGranularity, groupbyGeolocationGranularity) => {
|
|
156
|
+
let updated = {
|
|
157
|
+
column_groupby_column_key: groupbyColumnKey,
|
|
158
|
+
column_groupby_date_granularity: groupbyDateGranularity,
|
|
159
|
+
column_groupby_geolocation_granularity: groupbyGeolocationGranularity
|
|
160
|
+
};
|
|
161
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
162
|
+
};
|
|
163
|
+
this.onSelectGroupbyDateGranularity = (type, dateGranularity) => {
|
|
164
|
+
let updated = {
|
|
165
|
+
column_groupby_date_granularity: dateGranularity
|
|
166
|
+
};
|
|
167
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
168
|
+
};
|
|
169
|
+
this.onSelectGroupbyGeolocationGranularity = (type, geolocationGranularity) => {
|
|
170
|
+
let updated = {
|
|
171
|
+
column_groupby_geolocation_granularity: geolocationGranularity
|
|
172
|
+
};
|
|
173
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, updated));
|
|
174
|
+
};
|
|
175
|
+
this.updateSummaryMethod = summaryMethod => {
|
|
176
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
177
|
+
horizontal_axis_summary_method: summaryMethod
|
|
178
|
+
}));
|
|
179
|
+
};
|
|
180
|
+
this.updateSummaryColumn = summaryColumnKey => {
|
|
181
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
182
|
+
horizontal_axis_column_key: summaryColumnKey
|
|
183
|
+
}));
|
|
184
|
+
};
|
|
185
|
+
this.renderGroupbyNumericColumns = () => {
|
|
186
|
+
const {
|
|
187
|
+
statItem
|
|
188
|
+
} = this.props;
|
|
189
|
+
let {
|
|
190
|
+
column_groupby_numeric_columns
|
|
191
|
+
} = statItem;
|
|
192
|
+
if (!column_groupby_numeric_columns || !Array.isArray(column_groupby_numeric_columns)) return null;
|
|
193
|
+
return column_groupby_numeric_columns.map((item, index) => {
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement(_numericSummaryItem.default, {
|
|
195
|
+
statItem: statItem,
|
|
196
|
+
key: "number-column-".concat(index),
|
|
197
|
+
numericColumnsOptions: this.props.numericColumnsOptions,
|
|
198
|
+
summaryMethodOptions: this.summaryMethodsOptions,
|
|
199
|
+
index: index + 1,
|
|
200
|
+
numericColumnItem: item,
|
|
201
|
+
onDeleteNumericColumnItem: this.onDeleteNumericColumnItem,
|
|
202
|
+
onChangeColumnOption: this.onChangeGroupbyNumericColumn,
|
|
203
|
+
onChangeSummaryMethod: this.onChangeSummaryMethod
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
this.onAddNumericColumn = () => {
|
|
208
|
+
let {
|
|
209
|
+
statItem,
|
|
210
|
+
numericColumnsOptions
|
|
211
|
+
} = this.props;
|
|
212
|
+
let {
|
|
213
|
+
column_groupby_numeric_columns
|
|
214
|
+
} = statItem || {};
|
|
215
|
+
let newNumericColumnKey = numericColumnsOptions[0].value.key;
|
|
216
|
+
if (Array.isArray(column_groupby_numeric_columns)) {
|
|
217
|
+
column_groupby_numeric_columns = [...column_groupby_numeric_columns];
|
|
218
|
+
column_groupby_numeric_columns.push({
|
|
219
|
+
column_key: newNumericColumnKey,
|
|
220
|
+
summary_method: _constants.SUMMARY_METHOD[0]
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
column_groupby_numeric_columns = [{
|
|
224
|
+
column_key: newNumericColumnKey,
|
|
225
|
+
summary_method: _constants.SUMMARY_METHOD[0]
|
|
226
|
+
}];
|
|
227
|
+
}
|
|
228
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
229
|
+
column_groupby_numeric_columns: [...column_groupby_numeric_columns]
|
|
230
|
+
}));
|
|
231
|
+
};
|
|
232
|
+
this.onChangeGroupbyNumericColumn = (index, columnOption) => {
|
|
233
|
+
if (index === 0) {
|
|
234
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
235
|
+
horizontal_axis_column_key: columnOption.value.key
|
|
236
|
+
}));
|
|
237
|
+
} else {
|
|
238
|
+
let {
|
|
239
|
+
column_groupby_numeric_columns
|
|
240
|
+
} = this.props.statItem || {};
|
|
241
|
+
column_groupby_numeric_columns = column_groupby_numeric_columns || [];
|
|
242
|
+
column_groupby_numeric_columns = [...column_groupby_numeric_columns];
|
|
243
|
+
let selectedItem = column_groupby_numeric_columns[index - 1];
|
|
244
|
+
selectedItem = Object.assign({}, selectedItem, {
|
|
245
|
+
column_key: columnOption.value.key
|
|
246
|
+
});
|
|
247
|
+
column_groupby_numeric_columns[index - 1] = selectedItem;
|
|
248
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
249
|
+
column_groupby_numeric_columns
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
this.onDeleteNumericColumnItem = index => {
|
|
254
|
+
let {
|
|
255
|
+
column_groupby_numeric_columns
|
|
256
|
+
} = this.props.statItem || {};
|
|
257
|
+
column_groupby_numeric_columns = column_groupby_numeric_columns || [];
|
|
258
|
+
column_groupby_numeric_columns = [...column_groupby_numeric_columns];
|
|
259
|
+
column_groupby_numeric_columns.splice(index - 1, 1);
|
|
260
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
261
|
+
column_groupby_numeric_columns: [...column_groupby_numeric_columns]
|
|
262
|
+
}));
|
|
263
|
+
};
|
|
264
|
+
this.onChangeSummaryMethod = (index, option) => {
|
|
265
|
+
if (index === 0) {
|
|
266
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
267
|
+
horizontal_axis_summary_method: option.value
|
|
268
|
+
}));
|
|
269
|
+
} else {
|
|
270
|
+
let {
|
|
271
|
+
column_groupby_numeric_columns
|
|
272
|
+
} = this.props.statItem || {};
|
|
273
|
+
column_groupby_numeric_columns = column_groupby_numeric_columns || [];
|
|
274
|
+
column_groupby_numeric_columns = [...column_groupby_numeric_columns];
|
|
275
|
+
let selectedItem = column_groupby_numeric_columns[index - 1];
|
|
276
|
+
selectedItem = Object.assign({}, selectedItem, {
|
|
277
|
+
summary_method: option.value
|
|
278
|
+
});
|
|
279
|
+
column_groupby_numeric_columns[index - 1] = selectedItem;
|
|
280
|
+
this.props.updateStatItem(Object.assign({}, this.props.statItem, {
|
|
281
|
+
column_groupby_numeric_columns
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
this.groupTypeOptions = this.getGroupTypeOptions();
|
|
286
|
+
this.summaryMethodsOptions = this.getSummaryMethodsOptions();
|
|
287
|
+
this.state = {
|
|
288
|
+
columnGroupbyType: this.getDefaultColumnGroupbyType(props.statItem)
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
render() {
|
|
292
|
+
let {
|
|
293
|
+
label,
|
|
294
|
+
statItem,
|
|
295
|
+
selectedTable,
|
|
296
|
+
columnGroupbyColumnsOptions,
|
|
297
|
+
numericColumnsOptions,
|
|
298
|
+
dateGranularityOptions,
|
|
299
|
+
geolocationGranularityOptions
|
|
300
|
+
} = this.props;
|
|
301
|
+
const selectedGroupItem = this.getSelectedGroupType();
|
|
302
|
+
let {
|
|
303
|
+
horizontal_axis_summary_type,
|
|
304
|
+
horizontal_axis_column_key,
|
|
305
|
+
horizontal_axis_summary_method,
|
|
306
|
+
column_groupby_column_key,
|
|
307
|
+
column_groupby_date_granularity,
|
|
308
|
+
column_groupby_geolocation_granularity,
|
|
309
|
+
column_groupby_multiple_numeric_column
|
|
310
|
+
} = statItem || {};
|
|
311
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
312
|
+
className: "statistic-chart-parameter-item"
|
|
313
|
+
}, /*#__PURE__*/_react.default.createElement("label", null, label), /*#__PURE__*/_react.default.createElement(_DTableSelect.default, {
|
|
314
|
+
classNamePrefix: "statistic-chart-summary-types",
|
|
315
|
+
value: selectedGroupItem,
|
|
316
|
+
onChange: this.onChangeGroupType,
|
|
317
|
+
options: this.groupTypeOptions
|
|
318
|
+
})), horizontal_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED && (column_groupby_multiple_numeric_column ? /*#__PURE__*/_react.default.createElement(_numericSummaryItem.default, {
|
|
319
|
+
statItem: statItem,
|
|
320
|
+
index: 0,
|
|
321
|
+
key: "number-column-".concat(0),
|
|
322
|
+
numericColumnsOptions: numericColumnsOptions,
|
|
323
|
+
summaryMethodOptions: this.summaryMethodsOptions,
|
|
324
|
+
numericColumnItem: {
|
|
325
|
+
column_key: horizontal_axis_column_key,
|
|
326
|
+
summary_method: horizontal_axis_summary_method
|
|
327
|
+
},
|
|
328
|
+
onChangeColumnOption: this.onChangeGroupbyNumericColumn,
|
|
329
|
+
onChangeSummaryMethod: this.onChangeSummaryMethod
|
|
330
|
+
}) : /*#__PURE__*/_react.default.createElement(_summaryMethodSetting.default, {
|
|
331
|
+
statItem: statItem,
|
|
332
|
+
numericColumnsOptions: numericColumnsOptions,
|
|
333
|
+
summaryType: horizontal_axis_summary_type,
|
|
334
|
+
summaryColumnKey: horizontal_axis_column_key,
|
|
335
|
+
summaryMethod: horizontal_axis_summary_method,
|
|
336
|
+
getSelectedColumnOption: this.props.getSelectedColumnOption,
|
|
337
|
+
onChangeSummaryType: this.updatedSummaryType,
|
|
338
|
+
onSelectSummaryMethod: this.updateSummaryMethod,
|
|
339
|
+
onSelectNumericColumn: this.updateSummaryColumn,
|
|
340
|
+
updateStatItem: this.props.updateStatItem
|
|
341
|
+
})), column_groupby_multiple_numeric_column && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
342
|
+
className: "statistics-add-number"
|
|
343
|
+
}, this.renderGroupbyNumericColumns()), Array.isArray(numericColumnsOptions) && numericColumnsOptions.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
344
|
+
className: "statistics-add-number-column",
|
|
345
|
+
onClick: this.onAddNumericColumn
|
|
346
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
347
|
+
className: "number-column-item dtable-font dtable-icon-add-table"
|
|
348
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
349
|
+
className: "number-column-item add-number-column-description"
|
|
350
|
+
}, _reactIntlUniversal.default.get('Add_new_numeric_column')))), (!column_groupby_multiple_numeric_column && horizontal_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED || horizontal_axis_summary_type === _constants.SUMMARY_TYPE.COUNT) && /*#__PURE__*/_react.default.createElement(_groupbySettings.default, {
|
|
351
|
+
selectedTable: selectedTable,
|
|
352
|
+
columnsOptions: columnGroupbyColumnsOptions,
|
|
353
|
+
dateGranularityOptions: dateGranularityOptions,
|
|
354
|
+
geolocationGranularityOptions: geolocationGranularityOptions,
|
|
355
|
+
label: _reactIntlUniversal.default.get('Group_by'),
|
|
356
|
+
groupbyColumnKey: column_groupby_column_key,
|
|
357
|
+
groupbyDateGranularity: column_groupby_date_granularity,
|
|
358
|
+
groupbyGeolocationGranularity: column_groupby_geolocation_granularity,
|
|
359
|
+
getSelectedColumnOption: this.props.getSelectedColumnOption,
|
|
360
|
+
onSelectGroupbyColumn: this.onSelectGroupbyColumn.bind(this, _constants.GROUPBY_TYPE.COLUMN),
|
|
361
|
+
onSelectGroupbyDateGranularity: this.onSelectGroupbyDateGranularity.bind(this, _constants.GROUPBY_TYPE.COLUMN),
|
|
362
|
+
onSelectGroupbyGeolocationGranularity: this.onSelectGroupbyGeolocationGranularity.bind(this, _constants.GROUPBY_TYPE.COLUMN)
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
var _default = exports.default = GroupingSettings;
|