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