dtable-statistic 4.3.4 → 4.3.5

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