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,255 @@
|
|
|
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, getNumberDisplayString } from 'dtable-store';
|
|
11
|
+
import BaseChart from './base-chart';
|
|
12
|
+
import { Chart } from '../custom-g2';
|
|
13
|
+
import { Loading } from '../components';
|
|
14
|
+
import { EMPTY_NAME, STAT_ITEM_THEME_COLORS } from '../constants';
|
|
15
|
+
var propTypes = {
|
|
16
|
+
isPreview: PropTypes.bool,
|
|
17
|
+
isEnlarge: PropTypes.bool,
|
|
18
|
+
theme: PropTypes.string,
|
|
19
|
+
statItem: PropTypes.object,
|
|
20
|
+
chartCalculator: PropTypes.object,
|
|
21
|
+
getTableById: PropTypes.func
|
|
22
|
+
};
|
|
23
|
+
var BasicNumericCard = /*#__PURE__*/function (_BaseChart) {
|
|
24
|
+
_inherits(BasicNumericCard, _BaseChart);
|
|
25
|
+
var _super = _createSuper(BasicNumericCard);
|
|
26
|
+
function BasicNumericCard(props) {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, BasicNumericCard);
|
|
29
|
+
_this = _super.call(this, props);
|
|
30
|
+
_this.componentDidMount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
31
|
+
var _this$props, statItem, chartCalculator, data;
|
|
32
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
33
|
+
while (1) {
|
|
34
|
+
switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
_this$props = _this.props, statItem = _this$props.statItem, chartCalculator = _this$props.chartCalculator;
|
|
37
|
+
if (!_this.container) {
|
|
38
|
+
_context.next = 8;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
_context.next = 4;
|
|
42
|
+
return chartCalculator.calculate(statItem);
|
|
43
|
+
case 4:
|
|
44
|
+
data = _context.sent;
|
|
45
|
+
_this.setState({
|
|
46
|
+
isCalculatingData: false
|
|
47
|
+
});
|
|
48
|
+
_this.drawChart(data);
|
|
49
|
+
_this.calculateData = data;
|
|
50
|
+
case 8:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
_this.componentDidUpdate = /*#__PURE__*/function () {
|
|
58
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(preProps, preState) {
|
|
59
|
+
var _this$props2, statItem, chartCalculator, isCalculatingData, data;
|
|
60
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
61
|
+
while (1) {
|
|
62
|
+
switch (_context2.prev = _context2.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
_this$props2 = _this.props, statItem = _this$props2.statItem, chartCalculator = _this$props2.chartCalculator;
|
|
65
|
+
isCalculatingData = _this.state.isCalculatingData;
|
|
66
|
+
if (!(isCalculatingData !== preState.isCalculatingData)) {
|
|
67
|
+
_context2.next = 4;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context2.abrupt("return");
|
|
71
|
+
case 4:
|
|
72
|
+
if (!_this.shouldCalculateStatItem(preProps, _this.props)) {
|
|
73
|
+
_context2.next = 17;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
_this.setState({
|
|
77
|
+
isCalculatingData: true
|
|
78
|
+
});
|
|
79
|
+
if (!_this.container) {
|
|
80
|
+
_context2.next = 15;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
_context2.next = 9;
|
|
84
|
+
return chartCalculator.calculate(statItem);
|
|
85
|
+
case 9:
|
|
86
|
+
data = _context2.sent;
|
|
87
|
+
_this.calculateData = data;
|
|
88
|
+
_this.setState({
|
|
89
|
+
isCalculatingData: false
|
|
90
|
+
});
|
|
91
|
+
_this.chart && _this.chart.destroy();
|
|
92
|
+
_this.drawChart(data);
|
|
93
|
+
if (_this.props.isPreview) {
|
|
94
|
+
_this.chart.forceFit();
|
|
95
|
+
}
|
|
96
|
+
case 15:
|
|
97
|
+
_context2.next = 20;
|
|
98
|
+
break;
|
|
99
|
+
case 17:
|
|
100
|
+
_this.chart && _this.chart.destroy();
|
|
101
|
+
_this.drawChart(_this.calculateData);
|
|
102
|
+
if (_this.props.isPreview) {
|
|
103
|
+
_this.chart.forceFit();
|
|
104
|
+
}
|
|
105
|
+
case 20:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context2.stop();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, _callee2);
|
|
111
|
+
}));
|
|
112
|
+
return function (_x, _x2) {
|
|
113
|
+
return _ref2.apply(this, arguments);
|
|
114
|
+
};
|
|
115
|
+
}();
|
|
116
|
+
_this.drawChart = function (data) {
|
|
117
|
+
var _this$props3 = _this.props,
|
|
118
|
+
isPreview = _this$props3.isPreview,
|
|
119
|
+
statItem = _this$props3.statItem,
|
|
120
|
+
isEnlarge = _this$props3.isEnlarge,
|
|
121
|
+
theme = _this$props3.theme;
|
|
122
|
+
if (isPreview) {
|
|
123
|
+
_this.chart = new Chart({
|
|
124
|
+
container: _this.container,
|
|
125
|
+
autoFit: true
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
_this.chart = new Chart({
|
|
129
|
+
container: _this.container,
|
|
130
|
+
autoFit: true,
|
|
131
|
+
height: 400,
|
|
132
|
+
width: 700
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
var summary_method = statItem.summary_method;
|
|
136
|
+
var content = summary_method === 'Distinct_values' ? data : _this.formatData(data);
|
|
137
|
+
var fontSize = _this.getFontSize(content);
|
|
138
|
+
var labelFontSize = fontSize - 35;
|
|
139
|
+
if (labelFontSize > 20) {
|
|
140
|
+
labelFontSize = 20;
|
|
141
|
+
}
|
|
142
|
+
if (labelFontSize < 12) {
|
|
143
|
+
labelFontSize = 12;
|
|
144
|
+
}
|
|
145
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
146
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
147
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
148
|
+
}
|
|
149
|
+
_this.chart.annotation().html({
|
|
150
|
+
position: ['50%', '50%'],
|
|
151
|
+
html: "\n <div style=\"color: ".concat(themeColors.cardColor, "; text-align: center;\">\n <p class=\"text-content\" style=\"font-size: ").concat(fontSize, "px; margin: -15px 0 2px 0;\">").concat(content, "</p>\n <p style=\"font-size: ").concat(labelFontSize, "px;margin: 0;\">").concat(statItem.name || '', "</p>\n </div>\n ")
|
|
152
|
+
});
|
|
153
|
+
_this.chart.render();
|
|
154
|
+
};
|
|
155
|
+
_this.formatData = function (data) {
|
|
156
|
+
if (!data) return intl.get(EMPTY_NAME);
|
|
157
|
+
var _this$props4 = _this.props,
|
|
158
|
+
getTableById = _this$props4.getTableById,
|
|
159
|
+
statItem = _this$props4.statItem;
|
|
160
|
+
var summary_method = statItem.summary_method,
|
|
161
|
+
table_id = statItem.table_id,
|
|
162
|
+
numeric_column = statItem.numeric_column;
|
|
163
|
+
if (summary_method !== 'Row_count') {
|
|
164
|
+
var table = getTableById(table_id);
|
|
165
|
+
var selectedColumn = TableUtils.getTableColumnByKey(table, numeric_column);
|
|
166
|
+
var formattedContent = getNumberDisplayString(data, selectedColumn.data || {});
|
|
167
|
+
return formattedContent;
|
|
168
|
+
}
|
|
169
|
+
var string = data + '';
|
|
170
|
+
var isFloat = string.indexOf('.') > 0;
|
|
171
|
+
if (isFloat) {
|
|
172
|
+
string = string.slice(0, string.indexOf('.'));
|
|
173
|
+
}
|
|
174
|
+
var content = '';
|
|
175
|
+
var endPoint = -3;
|
|
176
|
+
var startPoint = 0;
|
|
177
|
+
var subString = string.slice(endPoint);
|
|
178
|
+
while (subString.length === 3) {
|
|
179
|
+
content = ',' + subString + content;
|
|
180
|
+
startPoint = endPoint;
|
|
181
|
+
endPoint -= 3;
|
|
182
|
+
subString = string.slice(endPoint, startPoint);
|
|
183
|
+
}
|
|
184
|
+
content = subString + content;
|
|
185
|
+
if (content[0] === ',') {
|
|
186
|
+
content = content.slice(1);
|
|
187
|
+
}
|
|
188
|
+
if (isFloat) {
|
|
189
|
+
var initString = data + '';
|
|
190
|
+
content = content + initString.slice(initString.indexOf('.'));
|
|
191
|
+
}
|
|
192
|
+
return content;
|
|
193
|
+
};
|
|
194
|
+
_this.getFontSize = function (content) {
|
|
195
|
+
var canvas = document.createElement('canvas');
|
|
196
|
+
var context = canvas.getContext('2d');
|
|
197
|
+
var width = _this.chart.width;
|
|
198
|
+
var font = context.font;
|
|
199
|
+
var initFontSize = 70;
|
|
200
|
+
var fontStyle = font.slice(font.indexOf('px'));
|
|
201
|
+
font = initFontSize + fontStyle;
|
|
202
|
+
context.font = font;
|
|
203
|
+
context.fontSize = initFontSize;
|
|
204
|
+
while (context.measureText(content).width >= width - 40) {
|
|
205
|
+
initFontSize -= 1;
|
|
206
|
+
context.font = initFontSize + fontStyle;
|
|
207
|
+
context.fontSize = initFontSize;
|
|
208
|
+
}
|
|
209
|
+
canvas = null;
|
|
210
|
+
if (initFontSize < 16) {
|
|
211
|
+
initFontSize = 16;
|
|
212
|
+
}
|
|
213
|
+
return initFontSize;
|
|
214
|
+
};
|
|
215
|
+
_this.state = {
|
|
216
|
+
isCalculatingData: true
|
|
217
|
+
};
|
|
218
|
+
_this.calculateData = null;
|
|
219
|
+
return _this;
|
|
220
|
+
}
|
|
221
|
+
_createClass(BasicNumericCard, [{
|
|
222
|
+
key: "shouldComponentUpdate",
|
|
223
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
224
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "componentWillUnmount",
|
|
234
|
+
value: function componentWillUnmount() {
|
|
235
|
+
this.container = null;
|
|
236
|
+
}
|
|
237
|
+
}, {
|
|
238
|
+
key: "render",
|
|
239
|
+
value: function render() {
|
|
240
|
+
var _this2 = this;
|
|
241
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
242
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
243
|
+
className: 'statistic-chart-loading-container'
|
|
244
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
245
|
+
ref: function ref(_ref3) {
|
|
246
|
+
return _this2.container = _ref3;
|
|
247
|
+
},
|
|
248
|
+
className: "statistic-chart-container statistic-number-card"
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
}]);
|
|
252
|
+
return BasicNumericCard;
|
|
253
|
+
}(BaseChart);
|
|
254
|
+
BasicNumericCard.propTypes = propTypes;
|
|
255
|
+
export default BasicNumericCard;
|