dtable-statistic 4.0.2-test-2
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/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,428 @@
|
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import DataSet from '@antv/data-set/lib/index';
|
|
8
|
+
import { TableUtils, getNumberDisplayString } from 'dtable-store';
|
|
9
|
+
import BaseChart from './base-chart';
|
|
10
|
+
import { Chart } from '../custom-g2';
|
|
11
|
+
import { Loading } from '../components';
|
|
12
|
+
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE } from '../constants';
|
|
13
|
+
var WIDTH = 798;
|
|
14
|
+
var HEIGHT = 520;
|
|
15
|
+
var Map = /*#__PURE__*/function (_BaseChart) {
|
|
16
|
+
_inherits(Map, _BaseChart);
|
|
17
|
+
var _super = _createSuper(Map);
|
|
18
|
+
function Map(props) {
|
|
19
|
+
var _this;
|
|
20
|
+
_classCallCheck(this, Map);
|
|
21
|
+
_this = _super.call(this, props);
|
|
22
|
+
_this.fixData = function (statisticData) {
|
|
23
|
+
if (!statisticData) return [];
|
|
24
|
+
var statisticNewData = [];
|
|
25
|
+
var sum = 0;
|
|
26
|
+
var statItem = _this.props.statItem;
|
|
27
|
+
var type = statItem.type;
|
|
28
|
+
statisticData.forEach(function (item, index) {
|
|
29
|
+
if (item && item.name) {
|
|
30
|
+
var matchFeature = _this.mapData.features.find(function (feature) {
|
|
31
|
+
return feature.properties.name.indexOf(item.name) > -1;
|
|
32
|
+
});
|
|
33
|
+
if (matchFeature) {
|
|
34
|
+
statisticNewData.push({
|
|
35
|
+
name: matchFeature.properties.name,
|
|
36
|
+
value: item.value || 0
|
|
37
|
+
});
|
|
38
|
+
if (type === 'map_bubble') {
|
|
39
|
+
sum += item.value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (type === 'map_bubble') {
|
|
45
|
+
statisticNewData.sum = sum;
|
|
46
|
+
}
|
|
47
|
+
return statisticNewData;
|
|
48
|
+
};
|
|
49
|
+
_this.renderCommonMap = function (data) {
|
|
50
|
+
var _this$props = _this.props,
|
|
51
|
+
getTableById = _this$props.getTableById,
|
|
52
|
+
statItem = _this$props.statItem,
|
|
53
|
+
theme = _this$props.theme,
|
|
54
|
+
isEnlarge = _this$props.isEnlarge,
|
|
55
|
+
isPreview = _this$props.isPreview;
|
|
56
|
+
var userDataView = _this.dataSet.getView('statisticViewModel').source(data).transform({
|
|
57
|
+
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
58
|
+
field: 'name',
|
|
59
|
+
type: 'geo.region',
|
|
60
|
+
as: ['longitude', 'latitude']
|
|
61
|
+
});
|
|
62
|
+
var _this$props$statItem = _this.props.statItem,
|
|
63
|
+
table_id = _this$props$statItem.table_id,
|
|
64
|
+
data_color = _this$props$statItem.data_color,
|
|
65
|
+
summary_type = _this$props$statItem.summary_type,
|
|
66
|
+
summary_column = _this$props$statItem.summary_column;
|
|
67
|
+
var currentColorOption = COLOR_OPTIONS.filter(function (item) {
|
|
68
|
+
return item.name == data_color;
|
|
69
|
+
})[0] || COLOR_OPTIONS[0];
|
|
70
|
+
var exampleColors = currentColorOption.exampleColors,
|
|
71
|
+
highlightedBorderColor = currentColorOption.highlightedBorderColor;
|
|
72
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
73
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
74
|
+
var table = getTableById(table_id);
|
|
75
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
76
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
77
|
+
}
|
|
78
|
+
_this.statisticView = _this.chart.createView();
|
|
79
|
+
_this.statisticView.data(userDataView.rows);
|
|
80
|
+
_this.statisticView.polygon().position('longitude*latitude').color('value', "".concat(exampleColors[0], "-").concat(exampleColors[4], "-").concat(exampleColors[8])).style({
|
|
81
|
+
lineWidth: 1,
|
|
82
|
+
stroke: '#bdbdbd',
|
|
83
|
+
strokeOpacity: 0.5
|
|
84
|
+
}).state({
|
|
85
|
+
active: {
|
|
86
|
+
style: {
|
|
87
|
+
lineWidth: 1,
|
|
88
|
+
stroke: highlightedBorderColor
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}).tooltip('name*value*color', function (name, value, color) {
|
|
92
|
+
return {
|
|
93
|
+
name: name,
|
|
94
|
+
value: getNumberDisplayString(value, columnData),
|
|
95
|
+
color: color
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
99
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
100
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
101
|
+
}
|
|
102
|
+
var legendDirection = statItem.legend_direction || 'vertical';
|
|
103
|
+
var size = statItem.legend_size || 1;
|
|
104
|
+
_this.chart.legend({
|
|
105
|
+
layout: legendDirection,
|
|
106
|
+
position: legendDirection === 'vertical' ? 'left-bottom' : 'bottom-left',
|
|
107
|
+
rail: {
|
|
108
|
+
type: 'color',
|
|
109
|
+
defaultLength: 100 * size
|
|
110
|
+
},
|
|
111
|
+
label: {
|
|
112
|
+
spacing: 2,
|
|
113
|
+
style: {
|
|
114
|
+
fill: themeColors.textColor
|
|
115
|
+
},
|
|
116
|
+
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
117
|
+
formatter: function formatter(value) {
|
|
118
|
+
return getNumberDisplayString(value, columnData);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
handler: {
|
|
122
|
+
style: {
|
|
123
|
+
'opacity': 0
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
_this.statisticView.interaction('element-active');
|
|
128
|
+
_this.statisticView.render();
|
|
129
|
+
};
|
|
130
|
+
_this.updateStatisticData = function (data) {
|
|
131
|
+
// re-render statistic data view;
|
|
132
|
+
if (_this.statisticView) {
|
|
133
|
+
_this.statisticView.destroy();
|
|
134
|
+
}
|
|
135
|
+
if (data.length === 0) {
|
|
136
|
+
_this.chart.legend(false);
|
|
137
|
+
_this.chart.render();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
var statItem = _this.props.statItem;
|
|
141
|
+
var mapType = statItem.type;
|
|
142
|
+
if (!mapType.includes('bubble')) {
|
|
143
|
+
_this.renderCommonMap(data);
|
|
144
|
+
} else {
|
|
145
|
+
_this.renderBubbleMap(data);
|
|
146
|
+
}
|
|
147
|
+
_this.chart.render();
|
|
148
|
+
};
|
|
149
|
+
_this.renderBubbleMap = function (data) {
|
|
150
|
+
var _this$props2 = _this.props,
|
|
151
|
+
getTableById = _this$props2.getTableById,
|
|
152
|
+
statItem = _this$props2.statItem,
|
|
153
|
+
isPreview = _this$props2.isPreview,
|
|
154
|
+
isEnlarge = _this$props2.isEnlarge,
|
|
155
|
+
theme = _this$props2.theme;
|
|
156
|
+
var userDv = _this.dataSet.createView().source(data).transform({
|
|
157
|
+
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
158
|
+
field: 'name',
|
|
159
|
+
type: 'geo.centroid',
|
|
160
|
+
as: ['longitude', 'latitude']
|
|
161
|
+
});
|
|
162
|
+
var _this$props$statItem2 = _this.props.statItem,
|
|
163
|
+
table_id = _this$props$statItem2.table_id,
|
|
164
|
+
summary_type = _this$props$statItem2.summary_type,
|
|
165
|
+
summary_column = _this$props$statItem2.summary_column;
|
|
166
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
167
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
168
|
+
var table = getTableById(table_id);
|
|
169
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
170
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
171
|
+
}
|
|
172
|
+
_this.statisticView = _this.chart.createView();
|
|
173
|
+
_this.statisticView.data(userDv.rows);
|
|
174
|
+
_this.statisticView.point().position('longitude*latitude').size('value', function (value) {
|
|
175
|
+
var percent = value / data.sum;
|
|
176
|
+
var size = percent * 100;
|
|
177
|
+
if (isPreview && size > 60) {
|
|
178
|
+
size = 60;
|
|
179
|
+
}
|
|
180
|
+
return size;
|
|
181
|
+
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*value*color', function (name, value, color) {
|
|
182
|
+
return {
|
|
183
|
+
name: name,
|
|
184
|
+
value: getNumberDisplayString(value, columnData),
|
|
185
|
+
color: color
|
|
186
|
+
};
|
|
187
|
+
}).style({
|
|
188
|
+
fillOpacity: 0.6,
|
|
189
|
+
stroke: statItem.bubble_color || '#2a67d1'
|
|
190
|
+
}).state({
|
|
191
|
+
active: {
|
|
192
|
+
style: {
|
|
193
|
+
lineWidth: 1,
|
|
194
|
+
stroke: statItem.bubble_color || '#2a67d1',
|
|
195
|
+
fillOpacity: 0.9
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
200
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
201
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
202
|
+
}
|
|
203
|
+
var legendDirection = statItem.legend_direction || 'vertical';
|
|
204
|
+
var size = statItem.legend_size || 1;
|
|
205
|
+
_this.chart.legend({
|
|
206
|
+
layout: legendDirection,
|
|
207
|
+
position: legendDirection === 'vertical' ? 'left-bottom' : 'bottom-left',
|
|
208
|
+
rail: {
|
|
209
|
+
type: 'size',
|
|
210
|
+
defaultLength: 100 * size
|
|
211
|
+
},
|
|
212
|
+
label: {
|
|
213
|
+
style: {
|
|
214
|
+
fill: themeColors.textColor
|
|
215
|
+
},
|
|
216
|
+
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
217
|
+
formatter: function formatter(value) {
|
|
218
|
+
return getNumberDisplayString(value, columnData);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
handler: {
|
|
222
|
+
style: {
|
|
223
|
+
'opacity': 0
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
_this.statisticView.interaction('element-active');
|
|
228
|
+
_this.statisticView.render();
|
|
229
|
+
};
|
|
230
|
+
_this.getCanvasSize = function () {
|
|
231
|
+
var maxWidth = _this.container.clientWidth;
|
|
232
|
+
var maxHeight = _this.container.clientHeight;
|
|
233
|
+
var h = maxHeight;
|
|
234
|
+
var w = h * (WIDTH / HEIGHT);
|
|
235
|
+
if (w > maxWidth) {
|
|
236
|
+
w = maxWidth;
|
|
237
|
+
h = w * (HEIGHT / WIDTH);
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
w: w,
|
|
241
|
+
h: h
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
_this.initStatisticContext = function (geolocation) {
|
|
245
|
+
_this.mapData = geolocation;
|
|
246
|
+
if (!_this.container) return;
|
|
247
|
+
// create chart
|
|
248
|
+
var canvasSize = _this.getCanvasSize();
|
|
249
|
+
_this.chart = new Chart({
|
|
250
|
+
container: _this.container,
|
|
251
|
+
width: canvasSize.w,
|
|
252
|
+
height: canvasSize.h,
|
|
253
|
+
padding: [20, 20]
|
|
254
|
+
});
|
|
255
|
+
_this.chart.on('element:click', function (e) {
|
|
256
|
+
var statItem = _this.props.statItem;
|
|
257
|
+
var data = e.data.data;
|
|
258
|
+
var clickData = _this.calculateData.find(function (i) {
|
|
259
|
+
return i.name === data.name;
|
|
260
|
+
});
|
|
261
|
+
if (clickData) {
|
|
262
|
+
_this.props.toggleStatisticRecordsDialog(clickData, statItem);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
_this.chart.tooltip({
|
|
266
|
+
showTitle: false,
|
|
267
|
+
showMarkers: false,
|
|
268
|
+
shared: true,
|
|
269
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
270
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">数量: {value}<div></div>',
|
|
271
|
+
domStyles: {
|
|
272
|
+
'g2-tooltip': {
|
|
273
|
+
borderRadius: '2px',
|
|
274
|
+
backgroundColor: '#fff',
|
|
275
|
+
padding: '10px'
|
|
276
|
+
},
|
|
277
|
+
'tooltip-item': {
|
|
278
|
+
marginTop: '5px'
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
_this.chart.scale({
|
|
283
|
+
longitude: {
|
|
284
|
+
sync: true
|
|
285
|
+
},
|
|
286
|
+
latitude: {
|
|
287
|
+
sync: true
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
_this.chart.axis(false);
|
|
291
|
+
_this.dataSet = new DataSet();
|
|
292
|
+
|
|
293
|
+
// transform map data
|
|
294
|
+
var mapData = _this.dataSet.createView('mapDataModel').source(geolocation, {
|
|
295
|
+
type: 'GeoJSON'
|
|
296
|
+
});
|
|
297
|
+
var mapView = _this.chart.createView();
|
|
298
|
+
|
|
299
|
+
// draw background map
|
|
300
|
+
mapView.data(mapData.rows);
|
|
301
|
+
mapView.tooltip(false);
|
|
302
|
+
mapView.polygon().position('longitude*latitude').style({
|
|
303
|
+
fill: '#e2e2e2',
|
|
304
|
+
stroke: '#bdbdbd',
|
|
305
|
+
lineWidth: 1
|
|
306
|
+
});
|
|
307
|
+
_this.dataSet.createView('statisticViewModel');
|
|
308
|
+
mapView.render();
|
|
309
|
+
};
|
|
310
|
+
_this.getGeoLocationData = function () {
|
|
311
|
+
var mediaUrl = window.dtable.mediaUrl;
|
|
312
|
+
return fetch("".concat(mediaUrl, "dtable-statistic/geolocation/china.json")).catch(function (err) {});
|
|
313
|
+
};
|
|
314
|
+
_this.state = {
|
|
315
|
+
isDataLoaded: false,
|
|
316
|
+
isCalculatingData: true
|
|
317
|
+
};
|
|
318
|
+
_this.calculateData = null;
|
|
319
|
+
return _this;
|
|
320
|
+
}
|
|
321
|
+
_createClass(Map, [{
|
|
322
|
+
key: "componentDidMount",
|
|
323
|
+
value: function componentDidMount() {
|
|
324
|
+
var _this2 = this;
|
|
325
|
+
var _this$props3 = this.props,
|
|
326
|
+
statItem = _this$props3.statItem,
|
|
327
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
328
|
+
this.getGeoLocationData().then(function (res) {
|
|
329
|
+
return res && res.json();
|
|
330
|
+
}).then(function (data) {
|
|
331
|
+
_this2.setState({
|
|
332
|
+
isDataLoaded: true
|
|
333
|
+
}, function () {
|
|
334
|
+
if (!data) return;
|
|
335
|
+
_this2.initStatisticContext(data);
|
|
336
|
+
if (_this2.container) {
|
|
337
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
338
|
+
_this2.calculateData = data;
|
|
339
|
+
_this2.updateStatisticData(_this2.fixData(data));
|
|
340
|
+
_this2.setState({
|
|
341
|
+
isCalculatingData: false
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
key: "shouldComponentUpdate",
|
|
350
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
351
|
+
if (this.canUpdate(this.props, nextProps) && nextState.isDataLoaded === this.state.isDataLoaded) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
}, {
|
|
360
|
+
key: "componentDidUpdate",
|
|
361
|
+
value: function componentDidUpdate(preProps, preState) {
|
|
362
|
+
var _this3 = this;
|
|
363
|
+
if (!this.chart || !this.dataSet) return;
|
|
364
|
+
var _this$props4 = this.props,
|
|
365
|
+
statItem = _this$props4.statItem,
|
|
366
|
+
chartCalculator = _this$props4.chartCalculator;
|
|
367
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
368
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
369
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
370
|
+
this.setState({
|
|
371
|
+
isCalculatingData: true
|
|
372
|
+
});
|
|
373
|
+
if (this.container) {
|
|
374
|
+
chartCalculator.calculate(statItem).then(function (statData) {
|
|
375
|
+
_this3.calculateData = statData;
|
|
376
|
+
_this3.setState({
|
|
377
|
+
isCalculatingData: false
|
|
378
|
+
});
|
|
379
|
+
_this3.updateStatisticData(_this3.fixData(statData));
|
|
380
|
+
if (_this3.props.isPreview) {
|
|
381
|
+
var canvasSize = _this3.getCanvasSize();
|
|
382
|
+
_this3.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
this.updateStatisticData(this.fixData(this.calculateData));
|
|
388
|
+
if (this.props.isPreview) {
|
|
389
|
+
var canvasSize = this.getCanvasSize();
|
|
390
|
+
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}, {
|
|
395
|
+
key: "componentWillUnmount",
|
|
396
|
+
value: function componentWillUnmount() {
|
|
397
|
+
this.container = null;
|
|
398
|
+
this.setState = function () {};
|
|
399
|
+
}
|
|
400
|
+
}, {
|
|
401
|
+
key: "render",
|
|
402
|
+
value: function render() {
|
|
403
|
+
var _this4 = this;
|
|
404
|
+
var _this$state = this.state,
|
|
405
|
+
isDataLoaded = _this$state.isDataLoaded,
|
|
406
|
+
isCalculatingData = _this$state.isCalculatingData;
|
|
407
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (!isDataLoaded || isCalculatingData) && /*#__PURE__*/React.createElement("div", {
|
|
408
|
+
className: 'statistic-chart-loading-container'
|
|
409
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
410
|
+
ref: function ref(_ref) {
|
|
411
|
+
return _this4.container = _ref;
|
|
412
|
+
},
|
|
413
|
+
className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
|
|
414
|
+
}));
|
|
415
|
+
}
|
|
416
|
+
}]);
|
|
417
|
+
return Map;
|
|
418
|
+
}(BaseChart);
|
|
419
|
+
Map.propTypes = {
|
|
420
|
+
isPreview: PropTypes.bool,
|
|
421
|
+
isEnlarge: PropTypes.bool,
|
|
422
|
+
theme: PropTypes.string,
|
|
423
|
+
statItem: PropTypes.object,
|
|
424
|
+
chartCalculator: PropTypes.object,
|
|
425
|
+
getTableById: PropTypes.func,
|
|
426
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
427
|
+
};
|
|
428
|
+
export default Map;
|
|
@@ -0,0 +1,285 @@
|
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import intl from 'react-intl-universal';
|
|
8
|
+
import { TableUtils, getNumberDisplayString } from 'dtable-store';
|
|
9
|
+
import BaseChart from './base-chart';
|
|
10
|
+
import { Chart } from '../custom-g2';
|
|
11
|
+
import { Loading } from '../components';
|
|
12
|
+
import { DEFAULT_NUMBER_FORMAT_OBJECT, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
13
|
+
var Mirror = /*#__PURE__*/function (_BaseChart) {
|
|
14
|
+
_inherits(Mirror, _BaseChart);
|
|
15
|
+
var _super = _createSuper(Mirror);
|
|
16
|
+
function Mirror(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
_classCallCheck(this, Mirror);
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
_this.drawChart = function (_ref) {
|
|
21
|
+
var data = _ref.data,
|
|
22
|
+
colorSet = _ref.colorSet;
|
|
23
|
+
var _this$props = _this.props,
|
|
24
|
+
getTableById = _this$props.getTableById,
|
|
25
|
+
isPreview = _this$props.isPreview,
|
|
26
|
+
statItem = _this$props.statItem,
|
|
27
|
+
isEnlarge = _this$props.isEnlarge,
|
|
28
|
+
theme = _this$props.theme;
|
|
29
|
+
var table_id = statItem.table_id,
|
|
30
|
+
summary_type = statItem.summary_type,
|
|
31
|
+
summary_method = statItem.summary_method,
|
|
32
|
+
is_transpose = statItem.is_transpose,
|
|
33
|
+
summary_column = statItem.summary_column;
|
|
34
|
+
if (isPreview) {
|
|
35
|
+
_this.chart = new Chart({
|
|
36
|
+
container: _this.container,
|
|
37
|
+
autoFit: true,
|
|
38
|
+
padding: is_transpose ? [35, 10, 30, 10] : [10, 100, 30, 10]
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
_this.chart = new Chart({
|
|
42
|
+
container: _this.container,
|
|
43
|
+
autoFit: true,
|
|
44
|
+
height: 520,
|
|
45
|
+
width: 800,
|
|
46
|
+
padding: is_transpose ? [35, 30, 30, 30] : [30, 100, 30, 30]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
_this.chart.on('element:click', function (e) {
|
|
50
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
51
|
+
});
|
|
52
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
53
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
54
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
55
|
+
}
|
|
56
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
57
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
58
|
+
var table = getTableById(table_id);
|
|
59
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
60
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
61
|
+
}
|
|
62
|
+
_this.chart.data(data);
|
|
63
|
+
_this.chart.axis('name', {
|
|
64
|
+
line: {
|
|
65
|
+
style: themeColors.gridColor
|
|
66
|
+
},
|
|
67
|
+
label: {
|
|
68
|
+
style: {
|
|
69
|
+
fill: themeColors.textColor
|
|
70
|
+
},
|
|
71
|
+
formatter: function formatter(name) {
|
|
72
|
+
var label = name;
|
|
73
|
+
if (name.length > 5) {
|
|
74
|
+
label = "".concat(name.slice(0, 5), "...");
|
|
75
|
+
}
|
|
76
|
+
return label;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
_this.chart.axis('value', {
|
|
81
|
+
label: {
|
|
82
|
+
style: {
|
|
83
|
+
fill: themeColors.textColor
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
grid: {
|
|
87
|
+
line: {
|
|
88
|
+
style: {
|
|
89
|
+
stroke: themeColors.gridColor
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
_this.chart.scale({
|
|
95
|
+
name: {
|
|
96
|
+
sync: true
|
|
97
|
+
},
|
|
98
|
+
value: {
|
|
99
|
+
sync: true,
|
|
100
|
+
formatter: function formatter(value) {
|
|
101
|
+
return getNumberDisplayString(value, columnData);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
group_name: {
|
|
105
|
+
sync: true
|
|
106
|
+
},
|
|
107
|
+
color: {
|
|
108
|
+
sync: true
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
_this.chart.tooltip({
|
|
112
|
+
showTitle: true,
|
|
113
|
+
showMarkers: false,
|
|
114
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
115
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
116
|
+
domStyles: {
|
|
117
|
+
'g2-tooltip': {
|
|
118
|
+
borderRadius: '2px',
|
|
119
|
+
backgroundColor: '#fff',
|
|
120
|
+
padding: '10px'
|
|
121
|
+
},
|
|
122
|
+
'tooltip-item': {
|
|
123
|
+
marginTop: '5px'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
_this.chart.facet('mirror', {
|
|
128
|
+
fields: ['group_name'],
|
|
129
|
+
transpose: statItem.is_transpose,
|
|
130
|
+
padding: 'auto',
|
|
131
|
+
title: {
|
|
132
|
+
style: {
|
|
133
|
+
fill: themeColors.textColor
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
eachView: function eachView(view, facet) {
|
|
137
|
+
if (facet.rowValue && facet.rowValue.length > 5) {
|
|
138
|
+
facet.rowValue = facet.rowValue.slice(0, 5) + '...';
|
|
139
|
+
}
|
|
140
|
+
view.interval().position('name*value').color('group_name', colorSet).tooltip('name*value', function (name, value) {
|
|
141
|
+
return {
|
|
142
|
+
title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method]),
|
|
143
|
+
value: getNumberDisplayString(value, columnData),
|
|
144
|
+
name: name
|
|
145
|
+
};
|
|
146
|
+
}).state({
|
|
147
|
+
active: {
|
|
148
|
+
style: function style(element) {
|
|
149
|
+
return {
|
|
150
|
+
fillOpacity: 0.6
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
view.interaction('active-region');
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
_this.chart.legend({
|
|
159
|
+
itemName: {
|
|
160
|
+
style: {
|
|
161
|
+
fill: themeColors.textColor
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
_this.chart.render();
|
|
166
|
+
};
|
|
167
|
+
_this.destroyChart = function () {
|
|
168
|
+
_this.chart.destroy();
|
|
169
|
+
_this.chart = null;
|
|
170
|
+
};
|
|
171
|
+
_this.state = {
|
|
172
|
+
isCalculatingData: true,
|
|
173
|
+
showResultDescription: true
|
|
174
|
+
};
|
|
175
|
+
_this.calculateData = null;
|
|
176
|
+
return _this;
|
|
177
|
+
}
|
|
178
|
+
_createClass(Mirror, [{
|
|
179
|
+
key: "componentDidMount",
|
|
180
|
+
value: function componentDidMount() {
|
|
181
|
+
var _this2 = this;
|
|
182
|
+
var _this$props2 = this.props,
|
|
183
|
+
statItem = _this$props2.statItem,
|
|
184
|
+
chartCalculator = _this$props2.chartCalculator;
|
|
185
|
+
if (this.container) {
|
|
186
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
187
|
+
var showResultDescription = data.colorSet && data.colorSet.length > 0 ? false : true;
|
|
188
|
+
_this2.setState({
|
|
189
|
+
isCalculatingData: false,
|
|
190
|
+
showResultDescription: showResultDescription
|
|
191
|
+
}, function () {
|
|
192
|
+
if (!showResultDescription) {
|
|
193
|
+
_this2.drawChart(data);
|
|
194
|
+
_this2.calculateData = data;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "shouldComponentUpdate",
|
|
202
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
203
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "componentDidUpdate",
|
|
213
|
+
value: function componentDidUpdate(preProps, preState) {
|
|
214
|
+
var _this3 = this;
|
|
215
|
+
var _this$props3 = this.props,
|
|
216
|
+
statItem = _this$props3.statItem,
|
|
217
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
218
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
219
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
220
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
221
|
+
this.setState({
|
|
222
|
+
isCalculatingData: true
|
|
223
|
+
});
|
|
224
|
+
if (this.container) {
|
|
225
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
226
|
+
var showResultDescription = data.colorSet && data.colorSet.length > 0 ? false : true;
|
|
227
|
+
_this3.chart && _this3.destroyChart();
|
|
228
|
+
_this3.calculateData = data;
|
|
229
|
+
_this3.setState({
|
|
230
|
+
isCalculatingData: false,
|
|
231
|
+
showResultDescription: showResultDescription
|
|
232
|
+
}, function () {
|
|
233
|
+
if (!showResultDescription) {
|
|
234
|
+
_this3.drawChart(data);
|
|
235
|
+
if (_this3.props.isPreview) _this3.chart.forceFit();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
if (!this.state.showResultDescription) {
|
|
242
|
+
this.chart && this.destroyChart();
|
|
243
|
+
this.drawChart(this.calculateData);
|
|
244
|
+
if (this.props.isPreview) {
|
|
245
|
+
this.chart.forceFit();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "componentWillUnmount",
|
|
252
|
+
value: function componentWillUnmount() {
|
|
253
|
+
this.container = null;
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "render",
|
|
257
|
+
value: function render() {
|
|
258
|
+
var _this4 = this;
|
|
259
|
+
var _this$state = this.state,
|
|
260
|
+
isCalculatingData = _this$state.isCalculatingData,
|
|
261
|
+
showResultDescription = _this$state.showResultDescription;
|
|
262
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
263
|
+
className: 'statistic-chart-loading-container'
|
|
264
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
className: 'statistic-chart-text'
|
|
266
|
+
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
267
|
+
ref: function ref(_ref2) {
|
|
268
|
+
return _this4.container = _ref2;
|
|
269
|
+
},
|
|
270
|
+
className: "statistic-mirror-chart-container statistic-chart-container"
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
}]);
|
|
274
|
+
return Mirror;
|
|
275
|
+
}(BaseChart);
|
|
276
|
+
Mirror.propTypes = {
|
|
277
|
+
isPreview: PropTypes.bool,
|
|
278
|
+
isEnlarge: PropTypes.bool,
|
|
279
|
+
theme: PropTypes.string,
|
|
280
|
+
statItem: PropTypes.object,
|
|
281
|
+
chartCalculator: PropTypes.object,
|
|
282
|
+
getTableById: PropTypes.func,
|
|
283
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
284
|
+
};
|
|
285
|
+
export default Mirror;
|