dtable-statistic 4.3.4 → 4.3.5
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/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +108 -101
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +21 -14
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +49 -41
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +34 -27
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +41 -34
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +45 -37
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +55 -47
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +19 -11
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +53 -45
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +28 -20
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +55 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +19 -11
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +28 -20
- package/es/stat-list/index.js +35 -27
- package/es/stat-view/area-chart.js +50 -43
- package/es/stat-view/bar-chart.js +54 -47
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +56 -49
- package/es/stat-view/compare-chart.js +46 -39
- package/es/stat-view/completeness-chart.js +35 -28
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +58 -51
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +46 -39
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +45 -38
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +44 -37
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +34 -26
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +65 -41
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +33 -23
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +66 -60
- package/es/utils/trend-utils.js +40 -32
- package/package.json +3 -3
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _dataSet = _interopRequireDefault(require("@antv/data-set"));
|
|
11
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
12
|
+
var _dtableStore = require("dtable-store");
|
|
13
|
+
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
14
|
+
var _customG = require("../custom-g2");
|
|
15
|
+
var _commonUtils = require("../utils/common-utils");
|
|
16
|
+
var _basicChartUtils = require("../utils/basic-chart-utils");
|
|
17
|
+
var _colorUtils = require("../utils/color-utils");
|
|
18
|
+
var _constants = require("../constants");
|
|
12
19
|
const propTypes = {
|
|
13
|
-
isPreview:
|
|
14
|
-
isEdit:
|
|
15
|
-
colorThemeName:
|
|
16
|
-
statItem:
|
|
17
|
-
chartCalculator:
|
|
18
|
-
eventBus:
|
|
19
|
-
getTableById:
|
|
20
|
-
toggleStatisticRecordsDialog:
|
|
20
|
+
isPreview: _propTypes.default.bool,
|
|
21
|
+
isEdit: _propTypes.default.bool,
|
|
22
|
+
colorThemeName: _propTypes.default.string,
|
|
23
|
+
statItem: _propTypes.default.object,
|
|
24
|
+
chartCalculator: _propTypes.default.object,
|
|
25
|
+
eventBus: _propTypes.default.object,
|
|
26
|
+
getTableById: _propTypes.default.func,
|
|
27
|
+
toggleStatisticRecordsDialog: _propTypes.default.func
|
|
21
28
|
};
|
|
22
|
-
class BarChart extends
|
|
29
|
+
class BarChart extends _baseChart.default {
|
|
23
30
|
constructor(props) {
|
|
24
31
|
super(props);
|
|
25
32
|
this.drawChart = originalData => {
|
|
@@ -41,22 +48,22 @@ class BarChart extends BaseChart {
|
|
|
41
48
|
sort_type
|
|
42
49
|
} = statItem;
|
|
43
50
|
let data = originalData;
|
|
44
|
-
if (type === STAT_TYPE.BAR_STACK && sort_type) {
|
|
45
|
-
data = sortDataByGroupSum(originalData, sort_type);
|
|
51
|
+
if (type === _constants.STAT_TYPE.BAR_STACK && sort_type) {
|
|
52
|
+
data = (0, _commonUtils.sortDataByGroupSum)(originalData, sort_type);
|
|
46
53
|
}
|
|
47
54
|
this.initChartHandler();
|
|
48
55
|
this.chart.on('interval:click', e => {
|
|
49
56
|
this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
50
57
|
});
|
|
51
58
|
const isGroupBar = column_groupby_column_key || column_groupby_multiple_numeric_column;
|
|
52
|
-
const currentTheme = getCurrentTheme(colorThemeName);
|
|
53
|
-
let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
59
|
+
const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
|
|
60
|
+
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
54
61
|
let summaryType = summary_type;
|
|
55
62
|
let summaryMethod = summary_method;
|
|
56
|
-
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
63
|
+
if (y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
57
64
|
const table = getTableById(table_id);
|
|
58
|
-
const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
59
|
-
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
65
|
+
const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
66
|
+
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
60
67
|
}
|
|
61
68
|
if (!summaryType && y_axis_summary_type) {
|
|
62
69
|
summaryType = y_axis_summary_type;
|
|
@@ -82,7 +89,7 @@ class BarChart extends BaseChart {
|
|
|
82
89
|
const {
|
|
83
90
|
width
|
|
84
91
|
} = this.chart.coordinateBBox;
|
|
85
|
-
const chartData = isGroupBar ? getChartGroups(data) : data;
|
|
92
|
+
const chartData = isGroupBar ? (0, _basicChartUtils.getChartGroups)(data) : data;
|
|
86
93
|
const themeColors = this.getThemeColors();
|
|
87
94
|
const ticks = this.getTicks(chartData, width);
|
|
88
95
|
if (ticks.length > 0) {
|
|
@@ -135,7 +142,7 @@ class BarChart extends BaseChart {
|
|
|
135
142
|
config.height = 400;
|
|
136
143
|
config.width = 700;
|
|
137
144
|
}
|
|
138
|
-
this.chart = new Chart(config);
|
|
145
|
+
this.chart = new _customG.Chart(config);
|
|
139
146
|
};
|
|
140
147
|
this.drawBar = _ref => {
|
|
141
148
|
let {
|
|
@@ -151,7 +158,7 @@ class BarChart extends BaseChart {
|
|
|
151
158
|
color_option,
|
|
152
159
|
display_data
|
|
153
160
|
} = statItem;
|
|
154
|
-
const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && statItem.y_axis_label_color_rules && getConvertedColorRules(statItem.y_axis_label_color_rules);
|
|
161
|
+
const colorRules = color_option === _constants.TYPE_COLOR_USING.USE_RULES && statItem.y_axis_label_color_rules && (0, _colorUtils.getConvertedColorRules)(statItem.y_axis_label_color_rules);
|
|
155
162
|
this.chart.interval().label(display_data ? 'formatted_value' : false, {
|
|
156
163
|
style: {
|
|
157
164
|
fontSize: this.getLabelFontSize(),
|
|
@@ -160,8 +167,8 @@ class BarChart extends BaseChart {
|
|
|
160
167
|
}).position('name*value').tooltip('name*formatted_value', (name, value) => {
|
|
161
168
|
return {
|
|
162
169
|
value,
|
|
163
|
-
title: summaryType === STATISTICS_COUNT_TYPE.COUNT ?
|
|
164
|
-
name: !name && typeof name !== 'number' ?
|
|
170
|
+
title: summaryType === _constants.STATISTICS_COUNT_TYPE.COUNT ? _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT) : _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW[summaryMethod]),
|
|
171
|
+
name: !name && typeof name !== 'number' ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name
|
|
165
172
|
};
|
|
166
173
|
}).state({
|
|
167
174
|
active: {
|
|
@@ -170,7 +177,7 @@ class BarChart extends BaseChart {
|
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
}).style('value', value => {
|
|
173
|
-
const color = getLabelColor({
|
|
180
|
+
const color = (0, _colorUtils.getLabelColor)({
|
|
174
181
|
chart: statItem,
|
|
175
182
|
colorRules,
|
|
176
183
|
value
|
|
@@ -206,14 +213,14 @@ class BarChart extends BaseChart {
|
|
|
206
213
|
}
|
|
207
214
|
};
|
|
208
215
|
let displayData = display_data;
|
|
209
|
-
if (chartType === STAT_TYPE.BAR_STACK) {
|
|
216
|
+
if (chartType === _constants.STAT_TYPE.BAR_STACK) {
|
|
210
217
|
displayData = display_each_block_data;
|
|
211
218
|
if (displayData) {
|
|
212
219
|
labelCfg.position = 'middle';
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
// get the total value of each stack
|
|
216
|
-
const dv = new
|
|
223
|
+
const dv = new _dataSet.default.DataView().source(data);
|
|
217
224
|
dv.transform({
|
|
218
225
|
type: 'aggregate',
|
|
219
226
|
fields: ['value'],
|
|
@@ -239,7 +246,7 @@ class BarChart extends BaseChart {
|
|
|
239
246
|
|
|
240
247
|
// when the 'Group by' column is a 'single-select' column,
|
|
241
248
|
// and the user chooses to use the colors from the column.
|
|
242
|
-
if (color_option === TYPE_COLOR_USING.USE_COLUMN_COLORS) {
|
|
249
|
+
if (color_option === _constants.TYPE_COLOR_USING.USE_COLUMN_COLORS) {
|
|
243
250
|
const groupColorMapping = {};
|
|
244
251
|
data.forEach(item => {
|
|
245
252
|
if (!groupColorMapping[item.group_name]) {
|
|
@@ -256,8 +263,8 @@ class BarChart extends BaseChart {
|
|
|
256
263
|
}
|
|
257
264
|
});
|
|
258
265
|
this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name*raw_name', (name, value, group_name, raw_name) => {
|
|
259
|
-
const nameContent = !group_name && typeof group_name !== 'number' ?
|
|
260
|
-
const titleContent = !name && typeof name !== 'number' ?
|
|
266
|
+
const nameContent = !group_name && typeof group_name !== 'number' ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : group_name;
|
|
267
|
+
const titleContent = !name && typeof name !== 'number' ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
261
268
|
return {
|
|
262
269
|
value,
|
|
263
270
|
title: titleContent,
|
|
@@ -361,7 +368,7 @@ class BarChart extends BaseChart {
|
|
|
361
368
|
fill: themeColors.textColor
|
|
362
369
|
},
|
|
363
370
|
formatter: name => {
|
|
364
|
-
return !name && typeof name !== 'number' ?
|
|
371
|
+
return !name && typeof name !== 'number' ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
|
|
365
372
|
}
|
|
366
373
|
},
|
|
367
374
|
pageNavigator: {
|
|
@@ -412,7 +419,7 @@ class BarChart extends BaseChart {
|
|
|
412
419
|
const div = document.createElement('div');
|
|
413
420
|
div.id = xAxisID;
|
|
414
421
|
div.className = 'statistic-chart-axis-label';
|
|
415
|
-
const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
422
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
416
423
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
417
424
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
418
425
|
chartContainer.appendChild(div);
|
|
@@ -430,12 +437,12 @@ class BarChart extends BaseChart {
|
|
|
430
437
|
const div = document.createElement('div');
|
|
431
438
|
div.id = yAxisID;
|
|
432
439
|
div.className = 'statistic-chart-axis-label';
|
|
433
|
-
if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
|
|
434
|
-
div.innerHTML =
|
|
440
|
+
if (y_axis_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
441
|
+
div.innerHTML = _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT);
|
|
435
442
|
} else {
|
|
436
|
-
const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
443
|
+
const column = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
437
444
|
div.innerHTML = column.name || '';
|
|
438
|
-
if (type === STAT_TYPE.BAR_STACK) {
|
|
445
|
+
if (type === _constants.STAT_TYPE.BAR_STACK) {
|
|
439
446
|
div.innerHTML = title_name || '';
|
|
440
447
|
}
|
|
441
448
|
}
|
|
@@ -473,7 +480,7 @@ class BarChart extends BaseChart {
|
|
|
473
480
|
chartCalculator,
|
|
474
481
|
eventBus
|
|
475
482
|
} = this.props;
|
|
476
|
-
this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
|
|
483
|
+
this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
|
|
477
484
|
this.renderAxisLabel(newStatItem);
|
|
478
485
|
});
|
|
479
486
|
if (this.container) {
|
|
@@ -562,7 +569,7 @@ class BarChart extends BaseChart {
|
|
|
562
569
|
show_y_axis_label,
|
|
563
570
|
show_x_axis_label
|
|
564
571
|
} = statItem;
|
|
565
|
-
return /*#__PURE__*/
|
|
572
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/_react.default.createElement("div", {
|
|
566
573
|
ref: ref => this.container = ref,
|
|
567
574
|
style: {
|
|
568
575
|
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
@@ -572,4 +579,4 @@ class BarChart extends BaseChart {
|
|
|
572
579
|
}
|
|
573
580
|
}
|
|
574
581
|
BarChart.propTypes = propTypes;
|
|
575
|
-
|
|
582
|
+
var _default = exports.default = BarChart;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 _dtableStore = require("dtable-store");
|
|
12
|
+
var _components = require("../components");
|
|
13
|
+
var _commonUtils = require("../utils/common-utils");
|
|
14
|
+
var _basicChartUtils = require("../utils/basic-chart-utils");
|
|
15
|
+
var _constants = require("../constants");
|
|
8
16
|
const CHART_STYLE_CONFIG = {
|
|
9
17
|
'g2-tooltip': {
|
|
10
18
|
borderRadius: '2px',
|
|
@@ -15,7 +23,7 @@ const CHART_STYLE_CONFIG = {
|
|
|
15
23
|
marginTop: '5px'
|
|
16
24
|
}
|
|
17
25
|
};
|
|
18
|
-
class BaseChart extends Component {
|
|
26
|
+
class BaseChart extends _react.Component {
|
|
19
27
|
constructor() {
|
|
20
28
|
var _this;
|
|
21
29
|
super(...arguments);
|
|
@@ -35,7 +43,7 @@ class BaseChart extends Component {
|
|
|
35
43
|
statItem: nextStatItem,
|
|
36
44
|
theme: nextTheme
|
|
37
45
|
} = nextProps;
|
|
38
|
-
return !isStatItemEqual(statItem, nextStatItem) || this.needRefresh(preProps, nextProps) || nextTheme !== theme;
|
|
46
|
+
return !(0, _commonUtils.isStatItemEqual)(statItem, nextStatItem) || this.needRefresh(preProps, nextProps) || nextTheme !== theme;
|
|
39
47
|
};
|
|
40
48
|
this.shouldCalculateStatItem = (preProps, nextProps) => {
|
|
41
49
|
const {
|
|
@@ -44,14 +52,14 @@ class BaseChart extends Component {
|
|
|
44
52
|
const {
|
|
45
53
|
statItem: nextStatItem
|
|
46
54
|
} = nextProps;
|
|
47
|
-
return shouldCalculateStatItem(statItem, nextStatItem) || this.needRefresh(preProps, nextProps);
|
|
55
|
+
return (0, _commonUtils.shouldCalculateStatItem)(statItem, nextStatItem) || this.needRefresh(preProps, nextProps);
|
|
48
56
|
};
|
|
49
57
|
this.getTicks = (data, width) => {
|
|
50
58
|
const labelCount = data.length;
|
|
51
59
|
if (Math.floor(width / labelCount) > 20) {
|
|
52
60
|
return [];
|
|
53
61
|
}
|
|
54
|
-
return getChartDisplayLabels(width, 20, data);
|
|
62
|
+
return (0, _basicChartUtils.getChartDisplayLabels)(width, 20, data);
|
|
55
63
|
};
|
|
56
64
|
this.getLabelCount = (ticks, data) => {
|
|
57
65
|
const ticksLen = ticks.length;
|
|
@@ -65,10 +73,10 @@ class BaseChart extends Component {
|
|
|
65
73
|
isEnlarge,
|
|
66
74
|
theme
|
|
67
75
|
} = _this.props;
|
|
68
|
-
if (theme === THEME_NAME_MAP.DARK && !isEnlarge && isPreview) {
|
|
69
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
76
|
+
if (theme === _constants.THEME_NAME_MAP.DARK && !isEnlarge && isPreview) {
|
|
77
|
+
themeColors = _constants.STAT_ITEM_THEME_COLORS.dark;
|
|
70
78
|
}
|
|
71
|
-
return themeColors || STAT_ITEM_THEME_COLORS[THEME_NAME_MAP.LIGHT];
|
|
79
|
+
return themeColors || _constants.STAT_ITEM_THEME_COLORS[_constants.THEME_NAME_MAP.LIGHT];
|
|
72
80
|
};
|
|
73
81
|
this.getAxisLabelColor = textColor => {
|
|
74
82
|
const {
|
|
@@ -76,7 +84,7 @@ class BaseChart extends Component {
|
|
|
76
84
|
isEnlarge,
|
|
77
85
|
theme
|
|
78
86
|
} = this.props;
|
|
79
|
-
if (theme === THEME_NAME_MAP.DARK && !isEnlarge && isPreview) {
|
|
87
|
+
if (theme === _constants.THEME_NAME_MAP.DARK && !isEnlarge && isPreview) {
|
|
80
88
|
return '#ffffff';
|
|
81
89
|
}
|
|
82
90
|
return textColor || '#999999';
|
|
@@ -90,7 +98,7 @@ class BaseChart extends Component {
|
|
|
90
98
|
label = "".concat(name.slice(0, 10), "...");
|
|
91
99
|
}
|
|
92
100
|
if (name === '' || name === 'undefined') {
|
|
93
|
-
label =
|
|
101
|
+
label = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
|
|
94
102
|
}
|
|
95
103
|
return label;
|
|
96
104
|
};
|
|
@@ -101,24 +109,24 @@ class BaseChart extends Component {
|
|
|
101
109
|
const {
|
|
102
110
|
label_font_size
|
|
103
111
|
} = statItem;
|
|
104
|
-
return getLabelFontSize(label_font_size);
|
|
112
|
+
return (0, _commonUtils.getLabelFontSize)(label_font_size);
|
|
105
113
|
};
|
|
106
114
|
this.getNumberDisplayString = (value, columnData, summaryMethod) => {
|
|
107
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
115
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Distinct_values) {
|
|
108
116
|
return value;
|
|
109
117
|
}
|
|
110
|
-
return getNumberDisplayString(value, columnData);
|
|
118
|
+
return (0, _dtableStore.getNumberDisplayString)(value, columnData);
|
|
111
119
|
};
|
|
112
120
|
this.renderLoading = () => {
|
|
113
|
-
return /*#__PURE__*/
|
|
121
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
114
122
|
className: 'statistic-chart-loading-container'
|
|
115
|
-
}, /*#__PURE__*/
|
|
123
|
+
}, /*#__PURE__*/_react.default.createElement(_components.Loading, null));
|
|
116
124
|
};
|
|
117
125
|
this.renderEmpty = () => {
|
|
118
|
-
return /*#__PURE__*/
|
|
126
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
119
127
|
className: 'statistic-chart-text'
|
|
120
|
-
},
|
|
128
|
+
}, _reactIntlUniversal.default.get(_constants.NO_STATISTIC_RESULTS));
|
|
121
129
|
};
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
|
-
|
|
132
|
+
var _default = exports.default = BaseChart;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
+
var _dtableStore = require("dtable-store");
|
|
12
|
+
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
|
+
var _customG = require("../custom-g2");
|
|
14
|
+
var _constants = require("../constants");
|
|
8
15
|
const propTypes = {
|
|
9
|
-
isPreview:
|
|
10
|
-
statItem:
|
|
11
|
-
chartCalculator:
|
|
12
|
-
getTableById:
|
|
16
|
+
isPreview: _propTypes.default.bool,
|
|
17
|
+
statItem: _propTypes.default.object,
|
|
18
|
+
chartCalculator: _propTypes.default.object,
|
|
19
|
+
getTableById: _propTypes.default.func
|
|
13
20
|
};
|
|
14
|
-
class BasicNumericCard extends
|
|
21
|
+
class BasicNumericCard extends _baseChart.default {
|
|
15
22
|
constructor(props) {
|
|
16
23
|
super(props);
|
|
17
24
|
this.componentDidMount = async () => {
|
|
@@ -67,12 +74,12 @@ class BasicNumericCard extends BaseChart {
|
|
|
67
74
|
statItem
|
|
68
75
|
} = this.props;
|
|
69
76
|
if (isPreview) {
|
|
70
|
-
this.chart = new Chart({
|
|
77
|
+
this.chart = new _customG.Chart({
|
|
71
78
|
container: this.container,
|
|
72
79
|
autoFit: true
|
|
73
80
|
});
|
|
74
81
|
} else {
|
|
75
|
-
this.chart = new Chart({
|
|
82
|
+
this.chart = new _customG.Chart({
|
|
76
83
|
container: this.container,
|
|
77
84
|
autoFit: true,
|
|
78
85
|
height: 400,
|
|
@@ -105,13 +112,13 @@ class BasicNumericCard extends BaseChart {
|
|
|
105
112
|
table_id,
|
|
106
113
|
numeric_column
|
|
107
114
|
} = statItem;
|
|
108
|
-
if (summary_method === SUMMARY_METHOD_MAP.Distinct_values) {
|
|
115
|
+
if (summary_method === _constants.SUMMARY_METHOD_MAP.Distinct_values) {
|
|
109
116
|
return data;
|
|
110
117
|
}
|
|
111
|
-
if (!data) return
|
|
118
|
+
if (!data) return _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
|
|
112
119
|
if (summary_method !== 'Row_count') {
|
|
113
120
|
const table = getTableById(table_id);
|
|
114
|
-
const selectedColumn = TableUtils.getTableColumnByKey(table, numeric_column);
|
|
121
|
+
const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, numeric_column);
|
|
115
122
|
const formattedContent = this.getNumberDisplayString(data, selectedColumn.data || {});
|
|
116
123
|
return formattedContent;
|
|
117
124
|
}
|
|
@@ -184,11 +191,11 @@ class BasicNumericCard extends BaseChart {
|
|
|
184
191
|
const {
|
|
185
192
|
isCalculatingData
|
|
186
193
|
} = this.state;
|
|
187
|
-
return /*#__PURE__*/
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
|
|
188
195
|
ref: ref => this.container = ref,
|
|
189
196
|
className: "statistic-chart-container statistic-number-card"
|
|
190
197
|
}));
|
|
191
198
|
}
|
|
192
199
|
}
|
|
193
200
|
BasicNumericCard.propTypes = propTypes;
|
|
194
|
-
|
|
201
|
+
var _default = exports.default = BasicNumericCard;
|