dtable-statistic 4.3.6 → 4.3.8
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/calculator/base-calculator.js +16 -5
- package/es/calculator/basic-chart-calculator.js +17 -31
- package/es/calculator/combination-calculator.js +20 -34
- package/es/calculator/compare-bar-calculator.js +9 -20
- package/es/calculator/completeness-calculator.js +10 -24
- package/es/calculator/dashboard-calculator.js +6 -20
- package/es/calculator/heat-map-calculator.js +6 -20
- package/es/calculator/horizontal-bar-calculator.js +2 -13
- package/es/calculator/index.js +2 -0
- package/es/calculator/map-calculator.js +7 -21
- package/es/calculator/mirror-calculator.js +8 -22
- package/es/calculator/number-card-calculator.js +4 -18
- package/es/calculator/pivot-table-calculator.js +40 -54
- package/es/calculator/scatter-calculator.js +6 -20
- package/es/calculator/thread-manager.js +41 -41
- package/es/calculator/trend-calculator.js +6 -20
- package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
- package/es/calculator/workers/calculator.worker.js +5 -2
- package/es/calculator/workers/card-calculator-worker.js +13 -9
- package/es/calculator/workers/combination-calculator-worker.js +20 -16
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
- package/es/calculator/workers/completeness-calculator-worker.js +21 -17
- package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
- package/es/calculator/workers/mirror-calculator-worker.js +14 -10
- package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
- package/es/calculator/workers/scatter-calculator-worker.js +15 -11
- package/es/calculator/workers/trend-calculator-worker.js +14 -10
- package/es/calculator/world-map-calculator.js +6 -20
- package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
- package/es/components/dialog/statistic-record-dialog/index.js +21 -11
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
- package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
- package/es/components/popover/color-rules-popover.js +2 -2
- package/es/components/select/select.js +3 -3
- package/es/components/toast/alert.js +2 -0
- package/es/components/toast/toastManager.js +1 -0
- package/es/constants/color-rules.js +3 -3
- package/es/constants/index.js +9 -9
- package/es/dashboard.js +7 -13
- package/es/desktop-dashboard.js +1 -1
- package/es/locale/lang/de.js +10 -10
- package/es/locale/lang/en.js +8 -8
- package/es/locale/lang/fr.js +10 -10
- package/es/locale/lang/zh_CN.js +8 -8
- package/es/model/basic-number-card.js +3 -3
- package/es/model/compare-bar.js +2 -2
- package/es/model/generic-model.js +11 -11
- package/es/model/heat-map.js +2 -2
- package/es/model/horizontal-bar.js +2 -2
- package/es/model/index.js +3 -2
- package/es/model/map.js +3 -3
- package/es/model/mirror.js +2 -2
- package/es/model/trend.js +2 -2
- package/es/model/world-map.js +3 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +4 -18
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +1 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
- package/es/stat-view/area-chart.js +4 -4
- package/es/stat-view/bar-chart.js +4 -4
- package/es/stat-view/base-chart.js +2 -2
- package/es/stat-view/basic-number-card.js +49 -49
- package/es/stat-view/combination-chart.js +69 -69
- package/es/stat-view/compare-chart.js +4 -4
- package/es/stat-view/completeness-chart.js +3 -3
- package/es/stat-view/custom-bar.js +2 -2
- package/es/stat-view/dashboard-chart.js +50 -50
- package/es/stat-view/heat-map.js +2 -2
- package/es/stat-view/horizontal-bar-chart.js +4 -4
- package/es/stat-view/line-chart.js +4 -4
- package/es/stat-view/map.js +3 -3
- package/es/stat-view/mirror.js +2 -2
- package/es/stat-view/pivot-table/index.js +6 -6
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
- package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
- package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
- package/es/stat-view/ring-chart.js +2 -2
- package/es/stat-view/scatter-chart.js +56 -56
- package/es/stat-view/treemap-chart.js +50 -49
- package/es/stat-view/trend-chart.js +52 -52
- package/es/stat-view/world-map.js +3 -3
- package/es/utils/cell-format.js +16 -16
- package/es/utils/cell-value.js +3 -3
- package/es/utils/color-utils.js +3 -3
- package/es/utils/column-utils.js +10 -10
- package/es/utils/column.js +2 -2
- package/es/utils/common-utils.js +10 -8
- package/es/utils/export-table-utils.js +38 -38
- package/es/utils/object.js +3 -3
- package/es/utils/pivot-table.js +3 -3
- package/es/utils/row-utils.js +17 -17
- package/es/utils/search.js +14 -14
- package/es/utils/sql-utils.js +23 -20
- package/es/utils/stat-utils.js +52 -52
- package/es/utils/trend-utils.js +1 -0
- package/package.json +6 -3
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _constants = require("../constants");
|
|
@@ -21,53 +21,6 @@ const propTypes = {
|
|
|
21
21
|
class BasicNumericCard extends _baseChart.default {
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props);
|
|
24
|
-
this.componentDidMount = async () => {
|
|
25
|
-
const {
|
|
26
|
-
statItem,
|
|
27
|
-
chartCalculator
|
|
28
|
-
} = this.props;
|
|
29
|
-
if (this.container) {
|
|
30
|
-
const data = await chartCalculator.calculate(statItem);
|
|
31
|
-
this.setState({
|
|
32
|
-
isCalculatingData: false
|
|
33
|
-
});
|
|
34
|
-
this.drawChart(data);
|
|
35
|
-
this.calculateData = data;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
this.componentDidUpdate = async (preProps, preState) => {
|
|
39
|
-
const {
|
|
40
|
-
statItem,
|
|
41
|
-
chartCalculator
|
|
42
|
-
} = this.props;
|
|
43
|
-
const {
|
|
44
|
-
isCalculatingData
|
|
45
|
-
} = this.state;
|
|
46
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
47
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
48
|
-
this.setState({
|
|
49
|
-
isCalculatingData: true
|
|
50
|
-
});
|
|
51
|
-
if (this.container) {
|
|
52
|
-
const data = await chartCalculator.calculate(statItem);
|
|
53
|
-
this.calculateData = data;
|
|
54
|
-
this.setState({
|
|
55
|
-
isCalculatingData: false
|
|
56
|
-
});
|
|
57
|
-
this.chart && this.chart.destroy();
|
|
58
|
-
this.drawChart(data);
|
|
59
|
-
if (this.props.isPreview) {
|
|
60
|
-
this.chart.forceFit();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
this.chart && this.chart.destroy();
|
|
65
|
-
this.drawChart(this.calculateData);
|
|
66
|
-
if (this.props.isPreview) {
|
|
67
|
-
this.chart.forceFit();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
24
|
this.drawChart = data => {
|
|
72
25
|
const {
|
|
73
26
|
isPreview,
|
|
@@ -118,7 +71,7 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
118
71
|
if (!data) return _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
|
|
119
72
|
if (summary_method !== 'Row_count') {
|
|
120
73
|
const table = getTableById(table_id);
|
|
121
|
-
const selectedColumn =
|
|
74
|
+
const selectedColumn = (0, _dtableUtils.getTableColumnByKey)(table, numeric_column);
|
|
122
75
|
const formattedContent = this.getNumberDisplayString(data, selectedColumn.data || {});
|
|
123
76
|
return formattedContent;
|
|
124
77
|
}
|
|
@@ -175,6 +128,20 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
175
128
|
};
|
|
176
129
|
this.calculateData = null;
|
|
177
130
|
}
|
|
131
|
+
async componentDidMount() {
|
|
132
|
+
const {
|
|
133
|
+
statItem,
|
|
134
|
+
chartCalculator
|
|
135
|
+
} = this.props;
|
|
136
|
+
if (this.container) {
|
|
137
|
+
const data = await chartCalculator.calculate(statItem);
|
|
138
|
+
this.setState({
|
|
139
|
+
isCalculatingData: false
|
|
140
|
+
});
|
|
141
|
+
this.drawChart(data);
|
|
142
|
+
this.calculateData = data;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
178
145
|
shouldComponentUpdate(nextProps, nextState) {
|
|
179
146
|
if (this.canUpdate(this.props, nextProps)) {
|
|
180
147
|
return true;
|
|
@@ -184,6 +151,39 @@ class BasicNumericCard extends _baseChart.default {
|
|
|
184
151
|
}
|
|
185
152
|
return false;
|
|
186
153
|
}
|
|
154
|
+
async componentDidUpdate(preProps, preState) {
|
|
155
|
+
const {
|
|
156
|
+
statItem,
|
|
157
|
+
chartCalculator
|
|
158
|
+
} = this.props;
|
|
159
|
+
const {
|
|
160
|
+
isCalculatingData
|
|
161
|
+
} = this.state;
|
|
162
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
163
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
164
|
+
this.setState({
|
|
165
|
+
isCalculatingData: true
|
|
166
|
+
});
|
|
167
|
+
if (this.container) {
|
|
168
|
+
const data = await chartCalculator.calculate(statItem);
|
|
169
|
+
this.calculateData = data;
|
|
170
|
+
this.setState({
|
|
171
|
+
isCalculatingData: false
|
|
172
|
+
});
|
|
173
|
+
this.chart && this.chart.destroy();
|
|
174
|
+
this.drawChart(data);
|
|
175
|
+
if (this.props.isPreview) {
|
|
176
|
+
this.chart.forceFit();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
this.chart && this.chart.destroy();
|
|
181
|
+
this.drawChart(this.calculateData);
|
|
182
|
+
if (this.props.isPreview) {
|
|
183
|
+
this.chart.forceFit();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
187
|
componentWillUnmount() {
|
|
188
188
|
this.container = null;
|
|
189
189
|
}
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -27,66 +27,6 @@ const propTypes = {
|
|
|
27
27
|
class CombinationChart extends _baseChart.default {
|
|
28
28
|
constructor(props) {
|
|
29
29
|
super(props);
|
|
30
|
-
this.componentDidMount = async () => {
|
|
31
|
-
const {
|
|
32
|
-
statItem,
|
|
33
|
-
chartCalculator,
|
|
34
|
-
eventBus
|
|
35
|
-
} = this.props;
|
|
36
|
-
this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
|
|
37
|
-
this.renderAxisLabel(newStatItem);
|
|
38
|
-
});
|
|
39
|
-
if (!this.container) return;
|
|
40
|
-
const data = await chartCalculator.calculate(statItem);
|
|
41
|
-
let showResultDescription = data.length > 0 ? false : true;
|
|
42
|
-
this.setState({
|
|
43
|
-
isCalculatingData: false,
|
|
44
|
-
showResultDescription
|
|
45
|
-
}, () => {
|
|
46
|
-
if (!showResultDescription) {
|
|
47
|
-
this.drawChart(data);
|
|
48
|
-
this.calculateData = data;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
this.componentDidUpdate = async (preProps, preState) => {
|
|
53
|
-
const {
|
|
54
|
-
statItem,
|
|
55
|
-
chartCalculator
|
|
56
|
-
} = this.props;
|
|
57
|
-
const {
|
|
58
|
-
isCalculatingData
|
|
59
|
-
} = this.state;
|
|
60
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
61
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
62
|
-
this.setState({
|
|
63
|
-
isCalculatingData: true
|
|
64
|
-
});
|
|
65
|
-
if (this.container) {
|
|
66
|
-
const data = await chartCalculator.calculate(statItem);
|
|
67
|
-
const showResultDescription = data.length > 0 ? false : true;
|
|
68
|
-
this.chart && this.destroyChart();
|
|
69
|
-
this.calculateData = data;
|
|
70
|
-
this.setState({
|
|
71
|
-
isCalculatingData: false,
|
|
72
|
-
showResultDescription
|
|
73
|
-
}, () => {
|
|
74
|
-
if (!showResultDescription) {
|
|
75
|
-
this.drawChart(data);
|
|
76
|
-
if (this.props.isPreview) this.chart.forceFit();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
if (!this.state.showResultDescription) {
|
|
82
|
-
this.chart && this.destroyChart();
|
|
83
|
-
this.drawChart(this.calculateData);
|
|
84
|
-
if (this.props.isPreview) {
|
|
85
|
-
this.chart.forceFit();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
30
|
this.renderAxisLabel = newStatItem => {
|
|
91
31
|
let {
|
|
92
32
|
getTableById,
|
|
@@ -121,7 +61,7 @@ class CombinationChart extends _baseChart.default {
|
|
|
121
61
|
const div = document.createElement('div');
|
|
122
62
|
div.id = xAxisID;
|
|
123
63
|
div.className = 'statistic-chart-axis-label';
|
|
124
|
-
const column =
|
|
64
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
125
65
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
126
66
|
div.setAttribute('style', "color:".concat(themeColors.textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
127
67
|
chartContainer.appendChild(div);
|
|
@@ -138,7 +78,7 @@ class CombinationChart extends _baseChart.default {
|
|
|
138
78
|
const div = document.createElement('div');
|
|
139
79
|
div.id = yAxisLeftID;
|
|
140
80
|
div.className = 'statistic-chart-axis-label';
|
|
141
|
-
const yAxisColumn =
|
|
81
|
+
const yAxisColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column);
|
|
142
82
|
const labeContent = yAxisColumn ? _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW[y_axis_left_summary_method]) : _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW.count);
|
|
143
83
|
div.innerHTML = labeContent;
|
|
144
84
|
const containerHeight = chartContainer.offsetHeight;
|
|
@@ -164,7 +104,7 @@ class CombinationChart extends _baseChart.default {
|
|
|
164
104
|
const div = document.createElement('div');
|
|
165
105
|
div.id = yAxisRightID;
|
|
166
106
|
div.className = 'statistic-chart-axis-label';
|
|
167
|
-
const yAxisColumn =
|
|
107
|
+
const yAxisColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column);
|
|
168
108
|
const labeContent = yAxisColumn ? _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW[y_axis_right_summary_method]) : _reactIntlUniversal.default.get(_constants.STATISTICS_COUNT_SHOW.count);
|
|
169
109
|
div.innerHTML = labeContent;
|
|
170
110
|
const containerHeight = chartContainer.offsetHeight;
|
|
@@ -205,8 +145,8 @@ class CombinationChart extends _baseChart.default {
|
|
|
205
145
|
}
|
|
206
146
|
});
|
|
207
147
|
const table = getTableById(table_id);
|
|
208
|
-
const leftColumn =
|
|
209
|
-
const rightColumn =
|
|
148
|
+
const leftColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
|
|
149
|
+
const rightColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
|
|
210
150
|
this.handleAutoRange(leftColumn, rightColumn);
|
|
211
151
|
const themeColors = this.getThemeColors();
|
|
212
152
|
const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
|
|
@@ -422,8 +362,8 @@ class CombinationChart extends _baseChart.default {
|
|
|
422
362
|
y_axis_left_group_by_numeric_columns
|
|
423
363
|
} = statItem;
|
|
424
364
|
const legendItems = [];
|
|
425
|
-
const column1 =
|
|
426
|
-
const column2 =
|
|
365
|
+
const column1 = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
|
|
366
|
+
const column2 = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
|
|
427
367
|
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
428
368
|
legendItems.push({
|
|
429
369
|
value: 'value_left',
|
|
@@ -460,7 +400,7 @@ class CombinationChart extends _baseChart.default {
|
|
|
460
400
|
}
|
|
461
401
|
});
|
|
462
402
|
y_axis_left_group_by_numeric_columns.forEach((item, index) => {
|
|
463
|
-
const column =
|
|
403
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, item.column_key) || {};
|
|
464
404
|
legendItems.push({
|
|
465
405
|
value: 'group_name',
|
|
466
406
|
name: column.name || _reactIntlUniversal.default.get(_constants.LEGEND_LEFT),
|
|
@@ -498,6 +438,28 @@ class CombinationChart extends _baseChart.default {
|
|
|
498
438
|
};
|
|
499
439
|
this.calculateData = null;
|
|
500
440
|
}
|
|
441
|
+
async componentDidMount() {
|
|
442
|
+
const {
|
|
443
|
+
statItem,
|
|
444
|
+
chartCalculator,
|
|
445
|
+
eventBus
|
|
446
|
+
} = this.props;
|
|
447
|
+
this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
|
|
448
|
+
this.renderAxisLabel(newStatItem);
|
|
449
|
+
});
|
|
450
|
+
if (!this.container) return;
|
|
451
|
+
const data = await chartCalculator.calculate(statItem);
|
|
452
|
+
let showResultDescription = data.length > 0 ? false : true;
|
|
453
|
+
this.setState({
|
|
454
|
+
isCalculatingData: false,
|
|
455
|
+
showResultDescription
|
|
456
|
+
}, () => {
|
|
457
|
+
if (!showResultDescription) {
|
|
458
|
+
this.drawChart(data);
|
|
459
|
+
this.calculateData = data;
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
501
463
|
shouldComponentUpdate(nextProps, nextState) {
|
|
502
464
|
const {
|
|
503
465
|
theme,
|
|
@@ -517,6 +479,44 @@ class CombinationChart extends _baseChart.default {
|
|
|
517
479
|
}
|
|
518
480
|
return false;
|
|
519
481
|
}
|
|
482
|
+
async componentDidUpdate(preProps, preState) {
|
|
483
|
+
const {
|
|
484
|
+
statItem,
|
|
485
|
+
chartCalculator
|
|
486
|
+
} = this.props;
|
|
487
|
+
const {
|
|
488
|
+
isCalculatingData
|
|
489
|
+
} = this.state;
|
|
490
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
491
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
492
|
+
this.setState({
|
|
493
|
+
isCalculatingData: true
|
|
494
|
+
});
|
|
495
|
+
if (this.container) {
|
|
496
|
+
const data = await chartCalculator.calculate(statItem);
|
|
497
|
+
const showResultDescription = data.length > 0 ? false : true;
|
|
498
|
+
this.chart && this.destroyChart();
|
|
499
|
+
this.calculateData = data;
|
|
500
|
+
this.setState({
|
|
501
|
+
isCalculatingData: false,
|
|
502
|
+
showResultDescription
|
|
503
|
+
}, () => {
|
|
504
|
+
if (!showResultDescription) {
|
|
505
|
+
this.drawChart(data);
|
|
506
|
+
if (this.props.isPreview) this.chart.forceFit();
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
} else {
|
|
511
|
+
if (!this.state.showResultDescription) {
|
|
512
|
+
this.chart && this.destroyChart();
|
|
513
|
+
this.drawChart(this.calculateData);
|
|
514
|
+
if (this.props.isPreview) {
|
|
515
|
+
this.chart.forceFit();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
520
|
componentWillUnmount() {
|
|
521
521
|
this.container = null;
|
|
522
522
|
this.unsubscribeStyleChange();
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -46,7 +46,7 @@ class CompareChart extends _baseChart.default {
|
|
|
46
46
|
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
47
47
|
if (y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
48
48
|
const table = getTableById(table_id);
|
|
49
|
-
const summaryColumn =
|
|
49
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
|
|
50
50
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
51
51
|
}
|
|
52
52
|
this.chart.data(data, {
|
|
@@ -322,7 +322,7 @@ class CompareChart extends _baseChart.default {
|
|
|
322
322
|
const div = document.createElement('div');
|
|
323
323
|
div.id = xAxisID;
|
|
324
324
|
div.className = 'statistic-chart-axis-label';
|
|
325
|
-
const column =
|
|
325
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
326
326
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
327
327
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
328
328
|
chartContainer.appendChild(div);
|
|
@@ -343,7 +343,7 @@ class CompareChart extends _baseChart.default {
|
|
|
343
343
|
if (y_axis_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
344
344
|
div.innerHTML = _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT);
|
|
345
345
|
} else {
|
|
346
|
-
const column =
|
|
346
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
|
|
347
347
|
div.innerHTML = column.name || '';
|
|
348
348
|
}
|
|
349
349
|
const containerHeight = chartContainer.offsetHeight;
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -61,8 +61,8 @@ class CompletenessChart extends _baseChart.default {
|
|
|
61
61
|
const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
|
|
62
62
|
this.initChartHandler();
|
|
63
63
|
const selectedTable = getTableById(table_id);
|
|
64
|
-
const completedColumn =
|
|
65
|
-
const targetColumn =
|
|
64
|
+
const completedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, completed_column);
|
|
65
|
+
const targetColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, target_column);
|
|
66
66
|
|
|
67
67
|
// 数据颜色映射value设置当前主题色
|
|
68
68
|
if (isGroupChart) {
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _dataSet = _interopRequireDefault(require("@antv/data-set"));
|
|
11
11
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
12
|
-
var
|
|
12
|
+
var _dtableUtils = require("dtable-utils");
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
15
15
|
var _basicChartUtils = require("../utils/basic-chart-utils");
|
|
@@ -258,7 +258,7 @@ class CustomBar extends _baseChart.default {
|
|
|
258
258
|
const div = document.createElement('div');
|
|
259
259
|
div.id = xAxisID;
|
|
260
260
|
div.className = 'statistic-chart-axis-label';
|
|
261
|
-
const column =
|
|
261
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
262
262
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
263
263
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
264
264
|
chartContainer.appendChild(div);
|
|
@@ -20,56 +20,6 @@ const HEIGHT = 400;
|
|
|
20
20
|
class DashboardChart extends _baseChart.default {
|
|
21
21
|
constructor(props) {
|
|
22
22
|
super(props);
|
|
23
|
-
this.componentDidMount = async () => {
|
|
24
|
-
const {
|
|
25
|
-
statItem,
|
|
26
|
-
chartCalculator
|
|
27
|
-
} = this.props;
|
|
28
|
-
if (this.container) {
|
|
29
|
-
const data = await chartCalculator.calculate(statItem);
|
|
30
|
-
this.setState({
|
|
31
|
-
isCalculatingData: false
|
|
32
|
-
});
|
|
33
|
-
this.drawChart(data);
|
|
34
|
-
this.calculateData = data;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this.componentDidUpdate = async (preProps, preState) => {
|
|
38
|
-
const {
|
|
39
|
-
statItem,
|
|
40
|
-
chartCalculator
|
|
41
|
-
} = this.props;
|
|
42
|
-
const {
|
|
43
|
-
isCalculatingData
|
|
44
|
-
} = this.state;
|
|
45
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
46
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
47
|
-
this.setState({
|
|
48
|
-
isCalculatingData: true
|
|
49
|
-
});
|
|
50
|
-
if (this.container) {
|
|
51
|
-
const data = await chartCalculator.calculate(statItem);
|
|
52
|
-
if (!this.container) return;
|
|
53
|
-
this.calculateData = data;
|
|
54
|
-
this.setState({
|
|
55
|
-
isCalculatingData: false
|
|
56
|
-
});
|
|
57
|
-
this.chart && this.chart.destroy();
|
|
58
|
-
this.drawChart(data);
|
|
59
|
-
if (this.props.isPreview) {
|
|
60
|
-
const canvasSize = this.getCanvasSize();
|
|
61
|
-
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
this.chart && this.chart.destroy();
|
|
66
|
-
this.drawChart(this.calculateData);
|
|
67
|
-
if (this.props.isPreview) {
|
|
68
|
-
const canvasSize = this.getCanvasSize();
|
|
69
|
-
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
23
|
this.getCanvasSize = () => {
|
|
74
24
|
const maxWidth = this.container.clientWidth;
|
|
75
25
|
const maxHeight = this.container.clientHeight;
|
|
@@ -243,6 +193,20 @@ class DashboardChart extends _baseChart.default {
|
|
|
243
193
|
};
|
|
244
194
|
this.calculateData = null;
|
|
245
195
|
}
|
|
196
|
+
async componentDidMount() {
|
|
197
|
+
const {
|
|
198
|
+
statItem,
|
|
199
|
+
chartCalculator
|
|
200
|
+
} = this.props;
|
|
201
|
+
if (this.container) {
|
|
202
|
+
const data = await chartCalculator.calculate(statItem);
|
|
203
|
+
this.setState({
|
|
204
|
+
isCalculatingData: false
|
|
205
|
+
});
|
|
206
|
+
this.drawChart(data);
|
|
207
|
+
this.calculateData = data;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
246
210
|
shouldComponentUpdate(nextProps, nextState) {
|
|
247
211
|
if (this.canUpdate(this.props, nextProps)) {
|
|
248
212
|
return true;
|
|
@@ -252,6 +216,42 @@ class DashboardChart extends _baseChart.default {
|
|
|
252
216
|
}
|
|
253
217
|
return false;
|
|
254
218
|
}
|
|
219
|
+
async componentDidUpdate(preProps, preState) {
|
|
220
|
+
const {
|
|
221
|
+
statItem,
|
|
222
|
+
chartCalculator
|
|
223
|
+
} = this.props;
|
|
224
|
+
const {
|
|
225
|
+
isCalculatingData
|
|
226
|
+
} = this.state;
|
|
227
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
228
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
229
|
+
this.setState({
|
|
230
|
+
isCalculatingData: true
|
|
231
|
+
});
|
|
232
|
+
if (this.container) {
|
|
233
|
+
const data = await chartCalculator.calculate(statItem);
|
|
234
|
+
if (!this.container) return;
|
|
235
|
+
this.calculateData = data;
|
|
236
|
+
this.setState({
|
|
237
|
+
isCalculatingData: false
|
|
238
|
+
});
|
|
239
|
+
this.chart && this.chart.destroy();
|
|
240
|
+
this.drawChart(data);
|
|
241
|
+
if (this.props.isPreview) {
|
|
242
|
+
const canvasSize = this.getCanvasSize();
|
|
243
|
+
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
this.chart && this.chart.destroy();
|
|
248
|
+
this.drawChart(this.calculateData);
|
|
249
|
+
if (this.props.isPreview) {
|
|
250
|
+
const canvasSize = this.getCanvasSize();
|
|
251
|
+
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
255
|
render() {
|
|
256
256
|
const {
|
|
257
257
|
isCalculatingData
|
package/es/stat-view/heat-map.js
CHANGED
|
@@ -10,7 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
11
|
var _weekOfYear = _interopRequireDefault(require("dayjs/plugin/weekOfYear"));
|
|
12
12
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
13
|
-
var
|
|
13
|
+
var _dtableUtils = require("dtable-utils");
|
|
14
14
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
15
15
|
var _customG = require("../custom-g2");
|
|
16
16
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -141,7 +141,7 @@ class HeatMap extends _baseChart.default {
|
|
|
141
141
|
} = statItem;
|
|
142
142
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
143
143
|
const table = getTableById(table_id);
|
|
144
|
-
const summaryColumn =
|
|
144
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
145
145
|
columnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
146
146
|
}
|
|
147
147
|
this.chart.facet('list', {
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _dataSet = _interopRequireDefault(require("@antv/data-set"));
|
|
11
11
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
12
|
-
var
|
|
12
|
+
var _dtableUtils = require("dtable-utils");
|
|
13
13
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
14
14
|
var _customG = require("../custom-g2");
|
|
15
15
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -64,7 +64,7 @@ class HorizontalBarChart extends _baseChart.default {
|
|
|
64
64
|
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
65
65
|
if (horizontal_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
66
66
|
const table = getTableById(table_id);
|
|
67
|
-
const summaryColumn =
|
|
67
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, horizontal_axis_column_key) || {};
|
|
68
68
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
69
69
|
}
|
|
70
70
|
if (isGroup) {
|
|
@@ -406,7 +406,7 @@ class HorizontalBarChart extends _baseChart.default {
|
|
|
406
406
|
if (horizontal_axis_summary_type === 'count') {
|
|
407
407
|
div.innerHTML = _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT);
|
|
408
408
|
} else {
|
|
409
|
-
const column =
|
|
409
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, horizontal_axis_column_key) || {};
|
|
410
410
|
div.innerHTML = column.name || '';
|
|
411
411
|
}
|
|
412
412
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(horizontal_axis_label_position, "; bottom: -20px"));
|
|
@@ -424,7 +424,7 @@ class HorizontalBarChart extends _baseChart.default {
|
|
|
424
424
|
const div = document.createElement('div');
|
|
425
425
|
div.id = verticalAxisID;
|
|
426
426
|
div.className = 'statistic-chart-axis-label';
|
|
427
|
-
const column =
|
|
427
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, vertical_axis_column_key);
|
|
428
428
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
429
429
|
if (type === _constants.STAT_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
430
430
|
div.innerHTML = title_name;
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _commonUtils = require("../utils/common-utils");
|
|
@@ -60,7 +60,7 @@ class LineChart extends _baseChart.default {
|
|
|
60
60
|
}
|
|
61
61
|
if (y_axis_summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
62
62
|
const table = getTableById(table_id);
|
|
63
|
-
const summaryColumn =
|
|
63
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
|
|
64
64
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
65
65
|
}
|
|
66
66
|
const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
|
|
@@ -358,7 +358,7 @@ class LineChart extends _baseChart.default {
|
|
|
358
358
|
const div = document.createElement('div');
|
|
359
359
|
div.id = xAxisID;
|
|
360
360
|
div.className = 'statistic-chart-axis-label';
|
|
361
|
-
const column =
|
|
361
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
362
362
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
363
363
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
364
364
|
chartContainer.appendChild(div);
|
|
@@ -379,7 +379,7 @@ class LineChart extends _baseChart.default {
|
|
|
379
379
|
if (y_axis_summary_type === _constants.SUMMARY_TYPE.COUNT) {
|
|
380
380
|
div.innerHTML = _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT);
|
|
381
381
|
} else {
|
|
382
|
-
const column =
|
|
382
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
|
|
383
383
|
div.innerHTML = column.name || '';
|
|
384
384
|
}
|
|
385
385
|
const containerHeight = chartContainer.offsetHeight;
|
package/es/stat-view/map.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _index = _interopRequireDefault(require("@antv/data-set/lib/index"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _constants = require("../constants");
|
|
@@ -104,7 +104,7 @@ class Map extends _baseChart.default {
|
|
|
104
104
|
let columnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
105
105
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
106
106
|
const table = getTableById(table_id);
|
|
107
|
-
const summaryColumn =
|
|
107
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
108
108
|
columnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
109
109
|
}
|
|
110
110
|
this.statisticView = this.chart.createView();
|
|
@@ -196,7 +196,7 @@ class Map extends _baseChart.default {
|
|
|
196
196
|
let columnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
197
197
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
198
198
|
const table = getTableById(table_id);
|
|
199
|
-
const summaryColumn =
|
|
199
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
200
200
|
columnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
201
201
|
}
|
|
202
202
|
this.statisticView = this.chart.createView();
|
package/es/stat-view/mirror.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var
|
|
11
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
12
|
var _baseChart = _interopRequireDefault(require("./base-chart"));
|
|
13
13
|
var _customG = require("../custom-g2");
|
|
14
14
|
var _constants = require("../constants");
|
|
@@ -42,7 +42,7 @@ class Mirror extends _baseChart.default {
|
|
|
42
42
|
let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
43
43
|
if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
|
|
44
44
|
const table = getTableById(table_id);
|
|
45
|
-
const summaryColumn =
|
|
45
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column) || {};
|
|
46
46
|
summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
47
47
|
}
|
|
48
48
|
this.chart.data(data);
|