dtable-statistic 4.3.3 → 4.3.4

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 +3 -10
  2. package/es/calculator/base-calculator.js +12 -20
  3. package/es/calculator/basic-chart-calculator.js +65 -72
  4. package/es/calculator/combination-calculator.js +57 -64
  5. package/es/calculator/compare-bar-calculator.js +26 -33
  6. package/es/calculator/completeness-calculator.js +30 -37
  7. package/es/calculator/copy-value.js +1 -7
  8. package/es/calculator/dashboard-calculator.js +13 -20
  9. package/es/calculator/heat-map-calculator.js +18 -25
  10. package/es/calculator/horizontal-bar-calculator.js +8 -15
  11. package/es/calculator/index.js +35 -42
  12. package/es/calculator/map-calculator.js +22 -29
  13. package/es/calculator/mirror-calculator.js +20 -27
  14. package/es/calculator/number-card-calculator.js +10 -17
  15. package/es/calculator/pivot-table-calculator.js +58 -65
  16. package/es/calculator/scatter-calculator.js +14 -21
  17. package/es/calculator/thread-manager.js +1 -7
  18. package/es/calculator/trend-calculator.js +22 -29
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +76 -83
  20. package/es/calculator/workers/calculator.worker.js +30 -33
  21. package/es/calculator/workers/card-calculator-worker.js +13 -19
  22. package/es/calculator/workers/combination-calculator-worker.js +46 -53
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +22 -29
  24. package/es/calculator/workers/completeness-calculator-worker.js +34 -41
  25. package/es/calculator/workers/dashboard-calculator-worker.js +18 -24
  26. package/es/calculator/workers/mirror-calculator-worker.js +22 -29
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +77 -84
  28. package/es/calculator/workers/scatter-calculator-worker.js +20 -27
  29. package/es/calculator/workers/trend-calculator-worker.js +27 -34
  30. package/es/calculator/world-map-calculator.js +17 -24
  31. package/es/components/common-add-tool.js +5 -12
  32. package/es/components/dialog/chart-addition-edit-dialog.js +12 -20
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +101 -108
  34. package/es/components/dialog/color-theme-dialog.js +15 -22
  35. package/es/components/dialog/delete-confirmation-dialog.js +11 -18
  36. package/es/components/dialog/enlarged-chart-dialog.js +20 -28
  37. package/es/components/dialog/new-table-dialog.js +16 -23
  38. package/es/components/dialog/new-view-dialog.js +14 -21
  39. package/es/components/dialog/rename-view-dialog.js +14 -22
  40. package/es/components/dialog/statistic-record-dialog/index.js +37 -45
  41. package/es/components/dialog/statistic-types-dialog/index.js +14 -22
  42. package/es/components/dialog/table-select-dialog.js +15 -23
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +41 -49
  44. package/es/components/dtable-popover.js +12 -19
  45. package/es/components/dtable-search-input.js +13 -21
  46. package/es/components/dtable-select.js +15 -21
  47. package/es/components/icon.js +4 -11
  48. package/es/components/index.js +11 -76
  49. package/es/components/loading.js +3 -10
  50. package/es/components/modal-portal.js +5 -12
  51. package/es/components/popover/color-rules/color-rule.js +25 -33
  52. package/es/components/popover/color-rules/index.js +6 -14
  53. package/es/components/popover/color-rules/rule-filters/filter.js +27 -34
  54. package/es/components/popover/color-rules/rule-filters/index.js +17 -25
  55. package/es/components/popover/color-rules/rule-filters/number-input.js +9 -17
  56. package/es/components/popover/color-rules-popover.js +24 -32
  57. package/es/components/popover/color-selector-popover.js +10 -17
  58. package/es/components/seatable-radio/index.js +9 -16
  59. package/es/components/select/index.js +2 -9
  60. package/es/components/select/option-group.js +19 -27
  61. package/es/components/select/option.js +6 -14
  62. package/es/components/select/select.js +17 -25
  63. package/es/components/toast/alert.js +24 -31
  64. package/es/components/toast/index.js +3 -10
  65. package/es/components/toast/toast.js +12 -20
  66. package/es/components/toast/toastManager.js +9 -17
  67. package/es/components/toast/toaster.js +6 -14
  68. package/es/constants/color-rules.js +6 -12
  69. package/es/constants/dtable-select-style.js +4 -9
  70. package/es/constants/event-types.js +4 -10
  71. package/es/constants/index.js +67 -96
  72. package/es/constants/key-codes.js +0 -2
  73. package/es/constants/map.js +2 -8
  74. package/es/constants/model.js +20 -26
  75. package/es/constants/regions.js +3 -8
  76. package/es/constants/zIndexes.js +1 -7
  77. package/es/custom-g2.js +208 -236
  78. package/es/dashboard.js +50 -58
  79. package/es/desktop-dashboard.js +47 -55
  80. package/es/index.js +3 -6
  81. package/es/locale/index.js +10 -13
  82. package/es/locale/lang/de.js +1 -7
  83. package/es/locale/lang/en.js +1 -7
  84. package/es/locale/lang/fr.js +1 -7
  85. package/es/locale/lang/zh_CN.js +1 -7
  86. package/es/mobile-dashboard.js +38 -46
  87. package/es/model/bar-group.js +11 -19
  88. package/es/model/bar.js +10 -18
  89. package/es/model/base-model.js +2 -9
  90. package/es/model/basic-number-card.js +8 -16
  91. package/es/model/collaborators.js +2 -9
  92. package/es/model/combination.js +12 -20
  93. package/es/model/compare-bar.js +16 -24
  94. package/es/model/completeness-group.js +8 -16
  95. package/es/model/completeness.js +5 -13
  96. package/es/model/custom-bar.js +6 -14
  97. package/es/model/dashboard.js +6 -14
  98. package/es/model/generic-model.js +133 -141
  99. package/es/model/heat-map.js +11 -19
  100. package/es/model/horizontal-bar-group.js +10 -18
  101. package/es/model/horizontal-bar.js +10 -18
  102. package/es/model/index.js +53 -185
  103. package/es/model/map.js +15 -23
  104. package/es/model/mirror.js +13 -21
  105. package/es/model/pie.js +10 -18
  106. package/es/model/ring.js +11 -19
  107. package/es/model/scatter.js +6 -14
  108. package/es/model/statistic-dashboard.js +2 -9
  109. package/es/model/table.js +10 -18
  110. package/es/model/trend.js +12 -20
  111. package/es/model/world-map.js +13 -21
  112. package/es/service/chart-service.js +7 -14
  113. package/es/service/dashboard-service.js +34 -41
  114. package/es/service/map-json.js +8 -14
  115. package/es/stat-editor/chart-name-editor.js +8 -15
  116. package/es/stat-editor/index.js +16 -24
  117. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +21 -29
  118. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +49 -57
  119. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +23 -31
  120. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +4 -11
  121. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +19 -27
  122. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +43 -51
  123. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +23 -31
  124. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +23 -31
  125. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +37 -45
  126. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +19 -27
  127. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +26 -34
  128. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +47 -55
  129. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +22 -30
  130. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +18 -26
  131. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +27 -35
  132. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +24 -32
  133. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +33 -41
  134. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +22 -30
  135. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +27 -26
  136. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +46 -54
  137. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +23 -31
  138. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +26 -34
  139. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +77 -85
  140. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +21 -29
  141. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +73 -81
  142. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +16 -24
  143. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +19 -27
  144. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +18 -26
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +49 -57
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +17 -25
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +47 -55
  148. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +11 -19
  149. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +45 -53
  150. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +9 -17
  151. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +20 -28
  152. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +30 -38
  153. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +50 -58
  154. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +17 -25
  155. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +47 -55
  156. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +11 -19
  157. package/es/stat-editor/stat-settings/color-setting/color-picker.js +12 -19
  158. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +62 -70
  159. package/es/stat-editor/stat-settings/map/map-level.js +13 -20
  160. package/es/stat-editor/stat-settings/map/map-province-city.js +20 -27
  161. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +11 -19
  162. package/es/stat-editor/stat-settings/public-setting/base-settings.js +20 -28
  163. package/es/stat-editor/stat-settings/public-setting/calender.js +22 -29
  164. package/es/stat-editor/stat-settings/public-setting/column-settings.js +6 -13
  165. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +9 -16
  166. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +13 -21
  167. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +8 -15
  168. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +11 -19
  169. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +27 -35
  170. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +8 -15
  171. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +18 -26
  172. package/es/stat-list/chart-preview.js +20 -28
  173. package/es/stat-list/index.js +27 -35
  174. package/es/stat-view/area-chart.js +43 -50
  175. package/es/stat-view/bar-chart.js +47 -54
  176. package/es/stat-view/base-chart.js +24 -32
  177. package/es/stat-view/basic-number-card.js +19 -26
  178. package/es/stat-view/combination-chart.js +49 -56
  179. package/es/stat-view/compare-chart.js +39 -46
  180. package/es/stat-view/completeness-chart.js +28 -35
  181. package/es/stat-view/custom-bar.js +31 -38
  182. package/es/stat-view/dashboard-chart.js +15 -22
  183. package/es/stat-view/heat-map.js +43 -50
  184. package/es/stat-view/horizontal-bar-chart.js +51 -58
  185. package/es/stat-view/index.js +73 -80
  186. package/es/stat-view/line-chart.js +39 -46
  187. package/es/stat-view/map.js +33 -40
  188. package/es/stat-view/mirror.js +21 -28
  189. package/es/stat-view/pie-chart.js +29 -36
  190. package/es/stat-view/pivot-table/index.js +32 -39
  191. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +31 -39
  192. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +29 -37
  193. package/es/stat-view/pivot-table/pivot-table-display-name.js +46 -54
  194. package/es/stat-view/pivot-table/two-dimension-table.js +62 -70
  195. package/es/stat-view/ring-chart.js +38 -45
  196. package/es/stat-view/scatter-chart.js +30 -37
  197. package/es/stat-view/treemap-chart.js +37 -44
  198. package/es/stat-view/trend-chart.js +32 -39
  199. package/es/stat-view/world-map.js +33 -40
  200. package/es/tabs/index.js +32 -40
  201. package/es/tabs/tab.js +26 -34
  202. package/es/utils/basic-chart-utils.js +2 -9
  203. package/es/utils/cell-format.js +14 -22
  204. package/es/utils/cell-value.js +7 -14
  205. package/es/utils/collaborator.js +4 -13
  206. package/es/utils/color-utils.js +18 -29
  207. package/es/utils/column-utils.js +18 -29
  208. package/es/utils/column.js +4 -11
  209. package/es/utils/common-utils.js +41 -65
  210. package/es/utils/date-format.js +2 -8
  211. package/es/utils/export-table-utils.js +82 -91
  212. package/es/utils/index.js +11 -100
  213. package/es/utils/map.js +26 -36
  214. package/es/utils/model.js +6 -14
  215. package/es/utils/object.js +6 -15
  216. package/es/utils/pivot-table.js +16 -23
  217. package/es/utils/row-utils.js +23 -33
  218. package/es/utils/search.js +21 -29
  219. package/es/utils/sql-utils.js +65 -75
  220. package/es/utils/stat-utils.js +60 -66
  221. package/es/utils/trend-utils.js +32 -40
  222. package/package.json +1 -1
@@ -1,31 +1,24 @@
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 _dtableStore = require("dtable-store");
13
- var _customG = require("../custom-g2");
14
- var _baseChart = _interopRequireDefault(require("./base-chart"));
15
- var _basicChartUtils = require("../utils/basic-chart-utils");
16
- var _commonUtils = require("../utils/common-utils");
17
- var _constants = require("../constants");
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 { TableUtils } from 'dtable-store';
6
+ import { Chart } from '../custom-g2';
7
+ import BaseChart from './base-chart';
8
+ import { getChartGroups } from '../utils/basic-chart-utils';
9
+ import { getCurrentTheme } from '../utils/common-utils';
10
+ import { EMPTY_NAME, LABEL_CONFIG_CHANGED, TITLE_AMOUNT } from '../constants';
18
11
  const propTypes = {
19
- isPreview: _propTypes.default.bool,
20
- isEdit: _propTypes.default.bool,
21
- statItem: _propTypes.default.object,
22
- labelColorConfigs: _propTypes.default.array,
23
- chartCalculator: _propTypes.default.object,
24
- eventBus: _propTypes.default.object,
25
- colorThemeName: _propTypes.default.string,
26
- toggleStatisticRecordsDialog: _propTypes.default.func
12
+ isPreview: PropTypes.bool,
13
+ isEdit: PropTypes.bool,
14
+ statItem: PropTypes.object,
15
+ labelColorConfigs: PropTypes.array,
16
+ chartCalculator: PropTypes.object,
17
+ eventBus: PropTypes.object,
18
+ colorThemeName: PropTypes.string,
19
+ toggleStatisticRecordsDialog: PropTypes.func
27
20
  };
28
- class CustomBar extends _baseChart.default {
21
+ class CustomBar extends BaseChart {
29
22
  constructor(props) {
30
23
  super(props);
31
24
  this.drawChart = originalData => {
@@ -51,7 +44,7 @@ class CustomBar extends _baseChart.default {
51
44
  const {
52
45
  width
53
46
  } = this.chart.coordinateBBox;
54
- const chartData = (0, _basicChartUtils.getChartGroups)(data);
47
+ const chartData = getChartGroups(data);
55
48
  const ticks = this.getTicks(chartData, width);
56
49
  if (ticks.length > 0) {
57
50
  this.chart.scale('name', {
@@ -69,7 +62,7 @@ class CustomBar extends _baseChart.default {
69
62
  });
70
63
 
71
64
  // get the total value of each stack
72
- const dv = new _dataSet.default.DataView().source(data);
65
+ const dv = new DataSet.DataView().source(data);
73
66
  dv.transform({
74
67
  type: 'aggregate',
75
68
  fields: ['value'],
@@ -82,7 +75,7 @@ class CustomBar extends _baseChart.default {
82
75
  type: 'cat'
83
76
  }
84
77
  });
85
- const currentTheme = (0, _commonUtils.getCurrentTheme)(colorThemeName);
78
+ const currentTheme = getCurrentTheme(colorThemeName);
86
79
  const themeColors = this.getThemeColors();
87
80
  this.drawBar({
88
81
  themeColors,
@@ -112,7 +105,7 @@ class CustomBar extends _baseChart.default {
112
105
  config.height = 400;
113
106
  config.width = 700;
114
107
  }
115
- this.chart = new _customG.Chart(config);
108
+ this.chart = new Chart(config);
116
109
  };
117
110
  this.drawBar = _ref => {
118
111
  let {
@@ -136,9 +129,9 @@ class CustomBar extends _baseChart.default {
136
129
  this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name*raw_name', (name, value, group_name, raw_name) => {
137
130
  let nameContent = group_name;
138
131
  if (!group_name && typeof group_name !== 'number') {
139
- nameContent = _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
132
+ nameContent = intl.get(EMPTY_NAME);
140
133
  }
141
- const title = !name && typeof name !== 'number' ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : name;
134
+ const title = !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
142
135
  return {
143
136
  value,
144
137
  title,
@@ -208,7 +201,7 @@ class CustomBar extends _baseChart.default {
208
201
  },
209
202
  formatter: name => {
210
203
  if (!name && typeof name !== 'number') {
211
- return _reactIntlUniversal.default.get(_constants.EMPTY_NAME);
204
+ return intl.get(EMPTY_NAME);
212
205
  }
213
206
  return name;
214
207
  }
@@ -258,7 +251,7 @@ class CustomBar extends _baseChart.default {
258
251
  const div = document.createElement('div');
259
252
  div.id = xAxisID;
260
253
  div.className = 'statistic-chart-axis-label';
261
- const column = _dtableStore.TableUtils.getTableColumnByKey(table, x_axis_column_key);
254
+ const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
262
255
  div.innerHTML = "".concat(column ? column.name : '');
263
256
  div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
264
257
  chartContainer.appendChild(div);
@@ -276,7 +269,7 @@ class CustomBar extends _baseChart.default {
276
269
  const div = document.createElement('div');
277
270
  div.id = yAxisID;
278
271
  div.className = 'statistic-chart-axis-label';
279
- div.innerHTML = title_name || _reactIntlUniversal.default.get(_constants.TITLE_AMOUNT);
272
+ div.innerHTML = title_name || intl.get(TITLE_AMOUNT);
280
273
  const containerHeight = chartContainer.offsetHeight;
281
274
  let textAlign = 'center';
282
275
  if (y_axis_label_position === 'bottom') textAlign = 'left';
@@ -311,7 +304,7 @@ class CustomBar extends _baseChart.default {
311
304
  chartCalculator,
312
305
  eventBus
313
306
  } = this.props;
314
- this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
307
+ this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
315
308
  this.renderAxisLabel(newStatItem);
316
309
  });
317
310
  chartCalculator.calculate(statItem).then(data => {
@@ -405,7 +398,7 @@ class CustomBar extends _baseChart.default {
405
398
  show_y_axis_label,
406
399
  show_x_axis_label
407
400
  } = statItem;
408
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/_react.default.createElement("div", {
401
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
409
402
  ref: ref => this.container = ref,
410
403
  style: {
411
404
  padding: show_y_axis_label || show_x_axis_label ? 30 : 20
@@ -415,4 +408,4 @@ class CustomBar extends _baseChart.default {
415
408
  }
416
409
  }
417
410
  CustomBar.propTypes = propTypes;
418
- var _default = exports.default = CustomBar;
411
+ export default CustomBar;
@@ -1,23 +1,16 @@
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 _baseChart = _interopRequireDefault(require("./base-chart"));
11
- var _customG = require("../custom-g2");
12
- var _utils = require("../utils");
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import BaseChart from './base-chart';
4
+ import { Chart, registerShape } from '../custom-g2';
5
+ import { isMobile } from '../utils';
13
6
  const propTypes = {
14
- isPreview: _propTypes.default.bool,
15
- statItem: _propTypes.default.object,
16
- chartCalculator: _propTypes.default.object
7
+ isPreview: PropTypes.bool,
8
+ statItem: PropTypes.object,
9
+ chartCalculator: PropTypes.object
17
10
  };
18
11
  const WIDTH = 700;
19
12
  const HEIGHT = 400;
20
- class DashboardChart extends _baseChart.default {
13
+ class DashboardChart extends BaseChart {
21
14
  constructor(props) {
22
15
  super(props);
23
16
  this.componentDidMount = async () => {
@@ -130,10 +123,10 @@ class DashboardChart extends _baseChart.default {
130
123
  config.width = WIDTH;
131
124
  config.height = HEIGHT;
132
125
  }
133
- this.chart = new _customG.Chart(config);
126
+ this.chart = new Chart(config);
134
127
  };
135
128
  this.registerShape = () => {
136
- (0, _customG.registerShape)('point', 'pointer', {
129
+ registerShape('point', 'pointer', {
137
130
  draw(cfg, container) {
138
131
  const group = container.addGroup();
139
132
  const center = this.parsePoint({
@@ -216,7 +209,7 @@ class DashboardChart extends _baseChart.default {
216
209
  position: ['50%', '85%'],
217
210
  content: statItem.name,
218
211
  style: {
219
- fontSize: _utils.isMobile ? 16 : 20,
212
+ fontSize: isMobile ? 16 : 20,
220
213
  fill: '#545454',
221
214
  textAlign: 'center'
222
215
  }
@@ -231,7 +224,7 @@ class DashboardChart extends _baseChart.default {
231
224
  position: ['50%', '90%'],
232
225
  content: "".concat(shownValue, " %"),
233
226
  style: {
234
- fontSize: _utils.isMobile ? 20 : 36,
227
+ fontSize: isMobile ? 20 : 36,
235
228
  fill: themeColors.textColor,
236
229
  textAlign: 'center'
237
230
  },
@@ -256,11 +249,11 @@ class DashboardChart extends _baseChart.default {
256
249
  const {
257
250
  isCalculatingData
258
251
  } = this.state;
259
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/_react.default.createElement("div", {
252
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
260
253
  ref: ref => this.container = ref,
261
254
  className: "statistic-chart-container d-flex justify-content-around align-items-center"
262
255
  }));
263
256
  }
264
257
  }
265
258
  DashboardChart.propTypes = propTypes;
266
- var _default = exports.default = DashboardChart;
259
+ export default DashboardChart;
@@ -1,23 +1,16 @@
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 _dayjs = _interopRequireDefault(require("dayjs"));
11
- var _weekOfYear = _interopRequireDefault(require("dayjs/plugin/weekOfYear"));
12
- var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
13
- var _dtableStore = require("dtable-store");
14
- var _baseChart = _interopRequireDefault(require("./base-chart"));
15
- var _customG = require("../custom-g2");
16
- var _commonUtils = require("../utils/common-utils");
17
- var _constants = require("../constants");
18
- var _statisticCustomModule = _interopRequireDefault(require("../assets/css/statistic-custom.module.css"));
19
- _dayjs.default.extend(_weekOfYear.default);
20
- class HeatMap extends _baseChart.default {
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import dayjs from 'dayjs';
4
+ import weekOfYear from 'dayjs/plugin/weekOfYear';
5
+ import intl from 'react-intl-universal';
6
+ import { TableUtils } from 'dtable-store';
7
+ import BaseChart from './base-chart';
8
+ import { Chart, registerShape, getRectWithCornerRadius } from '../custom-g2';
9
+ import { isShapeEqual } from '../utils/common-utils';
10
+ import { COLOR_OPTIONS, DEFAULT_GRID_DISTANCE, DEFAULT_GRID_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, FILL_BORDER_COLOR_MAP, MONTH_MIRROR, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
11
+ import styles from '../assets/css/statistic-custom.module.css';
12
+ dayjs.extend(weekOfYear);
13
+ class HeatMap extends BaseChart {
21
14
  constructor(props) {
22
15
  super(props);
23
16
  this.destroyChart = () => {
@@ -26,7 +19,7 @@ class HeatMap extends _baseChart.default {
26
19
  };
27
20
  this.transformData = statData => {
28
21
  let data = {};
29
- let yearFirstDate = (0, _dayjs.default)(statData[0].name);
22
+ let yearFirstDate = dayjs(statData[0].name);
30
23
  this.firstDate = yearFirstDate.year() + '-01-01';
31
24
  statData.forEach(item => {
32
25
  data[item.name] = data[item.name] ? data[item.name] + item.value : item.value;
@@ -34,7 +27,7 @@ class HeatMap extends _baseChart.default {
34
27
  return data;
35
28
  };
36
29
  this.generateBackgroundGridData = statData => {
37
- let momentDate = (0, _dayjs.default)(this.firstDate);
30
+ let momentDate = dayjs(this.firstDate);
38
31
  const year = momentDate.year();
39
32
  const gridData = [];
40
33
  const isLeapYear = year % 4 > 0 ? false : true;
@@ -64,7 +57,7 @@ class HeatMap extends _baseChart.default {
64
57
  return gridData;
65
58
  };
66
59
  this.getLabel = val => {
67
- const currentDate = (0, _dayjs.default)(this.firstDate).add(val * 7, 'days');
60
+ const currentDate = dayjs(this.firstDate).add(val * 7, 'days');
68
61
  let month = currentDate.month();
69
62
  let monthDate = currentDate.date();
70
63
  let isFirst = monthDate <= 7 || false;
@@ -72,7 +65,7 @@ class HeatMap extends _baseChart.default {
72
65
  // if the week is the first week of a month
73
66
  // mark it to axis
74
67
  if (isFirst) {
75
- return _reactIntlUniversal.default.get(_constants.MONTH_MIRROR[month]);
68
+ return intl.get(MONTH_MIRROR[month]);
76
69
  }
77
70
  return '';
78
71
  };
@@ -82,7 +75,7 @@ class HeatMap extends _baseChart.default {
82
75
  getTableById,
83
76
  statItem
84
77
  } = this.props;
85
- const currentColorOption = _constants.COLOR_OPTIONS.filter(item => item.name === statItem.data_color)[0] || _constants.COLOR_OPTIONS[0];
78
+ const currentColorOption = COLOR_OPTIONS.filter(item => item.name === statItem.data_color)[0] || COLOR_OPTIONS[0];
86
79
  const {
87
80
  exampleColors
88
81
  } = currentColorOption;
@@ -99,12 +92,12 @@ class HeatMap extends _baseChart.default {
99
92
  grid_size,
100
93
  grid_distance
101
94
  } = statItem;
102
- grid_size = grid_size || _constants.DEFAULT_GRID_SIZE;
103
- grid_distance = grid_distance || _constants.DEFAULT_GRID_DISTANCE;
95
+ grid_size = grid_size || DEFAULT_GRID_SIZE;
96
+ grid_distance = grid_distance || DEFAULT_GRID_DISTANCE;
104
97
  // height for 1 year
105
98
  const yearHeight = grid_size * 7 + grid_distance * 6 + 8;
106
99
  const chartHeight = (yearHeight + 30) * count + 30 + (count - 1) * 15;
107
- this.chart = new _customG.Chart({
100
+ this.chart = new Chart({
108
101
  container: this.container,
109
102
  autoFit: false,
110
103
  height: chartHeight,
@@ -123,7 +116,7 @@ class HeatMap extends _baseChart.default {
123
116
  showTitle: false,
124
117
  shared: true,
125
118
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
126
- itemTpl: "<div class=\"g2-tooltip-content\"><div style=\"width: max-content; text-align: left;\" class=\"tooltip-name\">{date}<div><div style=\"word-break: keep-all;\" class=\"tooltip-item\">".concat(_reactIntlUniversal.default.get(_constants.TITLE_AMOUNT), " : {value}<div></div>"),
119
+ itemTpl: "<div class=\"g2-tooltip-content\"><div style=\"width: max-content; text-align: left;\" class=\"tooltip-name\">{date}<div><div style=\"word-break: keep-all;\" class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
127
120
  domStyles: {
128
121
  'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
129
122
  'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
@@ -132,17 +125,17 @@ class HeatMap extends _baseChart.default {
132
125
  this.chart.axis(false);
133
126
  this.chart.data(statData.data);
134
127
  const themeColors = this.getThemeColors();
135
- let columnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
128
+ let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
136
129
  const {
137
130
  table_id,
138
131
  summary_type,
139
132
  summary_column,
140
133
  summary_method
141
134
  } = statItem;
142
- if (summary_type === _constants.SUMMARY_TYPE.ADVANCED) {
135
+ if (summary_type === SUMMARY_TYPE.ADVANCED) {
143
136
  const table = getTableById(table_id);
144
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column) || {};
145
- columnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
137
+ const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
138
+ columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
146
139
  }
147
140
  this.chart.facet('list', {
148
141
  fields: ['year'],
@@ -196,7 +189,7 @@ class HeatMap extends _baseChart.default {
196
189
  gridView.scale({
197
190
  day: {
198
191
  type: 'cat',
199
- values: [_reactIntlUniversal.default.get('Sun'), _reactIntlUniversal.default.get('Mon'), _reactIntlUniversal.default.get('Tue'), _reactIntlUniversal.default.get('Wed'), _reactIntlUniversal.default.get('Thu'), _reactIntlUniversal.default.get('Fri'), _reactIntlUniversal.default.get('Sat')]
192
+ values: [intl.get('Sun'), intl.get('Mon'), intl.get('Tue'), intl.get('Wed'), intl.get('Thu'), intl.get('Fri'), intl.get('Sat')]
200
193
  },
201
194
  week: {
202
195
  type: 'cat'
@@ -254,7 +247,7 @@ class HeatMap extends _baseChart.default {
254
247
  context.font = font;
255
248
  return Math.ceil(context.measureText(text).width);
256
249
  };
257
- _dayjs.default.locale('en');
250
+ dayjs.locale('en');
258
251
  this.state = {
259
252
  isCalculatingData: true,
260
253
  showResultDescription: true
@@ -267,14 +260,14 @@ class HeatMap extends _baseChart.default {
267
260
  statItem,
268
261
  chartCalculator
269
262
  } = this.props;
270
- (0, _customG.registerShape)('polygon', 'boundary-polygon', {
263
+ registerShape('polygon', 'boundary-polygon', {
271
264
  draw(cfg, container) {
272
265
  if (cfg && cfg.points && cfg.points.length > 0) {
273
266
  const group = container.addGroup();
274
267
  let attrs = {
275
268
  fill: cfg.color,
276
269
  lineWidth: 1,
277
- stroke: _constants.FILL_BORDER_COLOR_MAP[cfg.color]
270
+ stroke: FILL_BORDER_COLOR_MAP[cfg.color]
278
271
  };
279
272
  const {
280
273
  points,
@@ -296,7 +289,7 @@ class HeatMap extends _baseChart.default {
296
289
  p3.x = p0.x + offset;
297
290
  p3.y = p0.y;
298
291
  // get cell path that has radius, the cell radius is 2;
299
- const path = (0, _customG.getRectWithCornerRadius)(parsedPoint, this.coordinate, 2);
292
+ const path = getRectWithCornerRadius(parsedPoint, this.coordinate, 2);
300
293
  attrs.path = path;
301
294
  group.addShape('path', {
302
295
  attrs,
@@ -328,7 +321,7 @@ class HeatMap extends _baseChart.default {
328
321
  statItem
329
322
  } = this.props;
330
323
  if (this.canUpdate(this.props, nextProps)) {
331
- if (!(0, _commonUtils.isShapeEqual)(nextProps.statItem.layout, statItem.layout)) {
324
+ if (!isShapeEqual(nextProps.statItem.layout, statItem.layout)) {
332
325
  return false;
333
326
  }
334
327
  return true;
@@ -377,7 +370,7 @@ class HeatMap extends _baseChart.default {
377
370
  this.container = null;
378
371
  }
379
372
  getLegendItems(colors) {
380
- const text = _reactIntlUniversal.default.get('Less');
373
+ const text = intl.get('Less');
381
374
  const textWidth = this.getTextWidthInCanvas(text);
382
375
  const items = [{
383
376
  name: text,
@@ -400,13 +393,13 @@ class HeatMap extends _baseChart.default {
400
393
  style: {
401
394
  fill: color,
402
395
  lineWidth: 1,
403
- stroke: _constants.FILL_BORDER_COLOR_MAP[color],
396
+ stroke: FILL_BORDER_COLOR_MAP[color],
404
397
  r: 5
405
398
  }
406
399
  }
407
400
  });
408
401
  });
409
- items[9].name = _reactIntlUniversal.default.get('More');
402
+ items[9].name = intl.get('More');
410
403
  items[9].marker.spacing = 22;
411
404
  return items;
412
405
  }
@@ -434,7 +427,7 @@ class HeatMap extends _baseChart.default {
434
427
  x: p0.x + 12,
435
428
  y: p0.y
436
429
  };
437
- const path = (0, _customG.getRectWithCornerRadius)([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
430
+ const path = getRectWithCornerRadius([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
438
431
  return path;
439
432
  }
440
433
  render() {
@@ -442,7 +435,7 @@ class HeatMap extends _baseChart.default {
442
435
  isCalculatingData,
443
436
  showResultDescription
444
437
  } = this.state;
445
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/_react.default.createElement("div", {
438
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
446
439
  style: {
447
440
  overflow: 'auto',
448
441
  height: '100%',
@@ -450,14 +443,14 @@ class HeatMap extends _baseChart.default {
450
443
  padding: 15
451
444
  },
452
445
  ref: ref => this.container = ref,
453
- className: "".concat(_statisticCustomModule.default['statistic-heatmap-container'], " statistic-chart-container")
446
+ className: "".concat(styles['statistic-heatmap-container'], " statistic-chart-container")
454
447
  }));
455
448
  }
456
449
  }
457
450
  HeatMap.propTypes = {
458
- statItem: _propTypes.default.object,
459
- chartCalculator: _propTypes.default.object,
460
- getTableById: _propTypes.default.func,
461
- toggleStatisticRecordsDialog: _propTypes.default.func
451
+ statItem: PropTypes.object,
452
+ chartCalculator: PropTypes.object,
453
+ getTableById: PropTypes.func,
454
+ toggleStatisticRecordsDialog: PropTypes.func
462
455
  };
463
- var _default = exports.default = HeatMap;
456
+ export default HeatMap;