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,367 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import intl from 'react-intl-universal';
|
|
10
|
+
import { TableUtils } from 'dtable-store';
|
|
11
|
+
import BaseChart from './base-chart';
|
|
12
|
+
import { Chart } from '../custom-g2';
|
|
13
|
+
import { Loading } from '../components';
|
|
14
|
+
import { getCurrentTheme } from '../utils/common-utils';
|
|
15
|
+
import { EMPTY_NAME, LABEL_CONFIG_CHANGED, STAT_ITEM_THEME_COLORS } from '../constants';
|
|
16
|
+
import chartStyles from '../assets/css/statistic-chart.module.css';
|
|
17
|
+
var propTypes = {
|
|
18
|
+
isPreview: PropTypes.bool,
|
|
19
|
+
isEnlarge: PropTypes.bool,
|
|
20
|
+
theme: PropTypes.string,
|
|
21
|
+
colorThemeName: PropTypes.string,
|
|
22
|
+
statItem: PropTypes.object,
|
|
23
|
+
chartCalculator: PropTypes.object,
|
|
24
|
+
eventBus: PropTypes.object,
|
|
25
|
+
getTableById: PropTypes.func,
|
|
26
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
27
|
+
};
|
|
28
|
+
var ScatterChart = /*#__PURE__*/function (_BaseChart) {
|
|
29
|
+
_inherits(ScatterChart, _BaseChart);
|
|
30
|
+
var _super = _createSuper(ScatterChart);
|
|
31
|
+
function ScatterChart(props) {
|
|
32
|
+
var _this;
|
|
33
|
+
_classCallCheck(this, ScatterChart);
|
|
34
|
+
_this = _super.call(this, props);
|
|
35
|
+
_this.componentDidMount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
36
|
+
var _this$props, statItem, chartCalculator, eventBus, data;
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) {
|
|
39
|
+
switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_this$props = _this.props, statItem = _this$props.statItem, chartCalculator = _this$props.chartCalculator, eventBus = _this$props.eventBus;
|
|
42
|
+
if (!_this.container) {
|
|
43
|
+
_context.next = 8;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
_context.next = 4;
|
|
47
|
+
return chartCalculator.calculate(statItem);
|
|
48
|
+
case 4:
|
|
49
|
+
data = _context.sent;
|
|
50
|
+
_this.setState({
|
|
51
|
+
isCalculatingData: false
|
|
52
|
+
});
|
|
53
|
+
_this.drawChart(data);
|
|
54
|
+
_this.calculateData = data;
|
|
55
|
+
case 8:
|
|
56
|
+
_this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
|
|
57
|
+
_this.renderAxisLabel(newStatItem);
|
|
58
|
+
});
|
|
59
|
+
case 9:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
_this.componentDidUpdate = /*#__PURE__*/function () {
|
|
67
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(preProps, preState) {
|
|
68
|
+
var _this$props2, statItem, chartCalculator, isCalculatingData, data;
|
|
69
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) {
|
|
71
|
+
switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
_this$props2 = _this.props, statItem = _this$props2.statItem, chartCalculator = _this$props2.chartCalculator;
|
|
74
|
+
isCalculatingData = _this.state.isCalculatingData;
|
|
75
|
+
if (!(isCalculatingData !== preState.isCalculatingData)) {
|
|
76
|
+
_context2.next = 4;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
return _context2.abrupt("return");
|
|
80
|
+
case 4:
|
|
81
|
+
if (!_this.shouldCalculateStatItem(preProps, _this.props)) {
|
|
82
|
+
_context2.next = 17;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (!_this.container) {
|
|
86
|
+
_context2.next = 15;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
_this.setState({
|
|
90
|
+
isCalculatingData: true
|
|
91
|
+
});
|
|
92
|
+
_context2.next = 9;
|
|
93
|
+
return chartCalculator.calculate(statItem);
|
|
94
|
+
case 9:
|
|
95
|
+
data = _context2.sent;
|
|
96
|
+
_this.calculateData = data;
|
|
97
|
+
_this.setState({
|
|
98
|
+
isCalculatingData: false
|
|
99
|
+
});
|
|
100
|
+
_this.chart && _this.chart.destroy();
|
|
101
|
+
_this.drawChart(data);
|
|
102
|
+
if (_this.props.isPreview) {
|
|
103
|
+
_this.chart.forceFit();
|
|
104
|
+
}
|
|
105
|
+
case 15:
|
|
106
|
+
_context2.next = 20;
|
|
107
|
+
break;
|
|
108
|
+
case 17:
|
|
109
|
+
_this.chart && _this.chart.destroy();
|
|
110
|
+
_this.drawChart(_this.calculateData);
|
|
111
|
+
if (_this.props.isPreview) {
|
|
112
|
+
_this.chart.forceFit();
|
|
113
|
+
}
|
|
114
|
+
case 20:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context2.stop();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, _callee2);
|
|
120
|
+
}));
|
|
121
|
+
return function (_x, _x2) {
|
|
122
|
+
return _ref2.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
125
|
+
_this.drawChart = function (data) {
|
|
126
|
+
var _this$props3 = _this.props,
|
|
127
|
+
getTableById = _this$props3.getTableById,
|
|
128
|
+
isPreview = _this$props3.isPreview,
|
|
129
|
+
statItem = _this$props3.statItem,
|
|
130
|
+
isEnlarge = _this$props3.isEnlarge,
|
|
131
|
+
theme = _this$props3.theme,
|
|
132
|
+
colorThemeName = _this$props3.colorThemeName;
|
|
133
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
134
|
+
var table_id = statItem.table_id,
|
|
135
|
+
x_axis_column = statItem.x_axis_column,
|
|
136
|
+
y_axis_column = statItem.y_axis_column;
|
|
137
|
+
var selectedTable = getTableById(table_id);
|
|
138
|
+
var selectedXAxisColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column);
|
|
139
|
+
var selectedYAxisColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_column);
|
|
140
|
+
if (isPreview) {
|
|
141
|
+
_this.chart = new Chart({
|
|
142
|
+
container: _this.container,
|
|
143
|
+
autoFit: true
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
_this.chart = new Chart({
|
|
147
|
+
container: _this.container,
|
|
148
|
+
height: 400,
|
|
149
|
+
width: 700
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
_this.chart.on('element:click', function (e) {
|
|
153
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
154
|
+
});
|
|
155
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
156
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
157
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
158
|
+
}
|
|
159
|
+
_this.chart.axis('x_axis', {
|
|
160
|
+
label: {
|
|
161
|
+
style: {
|
|
162
|
+
fill: themeColors.textColor
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
line: {
|
|
166
|
+
style: themeColors.gridColor
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
_this.chart.axis('y_axis', {
|
|
170
|
+
grid: {
|
|
171
|
+
line: {
|
|
172
|
+
style: {
|
|
173
|
+
stroke: themeColors.gridColor
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
label: {
|
|
178
|
+
style: {
|
|
179
|
+
fill: themeColors.textColor
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
var chart = _this.chart;
|
|
184
|
+
chart.data(data);
|
|
185
|
+
chart.scale({
|
|
186
|
+
x_axis: {
|
|
187
|
+
nice: true
|
|
188
|
+
},
|
|
189
|
+
y_axis: {
|
|
190
|
+
nice: true
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
chart.tooltip({
|
|
194
|
+
showTitle: false,
|
|
195
|
+
showCrosshairs: true,
|
|
196
|
+
crosshairs: {
|
|
197
|
+
type: 'xy'
|
|
198
|
+
},
|
|
199
|
+
itemTpl: '<li class="g2-tooltip-list-item" data-index={index} style="margin-bottom:4px;">' + '<span style="background-color:{color};" class="g2-tooltip-marker"></span>' + '{name}<br/>' + '{valueX}<br/>' + '{valueY}' + '</li>'
|
|
200
|
+
});
|
|
201
|
+
chart.point().position('x_axis*y_axis').color('group_by', currentTheme && currentTheme.colors).shape('circle').tooltip('group_by*x_axis*y_axis', function (group_by, x_axis, y_axis) {
|
|
202
|
+
return {
|
|
203
|
+
name: group_by || group_by === 0 ? group_by : intl.get(EMPTY_NAME),
|
|
204
|
+
valueX: "".concat(selectedXAxisColumn.name, ": ").concat(x_axis),
|
|
205
|
+
valueY: "".concat(selectedYAxisColumn.name, ": ").concat(y_axis)
|
|
206
|
+
};
|
|
207
|
+
}).style({
|
|
208
|
+
fillOpacity: 0.85
|
|
209
|
+
});
|
|
210
|
+
chart.legend('group_by', {
|
|
211
|
+
position: 'bottom',
|
|
212
|
+
itemName: {
|
|
213
|
+
formatter: function formatter(name) {
|
|
214
|
+
return name || name === 0 ? name : intl.get(EMPTY_NAME);
|
|
215
|
+
},
|
|
216
|
+
style: {
|
|
217
|
+
fill: themeColors.textColor
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
pageNavigator: {
|
|
221
|
+
text: {
|
|
222
|
+
style: {
|
|
223
|
+
fill: themeColors.textColor
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
marker: {
|
|
227
|
+
style: {
|
|
228
|
+
fill: themeColors.legendPageNavigatorMarkerColor,
|
|
229
|
+
inactiveFill: themeColors.legendPageNavigatorMarkerColor,
|
|
230
|
+
inactiveOpacity: 0.45
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
chart.interaction('legend-highlight');
|
|
236
|
+
chart.render();
|
|
237
|
+
_this.renderAxisLabel();
|
|
238
|
+
};
|
|
239
|
+
_this.renderAxisLabel = function (newStatItem) {
|
|
240
|
+
var _this$props4 = _this.props,
|
|
241
|
+
getTableById = _this$props4.getTableById,
|
|
242
|
+
statItem = _this$props4.statItem;
|
|
243
|
+
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (!_this.chart) return;
|
|
247
|
+
statItem = newStatItem || statItem;
|
|
248
|
+
var _this$props5 = _this.props,
|
|
249
|
+
isEnlarge = _this$props5.isEnlarge,
|
|
250
|
+
isPreview = _this$props5.isPreview,
|
|
251
|
+
theme = _this$props5.theme;
|
|
252
|
+
var _statItem = statItem,
|
|
253
|
+
table_id = _statItem.table_id,
|
|
254
|
+
x_axis_column = _statItem.x_axis_column,
|
|
255
|
+
y_axis_column = _statItem.y_axis_column,
|
|
256
|
+
show_y_axis_label = _statItem.show_y_axis_label,
|
|
257
|
+
show_x_axis_label = _statItem.show_x_axis_label,
|
|
258
|
+
y_axis_label_position = _statItem.y_axis_label_position,
|
|
259
|
+
x_axis_label_position = _statItem.x_axis_label_position;
|
|
260
|
+
var table = getTableById(table_id);
|
|
261
|
+
var autoPadding = _this.chart.autoPadding;
|
|
262
|
+
var textColor = '#999999';
|
|
263
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
264
|
+
textColor = '#ffffff';
|
|
265
|
+
}
|
|
266
|
+
var xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
267
|
+
var chartContainer = _this.chart.getCanvas().get('container');
|
|
268
|
+
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
269
|
+
if (!xLabel && show_x_axis_label) {
|
|
270
|
+
var div = document.createElement('div');
|
|
271
|
+
div.id = xAxisID;
|
|
272
|
+
div.className = 'statistic-chart-axis-label';
|
|
273
|
+
var column = TableUtils.getTableColumnByKey(table, x_axis_column);
|
|
274
|
+
div.innerHTML = "".concat(column ? column.name : '');
|
|
275
|
+
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
276
|
+
chartContainer.appendChild(div);
|
|
277
|
+
}
|
|
278
|
+
if (xLabel && show_x_axis_label) {
|
|
279
|
+
xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
280
|
+
}
|
|
281
|
+
if (xLabel && !show_x_axis_label) {
|
|
282
|
+
xLabel.parentNode.removeChild(xLabel);
|
|
283
|
+
}
|
|
284
|
+
var yAxisID = "chart-y-axis-label_".concat(statItem._id);
|
|
285
|
+
var yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
286
|
+
var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
|
|
287
|
+
if (!yLabel && show_y_axis_label) {
|
|
288
|
+
var _div = document.createElement('div');
|
|
289
|
+
_div.id = yAxisID;
|
|
290
|
+
_div.className = 'statistic-chart-axis-label';
|
|
291
|
+
var _column = TableUtils.getTableColumnByKey(table, y_axis_column) || {};
|
|
292
|
+
_div.innerHTML = _column.name || '';
|
|
293
|
+
var containerHeight = chartContainer.offsetHeight;
|
|
294
|
+
var textAlign = 'center';
|
|
295
|
+
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
296
|
+
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
297
|
+
_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)"));
|
|
298
|
+
chartContainer.appendChild(_div);
|
|
299
|
+
}
|
|
300
|
+
if (yLabel && show_y_axis_label) {
|
|
301
|
+
var _containerHeight = chartContainer.offsetHeight;
|
|
302
|
+
var _textAlign = 'center';
|
|
303
|
+
if (y_axis_label_position === 'bottom') _textAlign = 'left';
|
|
304
|
+
if (y_axis_label_position === 'top') _textAlign = 'right';
|
|
305
|
+
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)"));
|
|
306
|
+
}
|
|
307
|
+
if (yLabel && !show_y_axis_label) {
|
|
308
|
+
yLabel.parentNode.removeChild(yLabel);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
_this.state = {
|
|
312
|
+
isCalculatingData: true
|
|
313
|
+
};
|
|
314
|
+
_this.calculateData = null;
|
|
315
|
+
return _this;
|
|
316
|
+
}
|
|
317
|
+
_createClass(ScatterChart, [{
|
|
318
|
+
key: "shouldComponentUpdate",
|
|
319
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
320
|
+
var colorThemeName = this.props.colorThemeName;
|
|
321
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "componentWillUnmount",
|
|
334
|
+
value: function componentWillUnmount() {
|
|
335
|
+
this.container = null;
|
|
336
|
+
this.unsubscribeStyleChange && this.unsubscribeStyleChange();
|
|
337
|
+
}
|
|
338
|
+
}, {
|
|
339
|
+
key: "render",
|
|
340
|
+
value: function render() {
|
|
341
|
+
var _this2 = this;
|
|
342
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
343
|
+
var _this$props$statItem = this.props.statItem,
|
|
344
|
+
show_x_axis_label = _this$props$statItem.show_x_axis_label,
|
|
345
|
+
show_y_axis_label = _this$props$statItem.show_y_axis_label;
|
|
346
|
+
var style = {};
|
|
347
|
+
if (show_x_axis_label) {
|
|
348
|
+
style.paddingBottom = 38;
|
|
349
|
+
}
|
|
350
|
+
if (show_y_axis_label) {
|
|
351
|
+
style.paddingLeft = 38;
|
|
352
|
+
}
|
|
353
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
354
|
+
className: 'statistic-chart-loading-container'
|
|
355
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
356
|
+
ref: function ref(_ref3) {
|
|
357
|
+
return _this2.container = _ref3;
|
|
358
|
+
},
|
|
359
|
+
className: "".concat(chartStyles['statistic-scatter-chart-container'], " statistic-chart-container"),
|
|
360
|
+
style: style
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
}]);
|
|
364
|
+
return ScatterChart;
|
|
365
|
+
}(BaseChart);
|
|
366
|
+
ScatterChart.propTypes = propTypes;
|
|
367
|
+
export default ScatterChart;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import DataSet from '@antv/data-set';
|
|
11
|
+
import intl from 'react-intl-universal';
|
|
12
|
+
import { each, pick } from '@antv/util';
|
|
13
|
+
import { getEllipsisText } from '@antv/g2/esm/util/text';
|
|
14
|
+
import { TableUtils } from 'dtable-store';
|
|
15
|
+
import BaseChart from './base-chart';
|
|
16
|
+
import { Chart, registerGeometryLabelLayout } from '../custom-g2';
|
|
17
|
+
import { Loading } from '../components';
|
|
18
|
+
import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
|
|
19
|
+
import { EMPTY_NAME, STATISTICS_COUNT_TYPE } from '../constants';
|
|
20
|
+
import chartStyles from '../assets/css/statistic-chart.module.css';
|
|
21
|
+
var propTypes = {
|
|
22
|
+
isPreview: PropTypes.bool,
|
|
23
|
+
isEnlarge: PropTypes.bool,
|
|
24
|
+
theme: PropTypes.string,
|
|
25
|
+
colorThemeName: PropTypes.string,
|
|
26
|
+
statItem: PropTypes.object,
|
|
27
|
+
chartCalculator: PropTypes.object,
|
|
28
|
+
getTableById: PropTypes.func,
|
|
29
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
30
|
+
};
|
|
31
|
+
var TreemapChart = /*#__PURE__*/function (_BaseChart) {
|
|
32
|
+
_inherits(TreemapChart, _BaseChart);
|
|
33
|
+
var _super = _createSuper(TreemapChart);
|
|
34
|
+
function TreemapChart(props) {
|
|
35
|
+
var _this;
|
|
36
|
+
_classCallCheck(this, TreemapChart);
|
|
37
|
+
_this = _super.call(this, props);
|
|
38
|
+
_this.componentDidMount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
39
|
+
var _this$props, statItem, chartCalculator, data;
|
|
40
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) {
|
|
42
|
+
switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
_this$props = _this.props, statItem = _this$props.statItem, chartCalculator = _this$props.chartCalculator;
|
|
45
|
+
if (!_this.container) {
|
|
46
|
+
_context.next = 8;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
return chartCalculator.calculate(statItem);
|
|
51
|
+
case 4:
|
|
52
|
+
data = _context.sent;
|
|
53
|
+
_this.setState({
|
|
54
|
+
isCalculatingData: false
|
|
55
|
+
});
|
|
56
|
+
_this.drawChart(data);
|
|
57
|
+
_this.calculateData = data;
|
|
58
|
+
case 8:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, _callee);
|
|
64
|
+
}));
|
|
65
|
+
_this.componentDidUpdate = /*#__PURE__*/function () {
|
|
66
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(preProps, preState) {
|
|
67
|
+
var _this$props2, statItem, chartCalculator, isCalculatingData, data;
|
|
68
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
69
|
+
while (1) {
|
|
70
|
+
switch (_context2.prev = _context2.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
_this$props2 = _this.props, statItem = _this$props2.statItem, chartCalculator = _this$props2.chartCalculator;
|
|
73
|
+
isCalculatingData = _this.state.isCalculatingData;
|
|
74
|
+
if (!(isCalculatingData !== preState.isCalculatingData)) {
|
|
75
|
+
_context2.next = 4;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
return _context2.abrupt("return");
|
|
79
|
+
case 4:
|
|
80
|
+
if (!_this.shouldCalculateStatItem(preProps, _this.props)) {
|
|
81
|
+
_context2.next = 17;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
_this.setState({
|
|
85
|
+
isCalculatingData: true
|
|
86
|
+
});
|
|
87
|
+
if (!_this.container) {
|
|
88
|
+
_context2.next = 15;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
_context2.next = 9;
|
|
92
|
+
return chartCalculator.calculate(statItem);
|
|
93
|
+
case 9:
|
|
94
|
+
data = _context2.sent;
|
|
95
|
+
_this.calculateData = data;
|
|
96
|
+
_this.setState({
|
|
97
|
+
isCalculatingData: false
|
|
98
|
+
});
|
|
99
|
+
_this.chart && _this.chart.destroy();
|
|
100
|
+
_this.drawChart(data);
|
|
101
|
+
if (_this.props.isPreview) {
|
|
102
|
+
_this.chart.forceFit();
|
|
103
|
+
}
|
|
104
|
+
case 15:
|
|
105
|
+
_context2.next = 20;
|
|
106
|
+
break;
|
|
107
|
+
case 17:
|
|
108
|
+
_this.chart && _this.chart.destroy();
|
|
109
|
+
_this.drawChart(_this.calculateData);
|
|
110
|
+
if (_this.props.isPreview) {
|
|
111
|
+
_this.chart.forceFit();
|
|
112
|
+
}
|
|
113
|
+
case 20:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context2.stop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, _callee2);
|
|
119
|
+
}));
|
|
120
|
+
return function (_x, _x2) {
|
|
121
|
+
return _ref2.apply(this, arguments);
|
|
122
|
+
};
|
|
123
|
+
}();
|
|
124
|
+
_this.drawChart = function (data) {
|
|
125
|
+
var _this$props3 = _this.props,
|
|
126
|
+
getTableById = _this$props3.getTableById,
|
|
127
|
+
isPreview = _this$props3.isPreview,
|
|
128
|
+
statItem = _this$props3.statItem,
|
|
129
|
+
colorThemeName = _this$props3.colorThemeName;
|
|
130
|
+
var table_id = statItem.table_id,
|
|
131
|
+
summary_type = statItem.summary_type,
|
|
132
|
+
summary_column_key = statItem.summary_column_key;
|
|
133
|
+
var table = getTableById(table_id);
|
|
134
|
+
var selectedNumericColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
|
|
135
|
+
if (isPreview) {
|
|
136
|
+
_this.chart = new Chart({
|
|
137
|
+
container: _this.container,
|
|
138
|
+
autoFit: true
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
_this.chart = new Chart({
|
|
142
|
+
container: _this.container,
|
|
143
|
+
height: 400,
|
|
144
|
+
width: 700
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
_this.chart.on('element:click', function (e) {
|
|
148
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
149
|
+
});
|
|
150
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
151
|
+
var newData = formatPieChartData(data, statItem, table, currentTheme);
|
|
152
|
+
var colorSet = newData.colorSet;
|
|
153
|
+
var DataView = DataSet.DataView;
|
|
154
|
+
var dv = new DataView();
|
|
155
|
+
var fullData = {
|
|
156
|
+
name: 'root',
|
|
157
|
+
children: newData.map(function (item) {
|
|
158
|
+
var name = item.name;
|
|
159
|
+
item.name = name || name === 0 ? name : intl.get(EMPTY_NAME);
|
|
160
|
+
if (name == 'Others') {
|
|
161
|
+
item.name = intl.get('Others');
|
|
162
|
+
}
|
|
163
|
+
return item;
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
dv.source(fullData, {
|
|
167
|
+
type: 'hierarchy'
|
|
168
|
+
}).transform({
|
|
169
|
+
field: 'value',
|
|
170
|
+
type: 'hierarchy.treemap',
|
|
171
|
+
tile: 'treemapResquarify',
|
|
172
|
+
as: ['x', 'y']
|
|
173
|
+
});
|
|
174
|
+
var nodes = [];
|
|
175
|
+
var _iterator = _createForOfIteratorHelper(dv.getAllNodes()),
|
|
176
|
+
_step;
|
|
177
|
+
try {
|
|
178
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
179
|
+
var node = _step.value;
|
|
180
|
+
if (node.data.name === 'root') {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
var eachNode = {
|
|
184
|
+
name: node.data.name,
|
|
185
|
+
x: node.x,
|
|
186
|
+
y: node.y,
|
|
187
|
+
value: node.data.value,
|
|
188
|
+
formatted_value: node.data.formatted_value,
|
|
189
|
+
percent: node.data.percent,
|
|
190
|
+
original_name: node.data.original_name,
|
|
191
|
+
rows: node.data.rows || null
|
|
192
|
+
};
|
|
193
|
+
nodes.push(eachNode);
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator.f();
|
|
199
|
+
}
|
|
200
|
+
var chart = _this.chart;
|
|
201
|
+
chart.data(nodes);
|
|
202
|
+
chart.scale({
|
|
203
|
+
x: {
|
|
204
|
+
nice: true
|
|
205
|
+
},
|
|
206
|
+
y: {
|
|
207
|
+
nice: true
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
chart.axis(false);
|
|
211
|
+
chart.legend(false);
|
|
212
|
+
chart.tooltip({
|
|
213
|
+
showTitle: false,
|
|
214
|
+
showMarkers: false,
|
|
215
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
216
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">{info}<div></div>',
|
|
217
|
+
domStyles: {
|
|
218
|
+
'g2-tooltip': {
|
|
219
|
+
borderRadius: '2px',
|
|
220
|
+
backgroundColor: '#fff',
|
|
221
|
+
padding: '10px'
|
|
222
|
+
},
|
|
223
|
+
'tooltip-item': {
|
|
224
|
+
marginTop: '5px'
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
chart.polygon().position('x*y').color('name', colorSet).tooltip('name*formatted_value*percent', function (name, value, percent) {
|
|
229
|
+
return {
|
|
230
|
+
name: name,
|
|
231
|
+
info: summary_type == STATISTICS_COUNT_TYPE.COUNT ? "".concat(value) : "".concat(selectedNumericColumn.name, ": ").concat(value, " (").concat(percent, ")")
|
|
232
|
+
};
|
|
233
|
+
}).style({
|
|
234
|
+
lineWidth: 1,
|
|
235
|
+
stroke: '#fff'
|
|
236
|
+
}).label('name', {
|
|
237
|
+
offset: 0,
|
|
238
|
+
style: {
|
|
239
|
+
textBaseline: 'middle'
|
|
240
|
+
},
|
|
241
|
+
content: function content(obj) {
|
|
242
|
+
if (obj.name !== 'root') {
|
|
243
|
+
return obj.name;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
layout: {
|
|
247
|
+
type: 'custom-limit-in-shape'
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
chart.interaction('element-active');
|
|
251
|
+
chart.render();
|
|
252
|
+
};
|
|
253
|
+
_this.state = {
|
|
254
|
+
isCalculatingData: true
|
|
255
|
+
};
|
|
256
|
+
_this.calculateData = null;
|
|
257
|
+
|
|
258
|
+
// customize label layout: show ellipsis for long labels
|
|
259
|
+
function limitInShape(items, labels, shapes, region) {
|
|
260
|
+
each(labels, function (label, index) {
|
|
261
|
+
var labelBBox = label.getCanvasBBox();
|
|
262
|
+
var shapeBBox = shapes[index].getBBox();
|
|
263
|
+
if (labelBBox.minX < shapeBBox.minX || labelBBox.minY < shapeBBox.minY || labelBBox.maxX > shapeBBox.maxX || labelBBox.maxY > shapeBBox.maxY) {
|
|
264
|
+
var translateX = labelBBox.width - shapeBBox.width + 20;
|
|
265
|
+
var textShapes = label.findAll(function (shape) {
|
|
266
|
+
return shape.get('type') === 'text';
|
|
267
|
+
});
|
|
268
|
+
textShapes.forEach(function (textShape) {
|
|
269
|
+
var style = pick(textShape.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
|
|
270
|
+
var textBox = textShape.getCanvasBBox();
|
|
271
|
+
var text = getEllipsisText(textShape.attr('text'), textBox.width - Math.abs(translateX), style);
|
|
272
|
+
textShape.attr('text', text);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
registerGeometryLabelLayout('custom-limit-in-shape', limitInShape);
|
|
278
|
+
return _this;
|
|
279
|
+
}
|
|
280
|
+
_createClass(TreemapChart, [{
|
|
281
|
+
key: "shouldComponentUpdate",
|
|
282
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
283
|
+
var colorThemeName = this.props.colorThemeName;
|
|
284
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "componentWillUnmount",
|
|
297
|
+
value: function componentWillUnmount() {
|
|
298
|
+
this.container = null;
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
key: "render",
|
|
302
|
+
value: function render() {
|
|
303
|
+
var _this2 = this;
|
|
304
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
305
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
306
|
+
className: 'statistic-chart-loading-container'
|
|
307
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
308
|
+
ref: function ref(_ref3) {
|
|
309
|
+
return _this2.container = _ref3;
|
|
310
|
+
},
|
|
311
|
+
className: "statistic-chart-loading-container ".concat(chartStyles['statistic-treemap-chart-container'])
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
}]);
|
|
315
|
+
return TreemapChart;
|
|
316
|
+
}(BaseChart);
|
|
317
|
+
TreemapChart.propTypes = propTypes;
|
|
318
|
+
export default TreemapChart;
|