dtable-statistic 4.3.1 → 4.3.3

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 (222) hide show
  1. package/es/api/dtable-db-api.js +10 -3
  2. package/es/calculator/base-calculator.js +20 -12
  3. package/es/calculator/basic-chart-calculator.js +72 -65
  4. package/es/calculator/combination-calculator.js +64 -57
  5. package/es/calculator/compare-bar-calculator.js +33 -26
  6. package/es/calculator/completeness-calculator.js +37 -30
  7. package/es/calculator/copy-value.js +7 -1
  8. package/es/calculator/dashboard-calculator.js +20 -13
  9. package/es/calculator/heat-map-calculator.js +25 -18
  10. package/es/calculator/horizontal-bar-calculator.js +15 -8
  11. package/es/calculator/index.js +42 -35
  12. package/es/calculator/map-calculator.js +29 -22
  13. package/es/calculator/mirror-calculator.js +27 -20
  14. package/es/calculator/number-card-calculator.js +17 -10
  15. package/es/calculator/pivot-table-calculator.js +65 -58
  16. package/es/calculator/scatter-calculator.js +21 -14
  17. package/es/calculator/thread-manager.js +7 -1
  18. package/es/calculator/trend-calculator.js +29 -22
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
  20. package/es/calculator/workers/calculator.worker.js +33 -30
  21. package/es/calculator/workers/card-calculator-worker.js +19 -13
  22. package/es/calculator/workers/combination-calculator-worker.js +53 -46
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
  24. package/es/calculator/workers/completeness-calculator-worker.js +41 -34
  25. package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
  26. package/es/calculator/workers/mirror-calculator-worker.js +29 -22
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
  28. package/es/calculator/workers/scatter-calculator-worker.js +27 -20
  29. package/es/calculator/workers/trend-calculator-worker.js +34 -27
  30. package/es/calculator/world-map-calculator.js +24 -17
  31. package/es/components/common-add-tool.js +12 -5
  32. package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +110 -103
  34. package/es/components/dialog/color-theme-dialog.js +22 -15
  35. package/es/components/dialog/delete-confirmation-dialog.js +18 -11
  36. package/es/components/dialog/enlarged-chart-dialog.js +28 -20
  37. package/es/components/dialog/new-table-dialog.js +23 -16
  38. package/es/components/dialog/new-view-dialog.js +22 -15
  39. package/es/components/dialog/rename-view-dialog.js +22 -14
  40. package/es/components/dialog/statistic-record-dialog/index.js +45 -37
  41. package/es/components/dialog/statistic-types-dialog/index.js +22 -14
  42. package/es/components/dialog/table-select-dialog.js +23 -15
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +56 -43
  44. package/es/components/dtable-popover.js +19 -12
  45. package/es/components/dtable-search-input.js +21 -13
  46. package/es/components/dtable-select.js +20 -12
  47. package/es/components/icon.js +11 -4
  48. package/es/components/index.js +76 -11
  49. package/es/components/loading.js +10 -3
  50. package/es/components/modal-portal.js +12 -5
  51. package/es/components/popover/color-rules/color-rule.js +33 -25
  52. package/es/components/popover/color-rules/index.js +14 -6
  53. package/es/components/popover/color-rules/rule-filters/filter.js +35 -28
  54. package/es/components/popover/color-rules/rule-filters/index.js +25 -17
  55. package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
  56. package/es/components/popover/color-rules-popover.js +32 -24
  57. package/es/components/popover/color-selector-popover.js +17 -10
  58. package/es/components/seatable-radio/index.js +16 -9
  59. package/es/components/select/index.js +9 -2
  60. package/es/components/select/option-group.js +27 -19
  61. package/es/components/select/option.js +14 -6
  62. package/es/components/select/select.js +25 -17
  63. package/es/components/toast/alert.js +31 -24
  64. package/es/components/toast/index.js +10 -3
  65. package/es/components/toast/toast.js +20 -12
  66. package/es/components/toast/toastManager.js +17 -9
  67. package/es/components/toast/toaster.js +14 -6
  68. package/es/constants/color-rules.js +12 -6
  69. package/es/constants/dtable-select-style.js +9 -4
  70. package/es/constants/event-types.js +10 -4
  71. package/es/constants/index.js +96 -67
  72. package/es/constants/key-codes.js +2 -0
  73. package/es/constants/map.js +8 -2
  74. package/es/constants/model.js +26 -20
  75. package/es/constants/regions.js +8 -3
  76. package/es/constants/zIndexes.js +7 -1
  77. package/es/custom-g2.js +236 -208
  78. package/es/dashboard.js +58 -50
  79. package/es/desktop-dashboard.js +55 -47
  80. package/es/index.js +6 -3
  81. package/es/locale/index.js +13 -10
  82. package/es/locale/lang/de.js +7 -1
  83. package/es/locale/lang/en.js +7 -1
  84. package/es/locale/lang/fr.js +7 -1
  85. package/es/locale/lang/zh_CN.js +7 -1
  86. package/es/mobile-dashboard.js +46 -38
  87. package/es/model/bar-group.js +19 -11
  88. package/es/model/bar.js +18 -10
  89. package/es/model/base-model.js +9 -2
  90. package/es/model/basic-number-card.js +16 -8
  91. package/es/model/collaborators.js +9 -2
  92. package/es/model/combination.js +20 -12
  93. package/es/model/compare-bar.js +24 -16
  94. package/es/model/completeness-group.js +16 -8
  95. package/es/model/completeness.js +13 -5
  96. package/es/model/custom-bar.js +14 -6
  97. package/es/model/dashboard.js +14 -6
  98. package/es/model/generic-model.js +141 -133
  99. package/es/model/heat-map.js +19 -11
  100. package/es/model/horizontal-bar-group.js +18 -10
  101. package/es/model/horizontal-bar.js +18 -10
  102. package/es/model/index.js +185 -53
  103. package/es/model/map.js +23 -15
  104. package/es/model/mirror.js +21 -13
  105. package/es/model/pie.js +18 -10
  106. package/es/model/ring.js +19 -11
  107. package/es/model/scatter.js +14 -6
  108. package/es/model/statistic-dashboard.js +9 -2
  109. package/es/model/table.js +18 -10
  110. package/es/model/trend.js +20 -12
  111. package/es/model/world-map.js +21 -13
  112. package/es/service/chart-service.js +14 -7
  113. package/es/service/dashboard-service.js +42 -35
  114. package/es/service/map-json.js +14 -8
  115. package/es/stat-editor/chart-name-editor.js +15 -8
  116. package/es/stat-editor/index.js +24 -16
  117. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +30 -22
  118. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
  119. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +32 -24
  120. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
  121. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
  122. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
  123. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
  124. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
  125. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +48 -40
  126. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +29 -21
  127. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
  128. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
  129. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
  130. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
  131. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
  132. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
  133. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
  134. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
  135. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +25 -17
  136. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
  137. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
  138. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
  139. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
  140. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
  141. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
  142. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
  143. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
  144. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +59 -51
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +27 -19
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +57 -49
  148. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +20 -12
  149. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +56 -48
  150. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
  151. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +29 -21
  152. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
  153. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
  154. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
  155. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +56 -47
  156. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +20 -12
  157. package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
  158. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
  159. package/es/stat-editor/stat-settings/map/map-level.js +20 -13
  160. package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
  161. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
  162. package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
  163. package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
  164. package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
  165. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
  166. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
  167. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
  168. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
  169. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
  170. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
  171. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
  172. package/es/stat-list/chart-preview.js +33 -20
  173. package/es/stat-list/index.js +36 -28
  174. package/es/stat-view/area-chart.js +51 -44
  175. package/es/stat-view/bar-chart.js +55 -48
  176. package/es/stat-view/base-chart.js +32 -24
  177. package/es/stat-view/basic-number-card.js +26 -19
  178. package/es/stat-view/combination-chart.js +57 -50
  179. package/es/stat-view/compare-chart.js +47 -40
  180. package/es/stat-view/completeness-chart.js +37 -30
  181. package/es/stat-view/custom-bar.js +38 -31
  182. package/es/stat-view/dashboard-chart.js +22 -15
  183. package/es/stat-view/heat-map.js +50 -43
  184. package/es/stat-view/horizontal-bar-chart.js +59 -52
  185. package/es/stat-view/index.js +80 -73
  186. package/es/stat-view/line-chart.js +47 -40
  187. package/es/stat-view/map.js +40 -33
  188. package/es/stat-view/mirror.js +28 -21
  189. package/es/stat-view/pie-chart.js +36 -29
  190. package/es/stat-view/pivot-table/index.js +39 -32
  191. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
  192. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
  193. package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
  194. package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
  195. package/es/stat-view/ring-chart.js +46 -39
  196. package/es/stat-view/scatter-chart.js +37 -30
  197. package/es/stat-view/treemap-chart.js +45 -38
  198. package/es/stat-view/trend-chart.js +39 -32
  199. package/es/stat-view/world-map.js +40 -33
  200. package/es/tabs/index.js +40 -32
  201. package/es/tabs/tab.js +35 -27
  202. package/es/utils/basic-chart-utils.js +9 -2
  203. package/es/utils/cell-format.js +22 -14
  204. package/es/utils/cell-value.js +14 -7
  205. package/es/utils/collaborator.js +13 -4
  206. package/es/utils/color-utils.js +29 -18
  207. package/es/utils/column-utils.js +29 -18
  208. package/es/utils/column.js +11 -4
  209. package/es/utils/common-utils.js +67 -43
  210. package/es/utils/date-format.js +8 -2
  211. package/es/utils/export-table-utils.js +91 -82
  212. package/es/utils/index.js +100 -11
  213. package/es/utils/map.js +36 -26
  214. package/es/utils/model.js +14 -6
  215. package/es/utils/object.js +15 -6
  216. package/es/utils/pivot-table.js +23 -16
  217. package/es/utils/row-utils.js +34 -24
  218. package/es/utils/search.js +29 -21
  219. package/es/utils/sql-utils.js +75 -65
  220. package/es/utils/stat-utils.js +67 -60
  221. package/es/utils/trend-utils.js +40 -32
  222. package/package.json +85 -132
@@ -1,20 +1,27 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import intl from 'react-intl-universal';
4
- import { TableUtils } from 'dtable-store';
5
- import BaseChart from './base-chart';
6
- import { Chart } from '../custom-g2';
7
- import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
8
- import { DEFAULT_ANNOTATION_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS, SUMMARY_TYPE, TITLE_TOTAL } from '../constants';
9
- import chartStyles from '../assets/css/statistic-chart.module.css';
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 _dtableStore = require("dtable-store");
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"));
10
17
  const propTypes = {
11
- isPreview: PropTypes.bool,
12
- colorThemeName: PropTypes.string,
13
- statItem: PropTypes.object,
14
- chartCalculator: PropTypes.object,
15
- toggleStatisticRecordsDialog: PropTypes.func
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
16
23
  };
17
- class RingChart extends BaseChart {
24
+ class RingChart extends _baseChart.default {
18
25
  constructor(props) {
19
26
  super(props);
20
27
  this.drawChart = data => {
@@ -23,13 +30,13 @@ class RingChart extends BaseChart {
23
30
  statItem
24
31
  } = this.props;
25
32
  if (isPreview) {
26
- this.chart = new Chart({
33
+ this.chart = new _customG.Chart({
27
34
  container: this.container,
28
35
  autoFit: true,
29
36
  padding: [20, 0]
30
37
  });
31
38
  } else {
32
- this.chart = new Chart({
39
+ this.chart = new _customG.Chart({
33
40
  container: this.container,
34
41
  autoFit: true,
35
42
  height: 400,
@@ -54,7 +61,7 @@ class RingChart extends BaseChart {
54
61
  colorThemeName
55
62
  } = this.props;
56
63
  let summaryColumn = null;
57
- let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
64
+ let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
58
65
  const {
59
66
  summary_type,
60
67
  summary_method,
@@ -67,17 +74,17 @@ class RingChart extends BaseChart {
67
74
  display_annotation
68
75
  } = statItem;
69
76
  const table = getTableById(table_id);
70
- if (summary_type !== SUMMARY_TYPE.COUNT) {
71
- summaryColumn = summary_column_key && TableUtils.getTableColumnByKey(table, summary_column_key);
72
- summaryColumnData = summaryColumn && summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
77
+ if (summary_type !== _constants.SUMMARY_TYPE.COUNT) {
78
+ summaryColumn = summary_column_key && _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
79
+ summaryColumnData = summaryColumn && summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
73
80
  }
74
81
  this.chart.coordinate('theta', {
75
82
  radius: isCreating ? 0.75 : 0.95,
76
83
  innerRadius: isCreating ? 0.6 : 0.7
77
84
  });
78
- const currentTheme = getCurrentTheme(colorThemeName);
85
+ const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
79
86
  const themeColors = this.getThemeColors();
80
- const newData = formatPieChartData(data, statItem, table, currentTheme);
87
+ const newData = (0, _commonUtils.formatPieChartData)(data, statItem, table, currentTheme);
81
88
  this.chart.data(newData, {
82
89
  'name': {
83
90
  type: 'cat',
@@ -114,9 +121,9 @@ class RingChart extends BaseChart {
114
121
  const colorIndex = sIndex.charAt(sIndex.length - 1);
115
122
  let name = obj.name;
116
123
  if (!obj.name && typeof obj.name !== 'number') {
117
- name = intl.get(EMPTY_NAME);
124
+ name = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
118
125
  } else if (obj.name === 'Others') {
119
- name = intl.get('Others');
126
+ name = _reactIntlUniversal.default.get('Others');
120
127
  }
121
128
  return {
122
129
  name,
@@ -146,7 +153,7 @@ class RingChart extends BaseChart {
146
153
  content: this.getLabel(value, percent)
147
154
  };
148
155
  }, {
149
- offset: !label_position || label_position == LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
156
+ offset: !label_position || label_position === _constants.LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
150
157
  style: {
151
158
  fill: themeColors.labelColor,
152
159
  fontSize: this.getLabelFontSize(),
@@ -156,7 +163,7 @@ class RingChart extends BaseChart {
156
163
  }).tooltip('name*formatted_value*percent', (name, value, percent) => {
157
164
  let title = name;
158
165
  if (!name || name === 'undefined') {
159
- title = intl.get(EMPTY_NAME);
166
+ title = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
160
167
  }
161
168
  return show_percent || display_label ? {
162
169
  name: title,
@@ -180,9 +187,9 @@ class RingChart extends BaseChart {
180
187
  itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
181
188
  });
182
189
  this.chart.interaction('element-active');
183
- if (display_annotation == undefined || display_annotation) {
190
+ if (display_annotation === undefined || display_annotation === null || display_annotation) {
184
191
  this.setAnnotation({
185
- name: intl.get(TITLE_TOTAL),
192
+ name: _reactIntlUniversal.default.get(_constants.TITLE_TOTAL),
186
193
  value: summaryColumn ? this.getNumberDisplayString(this.sum, summaryColumnData, summary_method) : this.sum
187
194
  }, themeColors.labelColor);
188
195
  this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, themeColors.labelColor, summaryColumn, summaryColumnData));
@@ -206,13 +213,13 @@ class RingChart extends BaseChart {
206
213
  }
207
214
  }
208
215
  switch (label_format) {
209
- case LABEL_FORMATS[0]:
216
+ case _constants.LABEL_FORMATS[0]:
210
217
  content = percent;
211
218
  break;
212
- case LABEL_FORMATS[1]:
219
+ case _constants.LABEL_FORMATS[1]:
213
220
  content = value;
214
221
  break;
215
- case LABEL_FORMATS[2]:
222
+ case _constants.LABEL_FORMATS[2]:
216
223
  content = "".concat(value, " (").concat(percent, ")");
217
224
  break;
218
225
  default:
@@ -227,7 +234,7 @@ class RingChart extends BaseChart {
227
234
  const {
228
235
  annotation_font_size
229
236
  } = statItem;
230
- const mainFontSize = annotation_font_size || DEFAULT_ANNOTATION_SIZE;
237
+ const mainFontSize = annotation_font_size || _constants.DEFAULT_ANNOTATION_SIZE;
231
238
  const subFontSize = Math.max(mainFontSize - 12, 12);
232
239
  return {
233
240
  mainFontSize,
@@ -240,9 +247,9 @@ class RingChart extends BaseChart {
240
247
  } = this.props.statItem;
241
248
  let name = content.name;
242
249
  if (!name || name === 'undefined') {
243
- name = intl.get(EMPTY_NAME);
250
+ name = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
244
251
  } else if (name === 'Others') {
245
- name = intl.get('Others');
252
+ name = _reactIntlUniversal.default.get('Others');
246
253
  }
247
254
  const {
248
255
  mainFontSize,
@@ -278,7 +285,7 @@ class RingChart extends BaseChart {
278
285
  this.onLeaveRingChart = (ev, color, summaryColumn, summaryColumnData) => {
279
286
  this.chart.annotation().clear(true);
280
287
  this.setAnnotation({
281
- name: intl.get(TITLE_TOTAL),
288
+ name: _reactIntlUniversal.default.get(_constants.TITLE_TOTAL),
282
289
  value: this.sum
283
290
  }, color, summaryColumn, summaryColumnData);
284
291
  this.chart.render(true);
@@ -375,11 +382,11 @@ class RingChart extends BaseChart {
375
382
  isCalculatingData,
376
383
  showResultDescription
377
384
  } = this.state;
378
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
385
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/_react.default.createElement("div", {
379
386
  ref: ref => this.container = ref,
380
- className: "".concat(chartStyles['statistic-pie-chart-container'], " statistic-chart-container")
387
+ className: "".concat(_statisticChartModule.default['statistic-pie-chart-container'], " statistic-chart-container")
381
388
  }));
382
389
  }
383
390
  }
384
391
  RingChart.propTypes = propTypes;
385
- export default RingChart;
392
+ var _default = exports.default = RingChart;
@@ -1,22 +1,29 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import intl from 'react-intl-universal';
4
- import { TableUtils } from 'dtable-store';
5
- import BaseChart from './base-chart';
6
- import { Chart } from '../custom-g2';
7
- import { getCurrentTheme } from '../utils/common-utils';
8
- import { EMPTY_NAME, LABEL_CONFIG_CHANGED } from '../constants';
9
- import chartStyles from '../assets/css/statistic-chart.module.css';
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 _dtableStore = require("dtable-store");
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"));
10
17
  const propTypes = {
11
- isPreview: PropTypes.bool,
12
- colorThemeName: PropTypes.string,
13
- statItem: PropTypes.object,
14
- chartCalculator: PropTypes.object,
15
- eventBus: PropTypes.object,
16
- getTableById: PropTypes.func,
17
- toggleStatisticRecordsDialog: PropTypes.func
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
18
25
  };
19
- class ScatterChart extends BaseChart {
26
+ class ScatterChart extends _baseChart.default {
20
27
  constructor(props) {
21
28
  super(props);
22
29
  this.componentDidMount = async () => {
@@ -33,7 +40,7 @@ class ScatterChart extends BaseChart {
33
40
  this.drawChart(data);
34
41
  this.calculateData = data;
35
42
  }
36
- this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
43
+ this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
37
44
  this.renderAxisLabel(newStatItem);
38
45
  });
39
46
  };
@@ -77,22 +84,22 @@ class ScatterChart extends BaseChart {
77
84
  statItem,
78
85
  colorThemeName
79
86
  } = this.props;
80
- const currentTheme = getCurrentTheme(colorThemeName);
87
+ const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
81
88
  const {
82
89
  table_id,
83
90
  x_axis_column,
84
91
  y_axis_column
85
92
  } = statItem;
86
93
  const selectedTable = getTableById(table_id);
87
- const selectedXAxisColumn = TableUtils.getTableColumnByKey(selectedTable, x_axis_column);
88
- const selectedYAxisColumn = TableUtils.getTableColumnByKey(selectedTable, y_axis_column);
94
+ const selectedXAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column);
95
+ const selectedYAxisColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, y_axis_column);
89
96
  if (isPreview) {
90
- this.chart = new Chart({
97
+ this.chart = new _customG.Chart({
91
98
  container: this.container,
92
99
  autoFit: true
93
100
  });
94
101
  } else {
95
- this.chart = new Chart({
102
+ this.chart = new _customG.Chart({
96
103
  container: this.container,
97
104
  height: 400,
98
105
  width: 700
@@ -146,7 +153,7 @@ class ScatterChart extends BaseChart {
146
153
  });
147
154
  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) => {
148
155
  return {
149
- name: group_by || group_by === 0 ? group_by : intl.get(EMPTY_NAME),
156
+ name: group_by || group_by === 0 ? group_by : _reactIntlUniversal.default.get(_constants.EMPTY_NAME),
150
157
  valueX: "".concat(selectedXAxisColumn.name, ": ").concat(x_axis),
151
158
  valueY: "".concat(selectedYAxisColumn.name, ": ").concat(y_axis)
152
159
  };
@@ -157,7 +164,7 @@ class ScatterChart extends BaseChart {
157
164
  position: 'bottom',
158
165
  itemName: {
159
166
  formatter: name => {
160
- return name || name === 0 ? name : intl.get(EMPTY_NAME);
167
+ return name || name === 0 ? name : _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
161
168
  },
162
169
  style: {
163
170
  fill: themeColors.textColor
@@ -211,7 +218,7 @@ class ScatterChart extends BaseChart {
211
218
  const div = document.createElement('div');
212
219
  div.id = xAxisID;
213
220
  div.className = 'statistic-chart-axis-label';
214
- const column = TableUtils.getTableColumnByKey(table, x_axis_column);
221
+ const column = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column);
215
222
  div.innerHTML = "".concat(column ? column.name : '');
216
223
  div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
217
224
  chartContainer.appendChild(div);
@@ -229,7 +236,7 @@ class ScatterChart extends BaseChart {
229
236
  const div = document.createElement('div');
230
237
  div.id = yAxisID;
231
238
  div.className = 'statistic-chart-axis-label';
232
- const column = TableUtils.getTableColumnByKey(table, y_axis_column) || {};
239
+ const column = _dtableStore.TableUtils.getTableColumnByKey(table, y_axis_column) || {};
233
240
  div.innerHTML = column.name || '';
234
241
  const containerHeight = chartContainer.offsetHeight;
235
242
  let textAlign = 'center';
@@ -288,12 +295,12 @@ class ScatterChart extends BaseChart {
288
295
  if (show_y_axis_label) {
289
296
  style.paddingLeft = 38;
290
297
  }
291
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
298
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
292
299
  ref: ref => this.container = ref,
293
- className: "".concat(chartStyles['statistic-scatter-chart-container'], " statistic-chart-container"),
300
+ className: "".concat(_statisticChartModule.default['statistic-scatter-chart-container'], " statistic-chart-container"),
294
301
  style: style
295
302
  }));
296
303
  }
297
304
  }
298
305
  ScatterChart.propTypes = propTypes;
299
- export default ScatterChart;
306
+ var _default = exports.default = ScatterChart;
@@ -1,26 +1,33 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import DataSet from '@antv/data-set';
4
- import intl from 'react-intl-universal';
5
- import { each, pick } from '@antv/util';
6
- import { getEllipsisText } from '@antv/g2/esm/util/text';
7
- import { TableUtils } from 'dtable-store';
8
- import BaseChart from './base-chart';
9
- import { Chart, registerGeometryLabelLayout } from '../custom-g2';
10
- import { formatPieChartData, getCurrentTheme } from '../utils/common-utils';
11
- import { EMPTY_NAME, STATISTICS_COUNT_TYPE } from '../constants';
12
- import chartStyles from '../assets/css/statistic-chart.module.css';
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 _dataSet = _interopRequireDefault(require("@antv/data-set"));
11
+ var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
12
+ var _util = require("@antv/util");
13
+ var _text = require("@antv/g2/esm/util/text");
14
+ var _dtableStore = require("dtable-store");
15
+ var _baseChart = _interopRequireDefault(require("./base-chart"));
16
+ var _customG = require("../custom-g2");
17
+ var _commonUtils = require("../utils/common-utils");
18
+ var _constants = require("../constants");
19
+ var _statisticChartModule = _interopRequireDefault(require("../assets/css/statistic-chart.module.css"));
13
20
  const propTypes = {
14
- isPreview: PropTypes.bool,
15
- isEnlarge: PropTypes.bool,
16
- theme: PropTypes.string,
17
- colorThemeName: PropTypes.string,
18
- statItem: PropTypes.object,
19
- chartCalculator: PropTypes.object,
20
- getTableById: PropTypes.func,
21
- toggleStatisticRecordsDialog: PropTypes.func
21
+ isPreview: _propTypes.default.bool,
22
+ isEnlarge: _propTypes.default.bool,
23
+ theme: _propTypes.default.string,
24
+ colorThemeName: _propTypes.default.string,
25
+ statItem: _propTypes.default.object,
26
+ chartCalculator: _propTypes.default.object,
27
+ getTableById: _propTypes.default.func,
28
+ toggleStatisticRecordsDialog: _propTypes.default.func
22
29
  };
23
- class TreemapChart extends BaseChart {
30
+ class TreemapChart extends _baseChart.default {
24
31
  constructor(props) {
25
32
  super(props);
26
33
  this.componentDidMount = async () => {
@@ -83,14 +90,14 @@ class TreemapChart extends BaseChart {
83
90
  summary_column_key
84
91
  } = statItem;
85
92
  const table = getTableById(table_id);
86
- const selectedNumericColumn = TableUtils.getTableColumnByKey(table, summary_column_key);
93
+ const selectedNumericColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
87
94
  if (isPreview) {
88
- this.chart = new Chart({
95
+ this.chart = new _customG.Chart({
89
96
  container: this.container,
90
97
  autoFit: true
91
98
  });
92
99
  } else {
93
- this.chart = new Chart({
100
+ this.chart = new _customG.Chart({
94
101
  container: this.container,
95
102
  height: 400,
96
103
  width: 700
@@ -99,20 +106,20 @@ class TreemapChart extends BaseChart {
99
106
  this.chart.on('element:click', e => {
100
107
  this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
101
108
  });
102
- const currentTheme = getCurrentTheme(colorThemeName);
103
- const newData = formatPieChartData(data, statItem, table, currentTheme);
109
+ const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
110
+ const newData = (0, _commonUtils.formatPieChartData)(data, statItem, table, currentTheme);
104
111
  const colorSet = newData.colorSet;
105
112
  const {
106
113
  DataView
107
- } = DataSet;
114
+ } = _dataSet.default;
108
115
  const dv = new DataView();
109
116
  const fullData = {
110
117
  name: 'root',
111
118
  children: newData.map(item => {
112
119
  let name = item.name;
113
- item.name = name || name === 0 ? name : intl.get(EMPTY_NAME);
114
- if (name == 'Others') {
115
- item.name = intl.get('Others');
120
+ item.name = name || name === 0 ? name : _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
121
+ if (name === 'Others') {
122
+ item.name = _reactIntlUniversal.default.get('Others');
116
123
  }
117
124
  return item;
118
125
  })
@@ -167,7 +174,7 @@ class TreemapChart extends BaseChart {
167
174
  chart.polygon().position('x*y').color('name', colorSet).tooltip('name*formatted_value*percent', (name, value, percent) => {
168
175
  return {
169
176
  name,
170
- info: summary_type == STATISTICS_COUNT_TYPE.COUNT ? "".concat(value) : "".concat(selectedNumericColumn.name, ": ").concat(value, " (").concat(percent, ")")
177
+ info: summary_type === _constants.STATISTICS_COUNT_TYPE.COUNT ? "".concat(value) : "".concat(selectedNumericColumn.name, ": ").concat(value, " (").concat(percent, ")")
171
178
  };
172
179
  }).style({
173
180
  lineWidth: 1,
@@ -196,22 +203,22 @@ class TreemapChart extends BaseChart {
196
203
 
197
204
  // customize label layout: show ellipsis for long labels
198
205
  function limitInShape(items, labels, shapes, region) {
199
- each(labels, (label, index) => {
206
+ (0, _util.each)(labels, (label, index) => {
200
207
  const labelBBox = label.getCanvasBBox();
201
208
  const shapeBBox = shapes[index].getBBox();
202
209
  if (labelBBox.minX < shapeBBox.minX || labelBBox.minY < shapeBBox.minY || labelBBox.maxX > shapeBBox.maxX || labelBBox.maxY > shapeBBox.maxY) {
203
210
  const translateX = labelBBox.width - shapeBBox.width + 20;
204
211
  const textShapes = label.findAll(shape => shape.get('type') === 'text');
205
212
  textShapes.forEach(textShape => {
206
- const style = pick(textShape.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
213
+ const style = (0, _util.pick)(textShape.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
207
214
  const textBox = textShape.getCanvasBBox();
208
- const text = getEllipsisText(textShape.attr('text'), textBox.width - Math.abs(translateX), style);
215
+ const text = (0, _text.getEllipsisText)(textShape.attr('text'), textBox.width - Math.abs(translateX), style);
209
216
  textShape.attr('text', text);
210
217
  });
211
218
  }
212
219
  });
213
220
  }
214
- registerGeometryLabelLayout('custom-limit-in-shape', limitInShape);
221
+ (0, _customG.registerGeometryLabelLayout)('custom-limit-in-shape', limitInShape);
215
222
  }
216
223
  shouldComponentUpdate(nextProps, nextState) {
217
224
  const {
@@ -235,11 +242,11 @@ class TreemapChart extends BaseChart {
235
242
  const {
236
243
  isCalculatingData
237
244
  } = this.state;
238
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
245
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
239
246
  ref: ref => this.container = ref,
240
- className: "statistic-chart-container ".concat(chartStyles['statistic-treemap-chart-container'])
247
+ className: "statistic-chart-container ".concat(_statisticChartModule.default['statistic-treemap-chart-container'])
241
248
  }));
242
249
  }
243
250
  }
244
251
  TreemapChart.propTypes = propTypes;
245
- export default TreemapChart;
252
+ var _default = exports.default = TreemapChart;
@@ -1,17 +1,24 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import intl from 'react-intl-universal';
4
- import { TableUtils } from 'dtable-store';
5
- import BaseChart from './base-chart';
6
- import { Chart } from '../custom-g2';
7
- import { DATE_GRANULARITY, EMPTY_NAME, STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP } from '../constants';
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 _dtableStore = require("dtable-store");
12
+ var _baseChart = _interopRequireDefault(require("./base-chart"));
13
+ var _customG = require("../custom-g2");
14
+ var _constants = require("../constants");
8
15
  const propTypes = {
9
- isPreview: PropTypes.bool,
10
- statItem: PropTypes.object,
11
- chartCalculator: PropTypes.object,
12
- getTableById: PropTypes.func
16
+ isPreview: _propTypes.default.bool,
17
+ statItem: _propTypes.default.object,
18
+ chartCalculator: _propTypes.default.object,
19
+ getTableById: _propTypes.default.func
13
20
  };
14
- class BasicNumericCard extends BaseChart {
21
+ class BasicNumericCard extends _baseChart.default {
15
22
  constructor(props) {
16
23
  super(props);
17
24
  this.componentDidMount = async () => {
@@ -67,12 +74,12 @@ class BasicNumericCard extends BaseChart {
67
74
  statItem
68
75
  } = this.props;
69
76
  if (isPreview) {
70
- this.chart = new Chart({
77
+ this.chart = new _customG.Chart({
71
78
  container: this.container,
72
79
  autoFit: true
73
80
  });
74
81
  } else {
75
- this.chart = new Chart({
82
+ this.chart = new _customG.Chart({
76
83
  container: this.container,
77
84
  autoFit: true,
78
85
  height: 400,
@@ -83,7 +90,7 @@ class BasicNumericCard extends BaseChart {
83
90
  summary_method
84
91
  } = statItem;
85
92
  const latest = data && data.latest;
86
- const content = summary_method === SUMMARY_METHOD_MAP.Distinct_values ? latest : this.formatData(latest);
93
+ const content = summary_method === _constants.SUMMARY_METHOD_MAP.Distinct_values ? latest : this.formatData(latest);
87
94
  const fontSize = this.getFontSize(content);
88
95
  let labelFontSize = fontSize - 32;
89
96
  const themeColors = this.getThemeColors();
@@ -99,15 +106,15 @@ class BasicNumericCard extends BaseChart {
99
106
  getTableById,
100
107
  statItem
101
108
  } = this.props;
102
- if (typeof data !== 'number') return intl.get(EMPTY_NAME);
109
+ if (typeof data !== 'number') return _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
103
110
  const {
104
111
  table_id,
105
112
  summary_type,
106
113
  summary_column
107
114
  } = statItem;
108
- if (summary_type !== STATISTICS_COUNT_TYPE.COUNT) {
115
+ if (summary_type !== _constants.STATISTICS_COUNT_TYPE.COUNT) {
109
116
  const table = getTableById(table_id);
110
- const selectedColumn = TableUtils.getTableColumnByKey(table, summary_column);
117
+ const selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column);
111
118
  return this.getNumberDisplayString(data, selectedColumn.data || {});
112
119
  }
113
120
  let string = data + '';
@@ -167,20 +174,20 @@ class BasicNumericCard extends BaseChart {
167
174
  date_granularity
168
175
  } = statItem;
169
176
  let conjunctions = '';
170
- if (date_granularity === DATE_GRANULARITY.YEAR) {
171
- conjunctions = intl.get('The_year_before_last');
172
- } else if (date_granularity === DATE_GRANULARITY.QUARTER) {
173
- conjunctions = intl.get('The_quarter_before_last');
174
- } else if (date_granularity === DATE_GRANULARITY.MONTH) {
175
- conjunctions = intl.get('The_month_before_last');
176
- } else if (date_granularity === DATE_GRANULARITY.WEEK) {
177
- conjunctions = intl.get('The_week_before_last');
177
+ if (date_granularity === _constants.DATE_GRANULARITY.YEAR) {
178
+ conjunctions = _reactIntlUniversal.default.get('The_year_before_last');
179
+ } else if (date_granularity === _constants.DATE_GRANULARITY.QUARTER) {
180
+ conjunctions = _reactIntlUniversal.default.get('The_quarter_before_last');
181
+ } else if (date_granularity === _constants.DATE_GRANULARITY.MONTH) {
182
+ conjunctions = _reactIntlUniversal.default.get('The_month_before_last');
183
+ } else if (date_granularity === _constants.DATE_GRANULARITY.WEEK) {
184
+ conjunctions = _reactIntlUniversal.default.get('The_week_before_last');
178
185
  } else if (date_granularity === 'days_7') {
179
- conjunctions = intl.get('Previous_7_days');
186
+ conjunctions = _reactIntlUniversal.default.get('Previous_7_days');
180
187
  } else if (date_granularity === 'days_30') {
181
- conjunctions = intl.get('Previous_30_days');
188
+ conjunctions = _reactIntlUniversal.default.get('Previous_30_days');
182
189
  } else {
183
- conjunctions = intl.get('The_day_before_yesterday');
190
+ conjunctions = _reactIntlUniversal.default.get('The_day_before_yesterday');
184
191
  }
185
192
  const {
186
193
  result,
@@ -195,7 +202,7 @@ class BasicNumericCard extends BaseChart {
195
202
  }
196
203
  let resultText = "".concat(Number.parseFloat(result * 100).toFixed(2), "%&#8226;").concat(conjunctions).concat(previous);
197
204
  if (!previous) {
198
- resultText = intl.get('Can_not_compare_with_var', {
205
+ resultText = _reactIntlUniversal.default.get('Can_not_compare_with_var', {
199
206
  var: conjunctions.toLowerCase()
200
207
  });
201
208
  }
@@ -232,11 +239,11 @@ class BasicNumericCard extends BaseChart {
232
239
  const {
233
240
  isCalculatingData
234
241
  } = this.state;
235
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
242
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
236
243
  ref: ref => this.container = ref,
237
244
  className: "statistic-chart-container statistic-number-card"
238
245
  }));
239
246
  }
240
247
  }
241
248
  BasicNumericCard.propTypes = propTypes;
242
- export default BasicNumericCard;
249
+ var _default = exports.default = BasicNumericCard;