dtable-statistic 4.4.24 → 5.0.0-alpha.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.
Files changed (208) hide show
  1. package/es/assets/css/dashboard.css +1 -0
  2. package/es/assets/css/dialog.css +35 -0
  3. package/es/components/dialog/chart-edit-dialog.js +93 -0
  4. package/es/components/dialog/enlarged-chart-dialog.js +8 -13
  5. package/es/components/dialog/statistic-record-dialog/index.js +26 -33
  6. package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
  7. package/es/constants/index.js +3 -499
  8. package/es/dashboard.js +9 -87
  9. package/es/desktop-dashboard.js +51 -32
  10. package/es/index.js +56 -1
  11. package/es/mobile-dashboard.js +8 -16
  12. package/es/model/conver-statItem.js +124 -0
  13. package/es/service/chart-service.js +8 -27
  14. package/es/service/dashboard-service.js +25 -29
  15. package/es/stat-list/chart-preview.js +19 -20
  16. package/es/stat-list/index.js +15 -21
  17. package/es/stat-view/index.js +47 -156
  18. package/es/tabs/tab.js +17 -14
  19. package/es/utils/common-utils.js +2 -352
  20. package/es/utils/export-table-utils.js +0 -69
  21. package/es/utils/index.js +0 -89
  22. package/package.json +6 -8
  23. package/es/assets/css/color-picker.css +0 -53
  24. package/es/assets/css/color-rules-popover.css +0 -144
  25. package/es/assets/css/slider.css +0 -77
  26. package/es/assets/css/statistic-chart.module.css +0 -11
  27. package/es/assets/css/statistic-custom-title.module.css +0 -3
  28. package/es/assets/css/statistic-custom.module.css +0 -4
  29. package/es/assets/css/statistic-numeric-column-item.module.css +0 -43
  30. package/es/assets/css/statistic-time-picker.module.css +0 -21
  31. package/es/calculator/base-calculator.js +0 -80
  32. package/es/calculator/basic-chart-calculator.js +0 -349
  33. package/es/calculator/combination-calculator.js +0 -246
  34. package/es/calculator/compare-bar-calculator.js +0 -197
  35. package/es/calculator/completeness-calculator.js +0 -215
  36. package/es/calculator/copy-value.js +0 -53
  37. package/es/calculator/dashboard-calculator.js +0 -70
  38. package/es/calculator/heat-map-calculator.js +0 -148
  39. package/es/calculator/horizontal-bar-calculator.js +0 -67
  40. package/es/calculator/index.js +0 -81
  41. package/es/calculator/map-calculator.js +0 -103
  42. package/es/calculator/mirror-calculator.js +0 -146
  43. package/es/calculator/number-card-calculator.js +0 -60
  44. package/es/calculator/pivot-table-calculator.js +0 -821
  45. package/es/calculator/scatter-calculator.js +0 -75
  46. package/es/calculator/thread-manager.js +0 -57
  47. package/es/calculator/trend-calculator.js +0 -113
  48. package/es/calculator/workers/basic-chart-calculator-worker.js +0 -495
  49. package/es/calculator/workers/calculator.worker.js +0 -44
  50. package/es/calculator/workers/card-calculator-worker.js +0 -40
  51. package/es/calculator/workers/combination-calculator-worker.js +0 -276
  52. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +0 -150
  53. package/es/calculator/workers/completeness-calculator-worker.js +0 -208
  54. package/es/calculator/workers/dashboard-calculator-worker.js +0 -68
  55. package/es/calculator/workers/mirror-calculator-worker.js +0 -152
  56. package/es/calculator/workers/pivot-table-calculator-worker.js +0 -718
  57. package/es/calculator/workers/scatter-calculator-worker.js +0 -80
  58. package/es/calculator/workers/trend-calculator-worker.js +0 -108
  59. package/es/calculator/world-map-calculator.js +0 -124
  60. package/es/components/common-add-tool.js +0 -28
  61. package/es/components/dialog/chart-addition-edit-dialog.js +0 -90
  62. package/es/components/dialog/chart-addition-widgets/chart-selector.js +0 -259
  63. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +0 -83
  64. package/es/components/dialog/statistic-types-dialog/index.css +0 -14
  65. package/es/components/dialog/statistic-types-dialog/index.js +0 -62
  66. package/es/components/dtable-popover.js +0 -97
  67. package/es/components/dtable-search-input.js +0 -135
  68. package/es/components/index.js +0 -55
  69. package/es/components/loading.js +0 -15
  70. package/es/components/modal-portal.js +0 -26
  71. package/es/components/popover/color-rules/color-rule.js +0 -183
  72. package/es/components/popover/color-rules/index.js +0 -87
  73. package/es/components/popover/color-rules/rule-filters/filter.js +0 -221
  74. package/es/components/popover/color-rules/rule-filters/index.css +0 -210
  75. package/es/components/popover/color-rules/rule-filters/index.js +0 -97
  76. package/es/components/popover/color-rules/rule-filters/number-input.js +0 -78
  77. package/es/components/popover/color-rules-popover.js +0 -217
  78. package/es/components/popover/color-selector-popover.js +0 -82
  79. package/es/components/seatable-radio/index.css +0 -51
  80. package/es/components/seatable-radio/index.js +0 -35
  81. package/es/constants/color-rules.js +0 -17
  82. package/es/constants/map.js +0 -13
  83. package/es/constants/model.js +0 -26
  84. package/es/constants/regions.js +0 -2111
  85. package/es/constants/zIndexes.js +0 -7
  86. package/es/custom-g2.js +0 -644
  87. package/es/model/bar-group.js +0 -58
  88. package/es/model/bar.js +0 -47
  89. package/es/model/base-model.js +0 -18
  90. package/es/model/basic-number-card.js +0 -25
  91. package/es/model/combination.js +0 -48
  92. package/es/model/compare-bar.js +0 -56
  93. package/es/model/completeness-group.js +0 -31
  94. package/es/model/completeness.js +0 -25
  95. package/es/model/custom-bar.js +0 -25
  96. package/es/model/dashboard.js +0 -20
  97. package/es/model/generic-model.js +0 -222
  98. package/es/model/heat-map.js +0 -33
  99. package/es/model/horizontal-bar-group.js +0 -55
  100. package/es/model/horizontal-bar.js +0 -47
  101. package/es/model/index.js +0 -187
  102. package/es/model/map.js +0 -38
  103. package/es/model/mirror.js +0 -33
  104. package/es/model/pie.js +0 -38
  105. package/es/model/ring.js +0 -40
  106. package/es/model/scatter.js +0 -22
  107. package/es/model/table.js +0 -32
  108. package/es/model/trend.js +0 -32
  109. package/es/model/world-map.js +0 -34
  110. package/es/service/map-json.js +0 -140
  111. package/es/stat-editor/chart-name-editor.js +0 -68
  112. package/es/stat-editor/index.js +0 -75
  113. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +0 -153
  114. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +0 -422
  115. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +0 -203
  116. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +0 -23
  117. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +0 -104
  118. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +0 -334
  119. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +0 -119
  120. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +0 -132
  121. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +0 -240
  122. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +0 -89
  123. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +0 -138
  124. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +0 -331
  125. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +0 -143
  126. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +0 -109
  127. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +0 -153
  128. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +0 -144
  129. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +0 -214
  130. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +0 -121
  131. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +0 -172
  132. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +0 -366
  133. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +0 -142
  134. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +0 -150
  135. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +0 -473
  136. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +0 -182
  137. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +0 -564
  138. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +0 -112
  139. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +0 -87
  140. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +0 -187
  141. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +0 -300
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +0 -113
  143. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +0 -289
  144. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +0 -58
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +0 -359
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +0 -48
  147. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +0 -121
  148. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +0 -143
  149. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +0 -269
  150. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +0 -104
  151. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +0 -366
  152. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +0 -55
  153. package/es/stat-editor/stat-settings/color-setting/color-picker.js +0 -130
  154. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +0 -374
  155. package/es/stat-editor/stat-settings/map/map-level.js +0 -72
  156. package/es/stat-editor/stat-settings/map/map-province-city.js +0 -151
  157. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +0 -108
  158. package/es/stat-editor/stat-settings/public-setting/base-settings.js +0 -154
  159. package/es/stat-editor/stat-settings/public-setting/calender.js +0 -125
  160. package/es/stat-editor/stat-settings/public-setting/column-settings.js +0 -24
  161. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +0 -62
  162. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +0 -61
  163. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +0 -35
  164. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +0 -60
  165. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +0 -123
  166. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +0 -33
  167. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +0 -29
  168. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +0 -82
  169. package/es/stat-view/area-chart.js +0 -551
  170. package/es/stat-view/bar-chart.js +0 -582
  171. package/es/stat-view/base-chart.js +0 -132
  172. package/es/stat-view/basic-number-card.js +0 -201
  173. package/es/stat-view/combination-chart.js +0 -546
  174. package/es/stat-view/compare-chart.js +0 -483
  175. package/es/stat-view/completeness-chart.js +0 -390
  176. package/es/stat-view/custom-bar.js +0 -418
  177. package/es/stat-view/dashboard-chart.js +0 -266
  178. package/es/stat-view/heat-map.js +0 -463
  179. package/es/stat-view/horizontal-bar-chart.js +0 -562
  180. package/es/stat-view/line-chart.js +0 -518
  181. package/es/stat-view/map.js +0 -448
  182. package/es/stat-view/mirror.js +0 -275
  183. package/es/stat-view/pie-chart.js +0 -290
  184. package/es/stat-view/pivot-table/index.js +0 -196
  185. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +0 -156
  186. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +0 -176
  187. package/es/stat-view/pivot-table/pivot-table-display-name.js +0 -215
  188. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +0 -132
  189. package/es/stat-view/pivot-table/two-dimension-table.js +0 -384
  190. package/es/stat-view/ring-chart.js +0 -392
  191. package/es/stat-view/scatter-chart.js +0 -306
  192. package/es/stat-view/treemap-chart.js +0 -253
  193. package/es/stat-view/trend-chart.js +0 -249
  194. package/es/stat-view/world-map.js +0 -431
  195. package/es/utils/basic-chart-utils.js +0 -29
  196. package/es/utils/cell-format.js +0 -115
  197. package/es/utils/collaborator.js +0 -50
  198. package/es/utils/color-utils.js +0 -134
  199. package/es/utils/column-utils.js +0 -110
  200. package/es/utils/column.js +0 -20
  201. package/es/utils/date-format.js +0 -71
  202. package/es/utils/map.js +0 -114
  203. package/es/utils/model.js +0 -19
  204. package/es/utils/row-utils.js +0 -134
  205. package/es/utils/search.js +0 -73
  206. package/es/utils/sql-utils.js +0 -359
  207. package/es/utils/stat-utils.js +0 -351
  208. package/es/utils/trend-utils.js +0 -135
@@ -1,392 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
11
- var _dtableUtils = require("dtable-utils");
12
- var _baseChart = _interopRequireDefault(require("./base-chart"));
13
- var _customG = require("../custom-g2");
14
- var _commonUtils = require("../utils/common-utils");
15
- var _constants = require("../constants");
16
- var _statisticChartModule = _interopRequireDefault(require("../assets/css/statistic-chart.module.css"));
17
- const propTypes = {
18
- isPreview: _propTypes.default.bool,
19
- colorThemeName: _propTypes.default.string,
20
- statItem: _propTypes.default.object,
21
- chartCalculator: _propTypes.default.object,
22
- toggleStatisticRecordsDialog: _propTypes.default.func
23
- };
24
- class RingChart extends _baseChart.default {
25
- constructor(props) {
26
- super(props);
27
- this.drawChart = data => {
28
- const {
29
- isPreview,
30
- statItem
31
- } = this.props;
32
- if (isPreview) {
33
- this.chart = new _customG.Chart({
34
- container: this.container,
35
- autoFit: true,
36
- padding: [20, 0]
37
- });
38
- } else {
39
- this.chart = new _customG.Chart({
40
- container: this.container,
41
- autoFit: true,
42
- height: 400,
43
- width: 700
44
- });
45
- }
46
- this.chart.on('element:click', e => {
47
- const clickData = e.data.data;
48
- if (clickData.name !== 'Others') {
49
- this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
50
- }
51
- });
52
- this.drawRingChart(data, !isPreview);
53
- this.chart.render();
54
- };
55
- this.drawRingChart = (data, isCreating) => {
56
- this.sum = data.total;
57
- if (data.length === 0) return;
58
- let {
59
- getTableById,
60
- statItem,
61
- colorThemeName
62
- } = this.props;
63
- let summaryColumn = null;
64
- let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
65
- const {
66
- summary_type,
67
- summary_method,
68
- summary_column_key,
69
- table_id,
70
- show_legend,
71
- show_percent,
72
- display_label,
73
- label_position,
74
- display_annotation
75
- } = statItem;
76
- const table = getTableById(table_id);
77
- if (summary_type !== _constants.SUMMARY_TYPE.COUNT) {
78
- summaryColumn = summary_column_key && (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
79
- summaryColumnData = summaryColumn && summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
80
- }
81
- this.chart.coordinate('theta', {
82
- radius: isCreating ? 0.75 : 0.95,
83
- innerRadius: isCreating ? 0.6 : 0.7
84
- });
85
- const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
86
- const themeColors = this.getThemeColors();
87
- const newData = (0, _commonUtils.formatPieChartData)(data, statItem, table, currentTheme);
88
- this.chart.data(newData, {
89
- 'name': {
90
- type: 'cat',
91
- nice: false
92
- }
93
- });
94
- const colorSet = newData.colorSet;
95
- this.sum = newData.total;
96
- if (show_legend) {
97
- this.chart.legend('name', {
98
- position: 'right',
99
- custom: true,
100
- pageNavigator: {
101
- text: {
102
- style: {
103
- fill: themeColors.textColor
104
- }
105
- },
106
- marker: {
107
- style: {
108
- fill: themeColors.legendPageNavigatorMarkerColor,
109
- inactiveFill: themeColors.legendPageNavigatorMarkerColor,
110
- inactiveOpacity: 0.45
111
- }
112
- }
113
- },
114
- itemName: {
115
- style: {
116
- fill: themeColors.textColor
117
- }
118
- },
119
- items: newData.map((obj, index) => {
120
- const sIndex = String(index);
121
- const colorIndex = sIndex.charAt(sIndex.length - 1);
122
- let name = obj.name;
123
- if (!obj.name && typeof obj.name !== 'number') {
124
- name = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
125
- } else if (obj.name === 'Others') {
126
- name = _reactIntlUniversal.default.get('Others');
127
- }
128
- return {
129
- name,
130
- value: obj.value,
131
- marker: {
132
- symbol: 'circle',
133
- style: {
134
- r: 5,
135
- fill: colorSet[colorIndex]
136
- }
137
- }
138
- };
139
- })
140
- });
141
- } else {
142
- this.chart.legend(false);
143
- }
144
-
145
- // Do not automatically adjust the maximum and minimum values in ring chart
146
- this.chart.scale({
147
- value: {
148
- nice: false
149
- }
150
- });
151
- this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('formatted_value*percent', (value, percent) => {
152
- return {
153
- content: this.getLabel(value, percent)
154
- };
155
- }, {
156
- offset: !label_position || label_position === _constants.LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
157
- style: {
158
- fill: themeColors.labelColor,
159
- fontSize: this.getLabelFontSize(),
160
- shadowBlur: 2,
161
- shadowColor: 'rgba(0, 0, 0, .45)'
162
- }
163
- }).tooltip('name*formatted_value*percent', (name, value, percent) => {
164
- let title = name;
165
- if (!name || name === 'undefined') {
166
- title = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
167
- }
168
- return show_percent || display_label ? {
169
- name: title,
170
- value: this.getLabel(value, percent)
171
- } : {
172
- name: title,
173
- value
174
- };
175
- }).state({
176
- active: {
177
- style: {
178
- fillOpacity: 0.7,
179
- border: 'none',
180
- stroke: 0
181
- }
182
- }
183
- });
184
- this.chart.tooltip({
185
- showTitle: false,
186
- showMarkers: false,
187
- itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
188
- });
189
- this.chart.interaction('element-active');
190
- if (display_annotation === undefined || display_annotation === null || display_annotation) {
191
- this.setAnnotation({
192
- name: _reactIntlUniversal.default.get(_constants.TITLE_TOTAL),
193
- value: summaryColumn ? this.getNumberDisplayString(this.sum, summaryColumnData, summary_method) : this.sum
194
- }, themeColors.labelColor);
195
- this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, themeColors.labelColor, summaryColumn, summaryColumnData));
196
- this.chart.on('interval:mouseleave', evt => this.onLeaveRingChart(evt, themeColors.labelColor, summaryColumn, summaryColumnData));
197
- }
198
- };
199
- this.getLabel = (value, percent) => {
200
- const {
201
- show_percent,
202
- display_label,
203
- label_format
204
- } = this.props.statItem;
205
- let content;
206
- if (show_percent) {
207
- content = percent;
208
- return content;
209
- } else {
210
- if (!display_label) {
211
- content = '';
212
- return content;
213
- }
214
- }
215
- switch (label_format) {
216
- case _constants.LABEL_FORMATS[0]:
217
- content = percent;
218
- break;
219
- case _constants.LABEL_FORMATS[1]:
220
- content = value;
221
- break;
222
- case _constants.LABEL_FORMATS[2]:
223
- content = "".concat(value, " (").concat(percent, ")");
224
- break;
225
- default:
226
- content = percent;
227
- }
228
- return content;
229
- };
230
- this.getAnnotationFontSize = () => {
231
- const {
232
- statItem
233
- } = this.props;
234
- const {
235
- annotation_font_size
236
- } = statItem;
237
- const mainFontSize = annotation_font_size || _constants.DEFAULT_ANNOTATION_SIZE;
238
- const subFontSize = Math.max(mainFontSize - 12, 12);
239
- return {
240
- mainFontSize,
241
- subFontSize
242
- };
243
- };
244
- this.setAnnotation = (content, fontColor, summaryColumn, summaryColumnData) => {
245
- const {
246
- summary_method
247
- } = this.props.statItem;
248
- let name = content.name;
249
- if (!name || name === 'undefined') {
250
- name = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
251
- } else if (name === 'Others') {
252
- name = _reactIntlUniversal.default.get('Others');
253
- }
254
- const {
255
- mainFontSize,
256
- subFontSize
257
- } = this.getAnnotationFontSize();
258
- this.chart.annotation().text({
259
- content: name,
260
- position: ['50%', '50%'],
261
- style: {
262
- fontSize: subFontSize,
263
- fill: fontColor,
264
- fontWeight: '300',
265
- textAlign: 'center'
266
- },
267
- offsetY: -20
268
- }).text({
269
- position: ['50%', '50%'],
270
- content: summaryColumn ? this.getNumberDisplayString(content.value, summaryColumnData, summary_method) : content.value,
271
- style: {
272
- fontSize: mainFontSize,
273
- fill: fontColor,
274
- textAlign: 'center'
275
- },
276
- offsetY: 20
277
- });
278
- };
279
- this.onEnterRingChart = (ev, color, summaryColumn, summaryColumnData) => {
280
- const item = ev.data.data;
281
- this.chart.annotation().clear(true);
282
- this.setAnnotation(item, color, summaryColumn, summaryColumnData);
283
- this.chart.render(true);
284
- };
285
- this.onLeaveRingChart = (ev, color, summaryColumn, summaryColumnData) => {
286
- this.chart.annotation().clear(true);
287
- this.setAnnotation({
288
- name: _reactIntlUniversal.default.get(_constants.TITLE_TOTAL),
289
- value: this.sum
290
- }, color, summaryColumn, summaryColumnData);
291
- this.chart.render(true);
292
- };
293
- this.destroyChart = () => {
294
- this.chart.destroy();
295
- this.chart = null;
296
- };
297
- this.state = {
298
- isCalculatingData: true,
299
- showResultDescription: true
300
- };
301
- this.calculateData = null;
302
- }
303
- componentDidMount() {
304
- const {
305
- statItem,
306
- chartCalculator
307
- } = this.props;
308
- if (this.container) {
309
- chartCalculator.calculate(statItem).then(data => {
310
- const showResultDescription = data.length > 0 ? false : true;
311
- this.setState({
312
- isCalculatingData: false,
313
- showResultDescription
314
- }, () => {
315
- if (!showResultDescription) {
316
- this.drawChart(data);
317
- this.calculateData = data;
318
- }
319
- });
320
- });
321
- }
322
- }
323
- shouldComponentUpdate(nextProps, nextState) {
324
- const {
325
- colorThemeName
326
- } = this.props;
327
- if (this.canUpdate(this.props, nextProps)) {
328
- return true;
329
- }
330
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
331
- return true;
332
- }
333
- if (nextProps.colorThemeName !== colorThemeName) {
334
- return true;
335
- }
336
- return false;
337
- }
338
- componentDidUpdate(preProps, preState) {
339
- const {
340
- statItem,
341
- chartCalculator
342
- } = this.props;
343
- const {
344
- isCalculatingData
345
- } = this.state;
346
- if (isCalculatingData !== preState.isCalculatingData) return;
347
- if (this.shouldCalculateStatItem(preProps, this.props)) {
348
- this.setState({
349
- isCalculatingData: true
350
- });
351
- if (this.container) {
352
- chartCalculator.calculate(statItem).then(data => {
353
- const showResultDescription = data.length > 0 ? false : true;
354
- this.chart && this.destroyChart();
355
- this.calculateData = data;
356
- this.setState({
357
- isCalculatingData: false,
358
- showResultDescription
359
- }, () => {
360
- if (!showResultDescription) {
361
- this.drawChart(data);
362
- if (this.props.isPreview) this.chart.forceFit();
363
- }
364
- });
365
- });
366
- }
367
- } else {
368
- if (!this.state.showResultDescription) {
369
- this.chart && this.destroyChart();
370
- this.drawChart(this.calculateData);
371
- if (this.props.isPreview) {
372
- this.chart.forceFit();
373
- }
374
- }
375
- }
376
- }
377
- componentWillUnmount() {
378
- this.container = null;
379
- }
380
- render() {
381
- const {
382
- isCalculatingData,
383
- showResultDescription
384
- } = this.state;
385
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/_react.default.createElement("div", {
386
- ref: ref => this.container = ref,
387
- className: "".concat(_statisticChartModule.default['statistic-pie-chart-container'], " statistic-chart-container")
388
- }));
389
- }
390
- }
391
- RingChart.propTypes = propTypes;
392
- var _default = exports.default = RingChart;
@@ -1,306 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
11
- var _dtableUtils = require("dtable-utils");
12
- var _baseChart = _interopRequireDefault(require("./base-chart"));
13
- var _customG = require("../custom-g2");
14
- var _commonUtils = require("../utils/common-utils");
15
- var _constants = require("../constants");
16
- var _statisticChartModule = _interopRequireDefault(require("../assets/css/statistic-chart.module.css"));
17
- const propTypes = {
18
- isPreview: _propTypes.default.bool,
19
- colorThemeName: _propTypes.default.string,
20
- statItem: _propTypes.default.object,
21
- chartCalculator: _propTypes.default.object,
22
- eventBus: _propTypes.default.object,
23
- getTableById: _propTypes.default.func,
24
- toggleStatisticRecordsDialog: _propTypes.default.func
25
- };
26
- class ScatterChart extends _baseChart.default {
27
- constructor(props) {
28
- super(props);
29
- this.drawChart = data => {
30
- const {
31
- getTableById,
32
- isPreview,
33
- statItem,
34
- colorThemeName
35
- } = this.props;
36
- const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
37
- const {
38
- table_id,
39
- x_axis_column,
40
- y_axis_column
41
- } = statItem;
42
- const selectedTable = getTableById(table_id);
43
- const selectedXAxisColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column);
44
- const selectedYAxisColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, y_axis_column);
45
- if (isPreview) {
46
- this.chart = new _customG.Chart({
47
- container: this.container,
48
- autoFit: true
49
- });
50
- } else {
51
- this.chart = new _customG.Chart({
52
- container: this.container,
53
- height: 400,
54
- width: 700
55
- });
56
- }
57
- this.chart.on('element:click', e => {
58
- this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
59
- });
60
- const themeColors = this.getThemeColors();
61
- this.chart.axis('x_axis', {
62
- label: {
63
- style: {
64
- fill: themeColors.textColor
65
- }
66
- },
67
- line: {
68
- style: themeColors.gridColor
69
- }
70
- });
71
- this.chart.axis('y_axis', {
72
- grid: {
73
- line: {
74
- style: {
75
- stroke: themeColors.gridColor
76
- }
77
- }
78
- },
79
- label: {
80
- style: {
81
- fill: themeColors.textColor
82
- }
83
- }
84
- });
85
- const chart = this.chart;
86
- chart.data(data);
87
- chart.scale({
88
- x_axis: {
89
- nice: true
90
- },
91
- y_axis: {
92
- nice: true
93
- }
94
- });
95
- chart.tooltip({
96
- showTitle: false,
97
- showCrosshairs: true,
98
- crosshairs: {
99
- type: 'xy'
100
- },
101
- 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>'
102
- });
103
- chart.point().position('x_axis*y_axis').color('group_by', currentTheme && currentTheme.colors).shape('circle').tooltip('group_by*x_axis*y_axis', (group_by, x_axis, y_axis) => {
104
- return {
105
- name: group_by || group_by === 0 ? group_by : _reactIntlUniversal.default.get(_constants.EMPTY_NAME),
106
- valueX: "".concat(selectedXAxisColumn.name, ": ").concat(x_axis),
107
- valueY: "".concat(selectedYAxisColumn.name, ": ").concat(y_axis)
108
- };
109
- }).style({
110
- fillOpacity: 0.85
111
- });
112
- chart.legend('group_by', {
113
- position: 'bottom',
114
- itemName: {
115
- formatter: name => {
116
- return name || name === 0 ? name : _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
117
- },
118
- style: {
119
- fill: themeColors.textColor
120
- }
121
- },
122
- pageNavigator: {
123
- text: {
124
- style: {
125
- fill: themeColors.textColor
126
- }
127
- },
128
- marker: {
129
- style: {
130
- fill: themeColors.legendPageNavigatorMarkerColor,
131
- inactiveFill: themeColors.legendPageNavigatorMarkerColor,
132
- inactiveOpacity: 0.45
133
- }
134
- }
135
- }
136
- });
137
- chart.interaction('legend-highlight');
138
- chart.render();
139
- this.renderAxisLabel();
140
- };
141
- this.renderAxisLabel = newStatItem => {
142
- let {
143
- getTableById,
144
- statItem
145
- } = this.props;
146
- if (newStatItem && newStatItem._id !== statItem._id) {
147
- return;
148
- }
149
- if (!this.chart) return;
150
- statItem = newStatItem || statItem;
151
- const {
152
- table_id,
153
- x_axis_column,
154
- y_axis_column,
155
- show_y_axis_label,
156
- show_x_axis_label,
157
- y_axis_label_position,
158
- x_axis_label_position
159
- } = statItem;
160
- const table = getTableById(table_id);
161
- const autoPadding = this.chart.autoPadding;
162
- const textColor = this.getAxisLabelColor();
163
- const xAxisID = "chart-x-axis-label_".concat(statItem._id);
164
- const chartContainer = this.chart.getCanvas().get('container');
165
- const xLabel = chartContainer.querySelector("#".concat(xAxisID));
166
- if (!xLabel && show_x_axis_label) {
167
- const div = document.createElement('div');
168
- div.id = xAxisID;
169
- div.className = 'statistic-chart-axis-label';
170
- const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column);
171
- div.innerHTML = "".concat(column ? column.name : '');
172
- div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
173
- chartContainer.appendChild(div);
174
- }
175
- if (xLabel && show_x_axis_label) {
176
- xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
177
- }
178
- if (xLabel && !show_x_axis_label) {
179
- xLabel.parentNode.removeChild(xLabel);
180
- }
181
- const yAxisID = "chart-y-axis-label_".concat(statItem._id);
182
- const yLabel = chartContainer.querySelector("#".concat(yAxisID));
183
- let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
184
- if (!yLabel && show_y_axis_label) {
185
- const div = document.createElement('div');
186
- div.id = yAxisID;
187
- div.className = 'statistic-chart-axis-label';
188
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column) || {};
189
- div.innerHTML = column.name || '';
190
- const containerHeight = chartContainer.offsetHeight;
191
- let textAlign = 'center';
192
- if (y_axis_label_position === 'bottom') textAlign = 'left';
193
- if (y_axis_label_position === 'top') textAlign = 'right';
194
- 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)"));
195
- chartContainer.appendChild(div);
196
- }
197
- if (yLabel && show_y_axis_label) {
198
- const containerHeight = chartContainer.offsetHeight;
199
- let textAlign = 'center';
200
- if (y_axis_label_position === 'bottom') textAlign = 'left';
201
- if (y_axis_label_position === 'top') textAlign = 'right';
202
- 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)"));
203
- }
204
- if (yLabel && !show_y_axis_label) {
205
- yLabel.parentNode.removeChild(yLabel);
206
- }
207
- };
208
- this.state = {
209
- isCalculatingData: true
210
- };
211
- this.calculateData = null;
212
- }
213
- async componentDidMount() {
214
- const {
215
- statItem,
216
- chartCalculator,
217
- eventBus
218
- } = this.props;
219
- if (this.container) {
220
- const data = await chartCalculator.calculate(statItem);
221
- this.setState({
222
- isCalculatingData: false
223
- });
224
- this.drawChart(data);
225
- this.calculateData = data;
226
- }
227
- this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
228
- this.renderAxisLabel(newStatItem);
229
- });
230
- }
231
- shouldComponentUpdate(nextProps, nextState) {
232
- const {
233
- colorThemeName
234
- } = this.props;
235
- if (this.canUpdate(this.props, nextProps)) {
236
- return true;
237
- }
238
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
239
- return true;
240
- }
241
- if (nextProps.colorThemeName !== colorThemeName) {
242
- return true;
243
- }
244
- return false;
245
- }
246
- async componentDidUpdate(preProps, preState) {
247
- const {
248
- statItem,
249
- chartCalculator
250
- } = this.props;
251
- const {
252
- isCalculatingData
253
- } = this.state;
254
- if (isCalculatingData !== preState.isCalculatingData) return;
255
- if (this.shouldCalculateStatItem(preProps, this.props)) {
256
- if (this.container) {
257
- this.setState({
258
- isCalculatingData: true
259
- });
260
- const data = await chartCalculator.calculate(statItem);
261
- this.calculateData = data;
262
- this.setState({
263
- isCalculatingData: false
264
- });
265
- this.chart && this.chart.destroy();
266
- this.drawChart(data);
267
- if (this.props.isPreview) {
268
- this.chart.forceFit();
269
- }
270
- }
271
- } else {
272
- this.chart && this.chart.destroy();
273
- this.drawChart(this.calculateData);
274
- if (this.props.isPreview) {
275
- this.chart.forceFit();
276
- }
277
- }
278
- }
279
- componentWillUnmount() {
280
- this.container = null;
281
- this.unsubscribeStyleChange && this.unsubscribeStyleChange();
282
- }
283
- render() {
284
- const {
285
- isCalculatingData
286
- } = this.state;
287
- const {
288
- show_x_axis_label,
289
- show_y_axis_label
290
- } = this.props.statItem;
291
- const style = {};
292
- if (show_x_axis_label) {
293
- style.paddingBottom = 38;
294
- }
295
- if (show_y_axis_label) {
296
- style.paddingLeft = 38;
297
- }
298
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
299
- ref: ref => this.container = ref,
300
- className: "".concat(_statisticChartModule.default['statistic-scatter-chart-container'], " statistic-chart-container"),
301
- style: style
302
- }));
303
- }
304
- }
305
- ScatterChart.propTypes = propTypes;
306
- var _default = exports.default = ScatterChart;