dtable-statistic 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/dtable-db-api.js +31 -37
- package/es/calculator/base-calculator.js +49 -99
- package/es/calculator/basic-chart-calculator.js +335 -559
- package/es/calculator/combination-calculator.js +231 -299
- package/es/calculator/compare-bar-calculator.js +184 -281
- package/es/calculator/completeness-calculator.js +203 -288
- package/es/calculator/copy-value.js +18 -18
- package/es/calculator/dashboard-calculator.js +68 -137
- package/es/calculator/heat-map-calculator.js +139 -220
- package/es/calculator/horizontal-bar-calculator.js +64 -93
- package/es/calculator/index.js +53 -69
- package/es/calculator/map-calculator.js +98 -174
- package/es/calculator/mirror-calculator.js +137 -216
- package/es/calculator/number-card-calculator.js +58 -126
- package/es/calculator/pivot-table-calculator.js +750 -792
- package/es/calculator/scatter-calculator.js +72 -140
- package/es/calculator/thread-manager.js +48 -67
- package/es/calculator/trend-calculator.js +107 -191
- package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
- package/es/calculator/workers/calculator.worker.js +22 -6
- package/es/calculator/workers/card-calculator-worker.js +16 -14
- package/es/calculator/workers/combination-calculator-worker.js +128 -135
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
- package/es/calculator/workers/completeness-calculator-worker.js +56 -49
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
- package/es/calculator/workers/mirror-calculator-worker.js +52 -52
- package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
- package/es/calculator/workers/scatter-calculator-worker.js +34 -32
- package/es/calculator/workers/trend-calculator-worker.js +33 -29
- package/es/calculator/world-map-calculator.js +120 -197
- package/es/components/common-add-tool.js +7 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
- package/es/components/dialog/color-theme-dialog.js +34 -47
- package/es/components/dialog/delete-confirmation-dialog.js +7 -5
- package/es/components/dialog/enlarged-chart-dialog.js +68 -81
- package/es/components/dialog/new-table-dialog.js +62 -80
- package/es/components/dialog/new-view-dialog.js +50 -62
- package/es/components/dialog/rename-view-dialog.js +49 -58
- package/es/components/dialog/statistic-record-dialog/index.js +233 -231
- package/es/components/dialog/statistic-types-dialog/index.js +40 -49
- package/es/components/dialog/table-select-dialog.js +61 -70
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
- package/es/components/dtable-popover.js +62 -81
- package/es/components/dtable-search-input.js +89 -99
- package/es/components/dtable-select.js +55 -74
- package/es/components/icon.js +5 -3
- package/es/components/loading.js +1 -1
- package/es/components/modal-portal.js +15 -32
- package/es/components/popover/color-rules/color-rule.js +137 -141
- package/es/components/popover/color-rules/index.js +58 -66
- package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
- package/es/components/popover/color-rules/rule-filters/index.js +50 -58
- package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
- package/es/components/popover/color-rules-popover.js +117 -121
- package/es/components/popover/color-selector-popover.js +60 -70
- package/es/components/seatable-radio/index.js +2 -2
- package/es/components/select/option-group.js +139 -157
- package/es/components/select/option.js +26 -40
- package/es/components/select/select.js +97 -112
- package/es/components/toast/alert.js +65 -80
- package/es/components/toast/index.js +1 -1
- package/es/components/toast/toast.js +76 -103
- package/es/components/toast/toastManager.js +57 -93
- package/es/components/toast/toaster.js +58 -56
- package/es/constants/color-rules.js +8 -5
- package/es/constants/dtable-select-style.js +44 -48
- package/es/constants/event-types.js +4 -4
- package/es/constants/index.js +328 -242
- package/es/constants/map.js +2 -2
- package/es/constants/model.js +20 -20
- package/es/constants/regions.js +1 -1
- package/es/constants/zIndexes.js +1 -1
- package/es/custom-g2.js +11 -11
- package/es/dashboard.js +343 -333
- package/es/desktop-dashboard.js +217 -224
- package/es/index.js +45 -58
- package/es/locale/index.js +3 -3
- package/es/locale/lang/de.js +1 -1
- package/es/locale/lang/en.js +7 -7
- package/es/locale/lang/fr.js +1 -1
- package/es/locale/lang/zh_CN.js +1 -1
- package/es/mobile-dashboard.js +76 -89
- package/es/model/bar-group.js +34 -44
- package/es/model/bar.js +26 -36
- package/es/model/base-model.js +11 -12
- package/es/model/basic-number-card.js +10 -20
- package/es/model/collaborators.js +10 -11
- package/es/model/combination.js +32 -42
- package/es/model/compare-bar.js +30 -40
- package/es/model/completeness-group.js +19 -29
- package/es/model/completeness.js +14 -24
- package/es/model/custom-bar.js +14 -24
- package/es/model/dashboard.js +9 -19
- package/es/model/generic-model.js +187 -197
- package/es/model/heat-map.js +16 -26
- package/es/model/horizontal-bar-group.js +32 -42
- package/es/model/horizontal-bar.js +26 -36
- package/es/model/index.js +31 -3
- package/es/model/map.js +20 -30
- package/es/model/mirror.js +15 -25
- package/es/model/pie.js +21 -31
- package/es/model/ring.js +23 -33
- package/es/model/scatter.js +11 -21
- package/es/model/statistic-dashboard.js +7 -8
- package/es/model/table.js +19 -29
- package/es/model/trend.js +15 -25
- package/es/model/world-map.js +17 -27
- package/es/service/chart-service.js +69 -65
- package/es/service/dashboard-service.js +421 -419
- package/es/service/map-json.js +112 -132
- package/es/stat-editor/chart-name-editor.js +44 -58
- package/es/stat-editor/index.js +59 -70
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
- package/es/stat-editor/stat-settings/map/map-level.js +31 -43
- package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
- package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
- package/es/stat-list/chart-preview.js +85 -98
- package/es/stat-list/index.js +170 -178
- package/es/stat-view/area-chart.js +282 -274
- package/es/stat-view/bar-chart.js +300 -292
- package/es/stat-view/base-chart.js +58 -52
- package/es/stat-view/basic-number-card.js +115 -168
- package/es/stat-view/combination-chart.js +298 -334
- package/es/stat-view/compare-chart.js +256 -254
- package/es/stat-view/completeness-chart.js +194 -206
- package/es/stat-view/custom-bar.js +221 -223
- package/es/stat-view/dashboard-chart.js +122 -180
- package/es/stat-view/heat-map.js +268 -294
- package/es/stat-view/horizontal-bar-chart.js +291 -281
- package/es/stat-view/index.js +136 -152
- package/es/stat-view/line-chart.js +267 -265
- package/es/stat-view/map.js +246 -246
- package/es/stat-view/mirror.js +141 -152
- package/es/stat-view/pie-chart.js +143 -156
- package/es/stat-view/pivot-table/index.js +113 -118
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
- package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
- package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
- package/es/stat-view/ring-chart.js +189 -200
- package/es/stat-view/scatter-chart.js +162 -213
- package/es/stat-view/treemap-chart.js +136 -200
- package/es/stat-view/trend-chart.js +137 -183
- package/es/stat-view/world-map.js +233 -243
- package/es/tabs/index.js +164 -169
- package/es/tabs/tab.js +101 -116
- package/es/utils/basic-chart-utils.js +7 -9
- package/es/utils/cell-format.js +48 -51
- package/es/utils/cell-value.js +1 -1
- package/es/utils/collaborator.js +15 -14
- package/es/utils/color-utils.js +48 -37
- package/es/utils/column-utils.js +47 -33
- package/es/utils/column.js +1 -1
- package/es/utils/common-utils.js +111 -117
- package/es/utils/date-format.js +17 -17
- package/es/utils/export-table-utils.js +507 -396
- package/es/utils/index.js +6 -6
- package/es/utils/map.js +30 -34
- package/es/utils/model.js +3 -5
- package/es/utils/object.js +4 -4
- package/es/utils/pivot-table.js +20 -20
- package/es/utils/row-utils.js +41 -33
- package/es/utils/search.js +18 -20
- package/es/utils/sql-utils.js +132 -98
- package/es/utils/stat-utils.js +303 -320
- package/es/utils/trend-utils.js +57 -67
- package/package.json +2 -2
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import PropTypes from 'prop-types';
|
|
7
3
|
import DataSet from '@antv/data-set';
|
|
@@ -13,7 +9,7 @@ import { getCurrentTheme, sortDataByGroupSum } from '../utils/common-utils';
|
|
|
13
9
|
import { getChartGroups } from '../utils/basic-chart-utils';
|
|
14
10
|
import { getConvertedColorRules, getLabelColor } from '../utils/color-utils';
|
|
15
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';
|
|
16
|
-
|
|
12
|
+
const propTypes = {
|
|
17
13
|
isPreview: PropTypes.bool,
|
|
18
14
|
isEdit: PropTypes.bool,
|
|
19
15
|
colorThemeName: PropTypes.string,
|
|
@@ -23,44 +19,43 @@ var propTypes = {
|
|
|
23
19
|
getTableById: PropTypes.func,
|
|
24
20
|
toggleStatisticRecordsDialog: PropTypes.func
|
|
25
21
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var data = originalData;
|
|
22
|
+
class BarChart extends BaseChart {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.drawChart = originalData => {
|
|
26
|
+
const {
|
|
27
|
+
getTableById,
|
|
28
|
+
statItem,
|
|
29
|
+
colorThemeName
|
|
30
|
+
} = this.props;
|
|
31
|
+
const {
|
|
32
|
+
type,
|
|
33
|
+
table_id,
|
|
34
|
+
summary_type,
|
|
35
|
+
y_axis_column_key,
|
|
36
|
+
y_axis_summary_type,
|
|
37
|
+
summary_method,
|
|
38
|
+
y_axis_summary_method,
|
|
39
|
+
column_groupby_column_key,
|
|
40
|
+
column_groupby_multiple_numeric_column,
|
|
41
|
+
sort_type
|
|
42
|
+
} = statItem;
|
|
43
|
+
let data = originalData;
|
|
49
44
|
if (type == STAT_TYPE.BAR_STACK && sort_type) {
|
|
50
45
|
data = sortDataByGroupSum(originalData, sort_type);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
this.initChartHandler();
|
|
48
|
+
this.chart.on('interval:click', e => {
|
|
49
|
+
this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
55
50
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const isGroupBar = column_groupby_column_key || column_groupby_multiple_numeric_column;
|
|
52
|
+
const currentTheme = getCurrentTheme(colorThemeName);
|
|
53
|
+
let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
54
|
+
let summaryType = summary_type;
|
|
55
|
+
let summaryMethod = summary_method;
|
|
61
56
|
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const table = getTableById(table_id);
|
|
58
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
64
59
|
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
65
60
|
}
|
|
66
61
|
if (!summaryType && y_axis_summary_type) {
|
|
@@ -69,65 +64,70 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
69
64
|
if (!summaryMethod && y_axis_summary_method) {
|
|
70
65
|
summaryMethod = y_axis_summary_method;
|
|
71
66
|
}
|
|
72
|
-
|
|
67
|
+
let chartBarColor = '#2a67d1';
|
|
73
68
|
if (isGroupBar) {
|
|
74
69
|
chartBarColor = 'group_name';
|
|
75
|
-
|
|
70
|
+
this.chart.scale('group_name', {
|
|
76
71
|
type: 'cat'
|
|
77
72
|
});
|
|
78
73
|
} else if (currentTheme && currentTheme.colors) {
|
|
79
74
|
chartBarColor = currentTheme.colors[0];
|
|
80
75
|
}
|
|
81
|
-
|
|
76
|
+
this.chart.data(data, {
|
|
82
77
|
'name': {
|
|
83
78
|
type: 'cat',
|
|
84
79
|
nice: false
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
const {
|
|
83
|
+
width
|
|
84
|
+
} = this.chart.coordinateBBox;
|
|
85
|
+
const chartData = isGroupBar ? getChartGroups(data) : data;
|
|
86
|
+
const themeColors = this.getThemeColors();
|
|
87
|
+
const ticks = this.getTicks(chartData, width);
|
|
91
88
|
if (ticks.length > 0) {
|
|
92
|
-
|
|
93
|
-
ticks
|
|
89
|
+
this.chart.scale('name', {
|
|
90
|
+
ticks
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
// set Coord type
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
this.chart.coordinate('rect');
|
|
96
|
+
this.handleAutoRange(data, summaryColumnData, summaryMethod);
|
|
100
97
|
if (isGroupBar) {
|
|
101
|
-
|
|
102
|
-
data
|
|
103
|
-
themeColors
|
|
104
|
-
currentTheme
|
|
105
|
-
summaryColumnData
|
|
106
|
-
summaryType
|
|
107
|
-
summaryMethod
|
|
98
|
+
this.drawBarGroup({
|
|
99
|
+
data,
|
|
100
|
+
themeColors,
|
|
101
|
+
currentTheme,
|
|
102
|
+
summaryColumnData,
|
|
103
|
+
summaryType,
|
|
104
|
+
summaryMethod
|
|
108
105
|
});
|
|
109
106
|
} else {
|
|
110
|
-
|
|
111
|
-
themeColors
|
|
112
|
-
chartBarColor
|
|
113
|
-
summaryType
|
|
114
|
-
summaryMethod
|
|
107
|
+
this.drawBar({
|
|
108
|
+
themeColors,
|
|
109
|
+
chartBarColor,
|
|
110
|
+
summaryType,
|
|
111
|
+
summaryMethod
|
|
115
112
|
});
|
|
116
113
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
this.setTooltip();
|
|
115
|
+
this.setAxis(themeColors);
|
|
116
|
+
this.setLegend(themeColors);
|
|
117
|
+
this.chart.interaction('active-region');
|
|
118
|
+
this.chart.render();
|
|
119
|
+
this.renderAxisLabel();
|
|
123
120
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
isPreview
|
|
127
|
-
statItem
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
this.initChartHandler = () => {
|
|
122
|
+
const {
|
|
123
|
+
isPreview,
|
|
124
|
+
statItem
|
|
125
|
+
} = this.props;
|
|
126
|
+
const {
|
|
127
|
+
display_data
|
|
128
|
+
} = statItem;
|
|
129
|
+
let config = {
|
|
130
|
+
container: this.container,
|
|
131
131
|
autoFit: true,
|
|
132
132
|
appendPadding: [display_data ? 17 : 0, 0, 0, 0]
|
|
133
133
|
};
|
|
@@ -135,25 +135,31 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
135
135
|
config.height = 400;
|
|
136
136
|
config.width = 700;
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
this.chart = new Chart(config);
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
this.drawBar = _ref => {
|
|
141
|
+
let {
|
|
142
|
+
themeColors,
|
|
143
|
+
chartBarColor,
|
|
144
|
+
summaryType,
|
|
145
|
+
summaryMethod
|
|
146
|
+
} = _ref;
|
|
147
|
+
const {
|
|
148
|
+
statItem
|
|
149
|
+
} = this.props;
|
|
150
|
+
const {
|
|
151
|
+
color_option,
|
|
152
|
+
display_data
|
|
153
|
+
} = statItem;
|
|
154
|
+
const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && statItem.y_axis_label_color_rules && getConvertedColorRules(statItem.y_axis_label_color_rules);
|
|
155
|
+
this.chart.interval().label(display_data ? 'formatted_value' : false, {
|
|
150
156
|
style: {
|
|
151
|
-
fontSize:
|
|
157
|
+
fontSize: this.getLabelFontSize(),
|
|
152
158
|
fill: themeColors.textColor
|
|
153
159
|
}
|
|
154
|
-
}).position('name*value').tooltip('name*formatted_value',
|
|
160
|
+
}).position('name*value').tooltip('name*formatted_value', (name, value) => {
|
|
155
161
|
return {
|
|
156
|
-
value
|
|
162
|
+
value,
|
|
157
163
|
title: summaryType === STATISTICS_COUNT_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod]),
|
|
158
164
|
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
159
165
|
};
|
|
@@ -163,37 +169,43 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
163
169
|
stroke: null
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
|
-
}).style('value',
|
|
167
|
-
|
|
172
|
+
}).style('value', value => {
|
|
173
|
+
const color = getLabelColor({
|
|
168
174
|
chart: statItem,
|
|
169
|
-
colorRules
|
|
170
|
-
value
|
|
175
|
+
colorRules,
|
|
176
|
+
value
|
|
171
177
|
});
|
|
172
178
|
return {
|
|
173
179
|
fill: color || chartBarColor
|
|
174
180
|
};
|
|
175
181
|
});
|
|
176
182
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
this.drawBarGroup = _ref2 => {
|
|
184
|
+
let {
|
|
185
|
+
data,
|
|
186
|
+
themeColors,
|
|
187
|
+
summaryColumnData,
|
|
188
|
+
summaryType,
|
|
189
|
+
summaryMethod,
|
|
190
|
+
currentTheme
|
|
191
|
+
} = _ref2;
|
|
192
|
+
const {
|
|
193
|
+
statItem
|
|
194
|
+
} = this.props;
|
|
195
|
+
const {
|
|
196
|
+
type: chartType,
|
|
197
|
+
color_option,
|
|
198
|
+
display_data,
|
|
199
|
+
y_axis_use_stack,
|
|
200
|
+
display_each_block_data
|
|
201
|
+
} = statItem;
|
|
202
|
+
let labelCfg = {
|
|
191
203
|
style: {
|
|
192
|
-
fontSize:
|
|
204
|
+
fontSize: this.getLabelFontSize(),
|
|
193
205
|
fill: themeColors.textColor
|
|
194
206
|
}
|
|
195
207
|
};
|
|
196
|
-
|
|
208
|
+
let displayData = display_data;
|
|
197
209
|
if (chartType == STAT_TYPE.BAR_STACK) {
|
|
198
210
|
displayData = display_each_block_data;
|
|
199
211
|
if (displayData) {
|
|
@@ -201,7 +213,7 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
201
213
|
}
|
|
202
214
|
|
|
203
215
|
// get the total value of each stack
|
|
204
|
-
|
|
216
|
+
const dv = new DataSet.DataView().source(data);
|
|
205
217
|
dv.transform({
|
|
206
218
|
type: 'aggregate',
|
|
207
219
|
fields: ['value'],
|
|
@@ -210,9 +222,9 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
210
222
|
groupBy: ['name']
|
|
211
223
|
});
|
|
212
224
|
if (display_data) {
|
|
213
|
-
dv.rows.forEach(
|
|
214
|
-
|
|
215
|
-
content:
|
|
225
|
+
dv.rows.forEach(item => {
|
|
226
|
+
this.chart.annotation().text({
|
|
227
|
+
content: this.getNumberDisplayString(item.value_sum, summaryColumnData, summaryMethod),
|
|
216
228
|
position: {
|
|
217
229
|
name: item.name,
|
|
218
230
|
value: item.value_sum
|
|
@@ -223,31 +235,31 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
|
-
|
|
238
|
+
let groupColorCallback = currentTheme && currentTheme.colors;
|
|
227
239
|
|
|
228
240
|
// when the 'Group by' column is a 'single-select' column,
|
|
229
241
|
// and the user chooses to use the colors from the column.
|
|
230
242
|
if (color_option === TYPE_COLOR_USING.USE_COLUMN_COLORS) {
|
|
231
|
-
|
|
232
|
-
data.forEach(
|
|
243
|
+
const groupColorMapping = {};
|
|
244
|
+
data.forEach(item => {
|
|
233
245
|
if (!groupColorMapping[item.group_name]) {
|
|
234
246
|
groupColorMapping[item.group_name] = item.color;
|
|
235
247
|
}
|
|
236
248
|
});
|
|
237
|
-
groupColorCallback =
|
|
249
|
+
groupColorCallback = group_name => {
|
|
238
250
|
return groupColorMapping[group_name];
|
|
239
251
|
};
|
|
240
252
|
}
|
|
241
|
-
|
|
253
|
+
this.chart.scale({
|
|
242
254
|
group_name: {
|
|
243
255
|
type: 'cat'
|
|
244
256
|
}
|
|
245
257
|
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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) => {
|
|
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;
|
|
249
261
|
return {
|
|
250
|
-
value
|
|
262
|
+
value,
|
|
251
263
|
title: titleContent,
|
|
252
264
|
name: nameContent
|
|
253
265
|
};
|
|
@@ -261,14 +273,15 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
261
273
|
}
|
|
262
274
|
});
|
|
263
275
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
y_axis_auto_range
|
|
267
|
-
y_axis_min
|
|
268
|
-
y_axis_max
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
276
|
+
this.handleAutoRange = (data, summaryColumnData, summaryMethod) => {
|
|
277
|
+
const {
|
|
278
|
+
y_axis_auto_range,
|
|
279
|
+
y_axis_min,
|
|
280
|
+
y_axis_max
|
|
281
|
+
} = this.props.statItem;
|
|
282
|
+
let valueScaleOptions = {
|
|
283
|
+
formatter: value => {
|
|
284
|
+
return this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
|
|
272
285
|
}
|
|
273
286
|
};
|
|
274
287
|
|
|
@@ -284,14 +297,14 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
284
297
|
});
|
|
285
298
|
|
|
286
299
|
// set the filter rule
|
|
287
|
-
|
|
300
|
+
this.chart.filter('value', value => {
|
|
288
301
|
return value >= y_axis_min;
|
|
289
302
|
});
|
|
290
303
|
|
|
291
304
|
// filter the data
|
|
292
|
-
|
|
305
|
+
this.chart.filterData(data);
|
|
293
306
|
}
|
|
294
|
-
|
|
307
|
+
this.chart.scale({
|
|
295
308
|
// Set the type of the name column so that g2 can draw correctly
|
|
296
309
|
name: {
|
|
297
310
|
type: 'cat'
|
|
@@ -299,20 +312,20 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
299
312
|
value: valueScaleOptions
|
|
300
313
|
});
|
|
301
314
|
};
|
|
302
|
-
|
|
303
|
-
|
|
315
|
+
this.setTooltip = () => {
|
|
316
|
+
this.chart.tooltip({
|
|
304
317
|
showTitle: true,
|
|
305
318
|
showMarkers: false,
|
|
306
319
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
307
320
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
308
321
|
domStyles: {
|
|
309
|
-
'g2-tooltip':
|
|
310
|
-
'tooltip-item':
|
|
322
|
+
'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
323
|
+
'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
|
|
311
324
|
}
|
|
312
325
|
});
|
|
313
326
|
};
|
|
314
|
-
|
|
315
|
-
|
|
327
|
+
this.setAxis = themeColors => {
|
|
328
|
+
this.chart.axis('name', {
|
|
316
329
|
line: {
|
|
317
330
|
style: themeColors.gridColor
|
|
318
331
|
},
|
|
@@ -321,10 +334,10 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
321
334
|
style: {
|
|
322
335
|
fill: themeColors.textColor
|
|
323
336
|
},
|
|
324
|
-
formatter:
|
|
337
|
+
formatter: this.labelFormatter
|
|
325
338
|
}
|
|
326
339
|
});
|
|
327
|
-
|
|
340
|
+
this.chart.axis('value', {
|
|
328
341
|
label: {
|
|
329
342
|
style: {
|
|
330
343
|
fill: themeColors.textColor
|
|
@@ -339,15 +352,15 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
339
352
|
}
|
|
340
353
|
});
|
|
341
354
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
355
|
+
this.setLegend = themeColors => {
|
|
356
|
+
let legendPosition = 'bottom';
|
|
357
|
+
this.chart.legend('group_name', {
|
|
345
358
|
position: legendPosition,
|
|
346
359
|
itemName: {
|
|
347
360
|
style: {
|
|
348
361
|
fill: themeColors.textColor
|
|
349
362
|
},
|
|
350
|
-
formatter:
|
|
363
|
+
formatter: name => {
|
|
351
364
|
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
352
365
|
}
|
|
353
366
|
},
|
|
@@ -367,37 +380,39 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
367
380
|
}
|
|
368
381
|
});
|
|
369
382
|
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
getTableById
|
|
373
|
-
statItem
|
|
383
|
+
this.renderAxisLabel = newStatItem => {
|
|
384
|
+
let {
|
|
385
|
+
getTableById,
|
|
386
|
+
statItem
|
|
387
|
+
} = this.props;
|
|
374
388
|
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
375
389
|
return;
|
|
376
390
|
}
|
|
377
|
-
if (!
|
|
391
|
+
if (!this.chart) return;
|
|
378
392
|
statItem = newStatItem || statItem;
|
|
379
|
-
|
|
380
|
-
type
|
|
381
|
-
table_id
|
|
382
|
-
x_axis_column_key
|
|
383
|
-
y_axis_column_key
|
|
384
|
-
show_y_axis_label
|
|
385
|
-
show_x_axis_label
|
|
386
|
-
y_axis_label_position
|
|
387
|
-
x_axis_label_position
|
|
388
|
-
y_axis_summary_type
|
|
389
|
-
title_name
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
const {
|
|
394
|
+
type,
|
|
395
|
+
table_id,
|
|
396
|
+
x_axis_column_key,
|
|
397
|
+
y_axis_column_key,
|
|
398
|
+
show_y_axis_label,
|
|
399
|
+
show_x_axis_label,
|
|
400
|
+
y_axis_label_position,
|
|
401
|
+
x_axis_label_position,
|
|
402
|
+
y_axis_summary_type,
|
|
403
|
+
title_name
|
|
404
|
+
} = statItem;
|
|
405
|
+
const table = getTableById(table_id);
|
|
406
|
+
const autoPadding = this.chart.autoPadding;
|
|
407
|
+
const textColor = this.getAxisLabelColor();
|
|
408
|
+
const xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
409
|
+
const chartContainer = this.chart.getCanvas().get('container');
|
|
410
|
+
const xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
396
411
|
if (!xLabel && show_x_axis_label) {
|
|
397
|
-
|
|
412
|
+
const div = document.createElement('div');
|
|
398
413
|
div.id = xAxisID;
|
|
399
414
|
div.className = 'statistic-chart-axis-label';
|
|
400
|
-
|
|
415
|
+
const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
401
416
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
402
417
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
403
418
|
chartContainer.appendChild(div);
|
|
@@ -408,160 +423,153 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
408
423
|
if (xLabel && !show_x_axis_label) {
|
|
409
424
|
xLabel.parentNode.removeChild(xLabel);
|
|
410
425
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
426
|
+
const yAxisID = "chart-y-axis-label_".concat(statItem._id);
|
|
427
|
+
const yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
428
|
+
let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
|
|
414
429
|
if (!yLabel && show_y_axis_label) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
430
|
+
const div = document.createElement('div');
|
|
431
|
+
div.id = yAxisID;
|
|
432
|
+
div.className = 'statistic-chart-axis-label';
|
|
418
433
|
if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
|
|
419
|
-
|
|
434
|
+
div.innerHTML = intl.get(TITLE_AMOUNT);
|
|
420
435
|
} else {
|
|
421
|
-
|
|
422
|
-
|
|
436
|
+
const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
437
|
+
div.innerHTML = column.name || '';
|
|
423
438
|
if (type === STAT_TYPE.BAR_STACK) {
|
|
424
|
-
|
|
439
|
+
div.innerHTML = title_name || '';
|
|
425
440
|
}
|
|
426
441
|
}
|
|
427
|
-
|
|
428
|
-
|
|
442
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
443
|
+
let textAlign = 'center';
|
|
429
444
|
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
430
445
|
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
431
|
-
|
|
432
|
-
chartContainer.appendChild(
|
|
446
|
+
div.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
447
|
+
chartContainer.appendChild(div);
|
|
433
448
|
}
|
|
434
449
|
if (yLabel && show_y_axis_label) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (y_axis_label_position === 'bottom')
|
|
438
|
-
if (y_axis_label_position === 'top')
|
|
439
|
-
yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(
|
|
450
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
451
|
+
let textAlign = 'center';
|
|
452
|
+
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
453
|
+
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
454
|
+
yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
440
455
|
}
|
|
441
456
|
if (yLabel && !show_y_axis_label) {
|
|
442
457
|
yLabel.parentNode.removeChild(yLabel);
|
|
443
458
|
}
|
|
444
459
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
460
|
+
this.destroyChart = () => {
|
|
461
|
+
this.chart.destroy();
|
|
462
|
+
this.chart = null;
|
|
448
463
|
};
|
|
449
|
-
|
|
464
|
+
this.state = {
|
|
450
465
|
isCalculatingData: true,
|
|
451
466
|
showResultDescription: true
|
|
452
467
|
};
|
|
453
|
-
|
|
454
|
-
|
|
468
|
+
this.calculateData = null;
|
|
469
|
+
}
|
|
470
|
+
componentDidMount() {
|
|
471
|
+
const {
|
|
472
|
+
statItem,
|
|
473
|
+
chartCalculator,
|
|
474
|
+
eventBus
|
|
475
|
+
} = this.props;
|
|
476
|
+
this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
|
|
477
|
+
this.renderAxisLabel(newStatItem);
|
|
478
|
+
});
|
|
479
|
+
if (this.container) {
|
|
480
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
481
|
+
if (!data) return;
|
|
482
|
+
let showResultDescription = data.length > 0 ? false : true;
|
|
483
|
+
this.setState({
|
|
484
|
+
isCalculatingData: false,
|
|
485
|
+
showResultDescription
|
|
486
|
+
}, () => {
|
|
487
|
+
if (!showResultDescription) {
|
|
488
|
+
this.drawChart(data);
|
|
489
|
+
this.calculateData = data;
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
496
|
+
const {
|
|
497
|
+
colorThemeName
|
|
498
|
+
} = this.props;
|
|
499
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
502
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
return false;
|
|
455
509
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
510
|
+
componentDidUpdate(preProps, preState) {
|
|
511
|
+
const {
|
|
512
|
+
statItem,
|
|
513
|
+
chartCalculator
|
|
514
|
+
} = this.props;
|
|
515
|
+
const {
|
|
516
|
+
isCalculatingData
|
|
517
|
+
} = this.state;
|
|
518
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
519
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
520
|
+
this.setState({
|
|
521
|
+
isCalculatingData: true
|
|
466
522
|
});
|
|
467
523
|
if (this.container) {
|
|
468
|
-
chartCalculator.calculate(statItem).then(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
524
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
525
|
+
const showResultDescription = data.length > 0 ? false : true;
|
|
526
|
+
this.chart && this.destroyChart();
|
|
527
|
+
this.calculateData = data;
|
|
528
|
+
this.setState({
|
|
472
529
|
isCalculatingData: false,
|
|
473
|
-
showResultDescription
|
|
474
|
-
},
|
|
530
|
+
showResultDescription
|
|
531
|
+
}, () => {
|
|
475
532
|
if (!showResultDescription) {
|
|
476
|
-
|
|
477
|
-
|
|
533
|
+
this.drawChart(data);
|
|
534
|
+
if (this.props.isPreview) this.chart.forceFit();
|
|
478
535
|
}
|
|
479
536
|
});
|
|
480
537
|
});
|
|
481
538
|
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
if (nextProps.colorThemeName !== colorThemeName) {
|
|
494
|
-
return true;
|
|
495
|
-
}
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
}, {
|
|
499
|
-
key: "componentDidUpdate",
|
|
500
|
-
value: function componentDidUpdate(preProps, preState) {
|
|
501
|
-
var _this3 = this;
|
|
502
|
-
var _this$props5 = this.props,
|
|
503
|
-
statItem = _this$props5.statItem,
|
|
504
|
-
chartCalculator = _this$props5.chartCalculator;
|
|
505
|
-
var isCalculatingData = this.state.isCalculatingData;
|
|
506
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
507
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
508
|
-
this.setState({
|
|
509
|
-
isCalculatingData: true
|
|
510
|
-
});
|
|
511
|
-
if (this.container) {
|
|
512
|
-
chartCalculator.calculate(statItem).then(function (data) {
|
|
513
|
-
var showResultDescription = data.length > 0 ? false : true;
|
|
514
|
-
_this3.chart && _this3.destroyChart();
|
|
515
|
-
_this3.calculateData = data;
|
|
516
|
-
_this3.setState({
|
|
517
|
-
isCalculatingData: false,
|
|
518
|
-
showResultDescription: showResultDescription
|
|
519
|
-
}, function () {
|
|
520
|
-
if (!showResultDescription) {
|
|
521
|
-
_this3.drawChart(data);
|
|
522
|
-
if (_this3.props.isPreview) _this3.chart.forceFit();
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
} else {
|
|
528
|
-
if (!this.state.showResultDescription) {
|
|
529
|
-
this.chart && this.destroyChart();
|
|
530
|
-
this.drawChart(this.calculateData);
|
|
531
|
-
if (this.props.isPreview) {
|
|
532
|
-
this.chart.forceFit();
|
|
533
|
-
}
|
|
539
|
+
} else {
|
|
540
|
+
if (!this.state.showResultDescription) {
|
|
541
|
+
this.chart && this.destroyChart();
|
|
542
|
+
this.drawChart(this.calculateData);
|
|
543
|
+
if (this.props.isPreview) {
|
|
544
|
+
this.chart.forceFit();
|
|
534
545
|
}
|
|
535
546
|
}
|
|
536
547
|
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}]);
|
|
564
|
-
return BarChart;
|
|
565
|
-
}(BaseChart);
|
|
548
|
+
}
|
|
549
|
+
componentWillUnmount() {
|
|
550
|
+
this.container = null;
|
|
551
|
+
this.unsubscribeStyleChange();
|
|
552
|
+
}
|
|
553
|
+
render() {
|
|
554
|
+
const {
|
|
555
|
+
statItem
|
|
556
|
+
} = this.props;
|
|
557
|
+
const {
|
|
558
|
+
isCalculatingData,
|
|
559
|
+
showResultDescription
|
|
560
|
+
} = this.state;
|
|
561
|
+
const {
|
|
562
|
+
show_y_axis_label,
|
|
563
|
+
show_x_axis_label
|
|
564
|
+
} = statItem;
|
|
565
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
566
|
+
ref: ref => this.container = ref,
|
|
567
|
+
style: {
|
|
568
|
+
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
569
|
+
},
|
|
570
|
+
className: "statistic-chart-container"
|
|
571
|
+
}));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
566
574
|
BarChart.propTypes = propTypes;
|
|
567
575
|
export default BarChart;
|