dtable-statistic 4.2.2 → 4.3.1

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 (219) hide show
  1. package/es/api/dtable-db-api.js +31 -37
  2. package/es/calculator/base-calculator.js +49 -99
  3. package/es/calculator/basic-chart-calculator.js +335 -559
  4. package/es/calculator/combination-calculator.js +231 -299
  5. package/es/calculator/compare-bar-calculator.js +184 -281
  6. package/es/calculator/completeness-calculator.js +203 -288
  7. package/es/calculator/copy-value.js +18 -18
  8. package/es/calculator/dashboard-calculator.js +68 -137
  9. package/es/calculator/heat-map-calculator.js +139 -220
  10. package/es/calculator/horizontal-bar-calculator.js +64 -93
  11. package/es/calculator/index.js +53 -69
  12. package/es/calculator/map-calculator.js +98 -174
  13. package/es/calculator/mirror-calculator.js +137 -216
  14. package/es/calculator/number-card-calculator.js +58 -126
  15. package/es/calculator/pivot-table-calculator.js +750 -792
  16. package/es/calculator/scatter-calculator.js +72 -140
  17. package/es/calculator/thread-manager.js +48 -67
  18. package/es/calculator/trend-calculator.js +107 -191
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
  20. package/es/calculator/workers/calculator.worker.js +22 -6
  21. package/es/calculator/workers/card-calculator-worker.js +16 -14
  22. package/es/calculator/workers/combination-calculator-worker.js +128 -135
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
  24. package/es/calculator/workers/completeness-calculator-worker.js +56 -49
  25. package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
  26. package/es/calculator/workers/mirror-calculator-worker.js +52 -52
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
  28. package/es/calculator/workers/scatter-calculator-worker.js +34 -32
  29. package/es/calculator/workers/trend-calculator-worker.js +33 -29
  30. package/es/calculator/world-map-calculator.js +120 -197
  31. package/es/components/common-add-tool.js +7 -5
  32. package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
  34. package/es/components/dialog/color-theme-dialog.js +34 -47
  35. package/es/components/dialog/delete-confirmation-dialog.js +7 -5
  36. package/es/components/dialog/enlarged-chart-dialog.js +68 -81
  37. package/es/components/dialog/new-table-dialog.js +62 -80
  38. package/es/components/dialog/new-view-dialog.js +50 -62
  39. package/es/components/dialog/rename-view-dialog.js +49 -58
  40. package/es/components/dialog/statistic-record-dialog/index.js +233 -231
  41. package/es/components/dialog/statistic-types-dialog/index.js +40 -49
  42. package/es/components/dialog/table-select-dialog.js +61 -70
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
  44. package/es/components/dtable-popover.js +62 -81
  45. package/es/components/dtable-search-input.js +89 -99
  46. package/es/components/dtable-select.js +55 -74
  47. package/es/components/icon.js +5 -3
  48. package/es/components/loading.js +1 -1
  49. package/es/components/modal-portal.js +15 -32
  50. package/es/components/popover/color-rules/color-rule.js +137 -141
  51. package/es/components/popover/color-rules/index.js +58 -66
  52. package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
  53. package/es/components/popover/color-rules/rule-filters/index.js +50 -58
  54. package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
  55. package/es/components/popover/color-rules-popover.js +117 -121
  56. package/es/components/popover/color-selector-popover.js +60 -70
  57. package/es/components/seatable-radio/index.js +2 -2
  58. package/es/components/select/option-group.js +139 -157
  59. package/es/components/select/option.js +26 -40
  60. package/es/components/select/select.js +97 -112
  61. package/es/components/toast/alert.js +65 -80
  62. package/es/components/toast/index.js +1 -1
  63. package/es/components/toast/toast.js +76 -103
  64. package/es/components/toast/toastManager.js +57 -93
  65. package/es/components/toast/toaster.js +58 -56
  66. package/es/constants/color-rules.js +8 -5
  67. package/es/constants/dtable-select-style.js +44 -48
  68. package/es/constants/event-types.js +4 -4
  69. package/es/constants/index.js +328 -242
  70. package/es/constants/map.js +2 -2
  71. package/es/constants/model.js +20 -20
  72. package/es/constants/regions.js +1 -1
  73. package/es/constants/zIndexes.js +1 -1
  74. package/es/custom-g2.js +11 -11
  75. package/es/dashboard.js +343 -333
  76. package/es/desktop-dashboard.js +217 -224
  77. package/es/index.js +45 -58
  78. package/es/locale/index.js +3 -3
  79. package/es/locale/lang/de.js +1 -1
  80. package/es/locale/lang/en.js +7 -7
  81. package/es/locale/lang/fr.js +1 -1
  82. package/es/locale/lang/zh_CN.js +1 -1
  83. package/es/mobile-dashboard.js +76 -89
  84. package/es/model/bar-group.js +34 -44
  85. package/es/model/bar.js +26 -36
  86. package/es/model/base-model.js +11 -12
  87. package/es/model/basic-number-card.js +10 -20
  88. package/es/model/collaborators.js +10 -11
  89. package/es/model/combination.js +32 -42
  90. package/es/model/compare-bar.js +30 -40
  91. package/es/model/completeness-group.js +19 -29
  92. package/es/model/completeness.js +14 -24
  93. package/es/model/custom-bar.js +14 -24
  94. package/es/model/dashboard.js +9 -19
  95. package/es/model/generic-model.js +187 -197
  96. package/es/model/heat-map.js +16 -26
  97. package/es/model/horizontal-bar-group.js +32 -42
  98. package/es/model/horizontal-bar.js +26 -36
  99. package/es/model/index.js +31 -3
  100. package/es/model/map.js +20 -30
  101. package/es/model/mirror.js +15 -25
  102. package/es/model/pie.js +21 -31
  103. package/es/model/ring.js +23 -33
  104. package/es/model/scatter.js +11 -21
  105. package/es/model/statistic-dashboard.js +7 -8
  106. package/es/model/table.js +19 -29
  107. package/es/model/trend.js +15 -25
  108. package/es/model/world-map.js +17 -27
  109. package/es/service/chart-service.js +69 -65
  110. package/es/service/dashboard-service.js +421 -419
  111. package/es/service/map-json.js +112 -132
  112. package/es/stat-editor/chart-name-editor.js +44 -58
  113. package/es/stat-editor/index.js +59 -70
  114. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
  115. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
  116. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
  117. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
  118. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
  119. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
  120. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
  121. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
  122. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
  123. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
  124. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
  125. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
  126. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
  127. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
  128. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
  129. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
  130. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
  131. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
  132. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
  133. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
  134. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
  135. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
  136. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
  137. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
  138. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
  139. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
  140. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
  141. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
  143. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
  144. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
  148. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
  149. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
  150. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
  151. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
  152. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
  153. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
  154. package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
  155. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
  156. package/es/stat-editor/stat-settings/map/map-level.js +31 -43
  157. package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
  158. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
  159. package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
  160. package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
  161. package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
  162. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
  163. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
  164. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
  165. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
  166. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
  167. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
  168. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
  169. package/es/stat-list/chart-preview.js +85 -98
  170. package/es/stat-list/index.js +170 -178
  171. package/es/stat-view/area-chart.js +282 -274
  172. package/es/stat-view/bar-chart.js +300 -292
  173. package/es/stat-view/base-chart.js +58 -52
  174. package/es/stat-view/basic-number-card.js +115 -168
  175. package/es/stat-view/combination-chart.js +298 -334
  176. package/es/stat-view/compare-chart.js +256 -254
  177. package/es/stat-view/completeness-chart.js +194 -206
  178. package/es/stat-view/custom-bar.js +221 -223
  179. package/es/stat-view/dashboard-chart.js +122 -180
  180. package/es/stat-view/heat-map.js +268 -294
  181. package/es/stat-view/horizontal-bar-chart.js +291 -281
  182. package/es/stat-view/index.js +136 -152
  183. package/es/stat-view/line-chart.js +267 -265
  184. package/es/stat-view/map.js +246 -246
  185. package/es/stat-view/mirror.js +141 -152
  186. package/es/stat-view/pie-chart.js +143 -156
  187. package/es/stat-view/pivot-table/index.js +113 -118
  188. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
  189. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
  190. package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
  191. package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
  192. package/es/stat-view/ring-chart.js +189 -200
  193. package/es/stat-view/scatter-chart.js +162 -213
  194. package/es/stat-view/treemap-chart.js +136 -200
  195. package/es/stat-view/trend-chart.js +137 -183
  196. package/es/stat-view/world-map.js +233 -243
  197. package/es/tabs/index.js +164 -169
  198. package/es/tabs/tab.js +101 -116
  199. package/es/utils/basic-chart-utils.js +7 -9
  200. package/es/utils/cell-format.js +48 -51
  201. package/es/utils/cell-value.js +1 -1
  202. package/es/utils/collaborator.js +15 -14
  203. package/es/utils/color-utils.js +48 -37
  204. package/es/utils/column-utils.js +47 -33
  205. package/es/utils/column.js +1 -1
  206. package/es/utils/common-utils.js +111 -117
  207. package/es/utils/date-format.js +17 -17
  208. package/es/utils/export-table-utils.js +507 -396
  209. package/es/utils/index.js +6 -6
  210. package/es/utils/map.js +30 -34
  211. package/es/utils/model.js +3 -5
  212. package/es/utils/object.js +4 -4
  213. package/es/utils/pivot-table.js +20 -20
  214. package/es/utils/row-utils.js +41 -33
  215. package/es/utils/search.js +18 -20
  216. package/es/utils/sql-utils.js +132 -98
  217. package/es/utils/stat-utils.js +303 -320
  218. package/es/utils/trend-utils.js +57 -67
  219. package/package.json +2 -2
@@ -1,8 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
1
  import React from 'react';
7
2
  import PropTypes from 'prop-types';
8
3
  import dayjs from 'dayjs';
@@ -15,61 +10,57 @@ import { isShapeEqual } from '../utils/common-utils';
15
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';
16
11
  import styles from '../assets/css/statistic-custom.module.css';
17
12
  dayjs.extend(weekOfYear);
18
- var HeatMap = /*#__PURE__*/function (_BaseChart) {
19
- _inherits(HeatMap, _BaseChart);
20
- var _super = _createSuper(HeatMap);
21
- function HeatMap(props) {
22
- var _this;
23
- _classCallCheck(this, HeatMap);
24
- _this = _super.call(this, props);
25
- _this.destroyChart = function () {
26
- _this.chart.destroy();
27
- _this.chart = null;
13
+ class HeatMap extends BaseChart {
14
+ constructor(props) {
15
+ super(props);
16
+ this.destroyChart = () => {
17
+ this.chart.destroy();
18
+ this.chart = null;
28
19
  };
29
- _this.transformData = function (statData) {
30
- var data = {};
31
- var yearFirstDate = dayjs(statData[0].name);
32
- _this.firstDate = yearFirstDate.year() + '-01-01';
33
- statData.forEach(function (item) {
20
+ this.transformData = statData => {
21
+ let data = {};
22
+ let yearFirstDate = dayjs(statData[0].name);
23
+ this.firstDate = yearFirstDate.year() + '-01-01';
24
+ statData.forEach(item => {
34
25
  data[item.name] = data[item.name] ? data[item.name] + item.value : item.value;
35
26
  });
36
27
  return data;
37
28
  };
38
- _this.generateBackgroundGridData = function (statData) {
39
- var momentDate = dayjs(_this.firstDate);
40
- var year = momentDate.year();
41
- var gridData = [];
42
- var isLeapYear = year % 4 > 0 ? false : true;
43
- var yearDayCount = 365;
29
+ this.generateBackgroundGridData = statData => {
30
+ let momentDate = dayjs(this.firstDate);
31
+ const year = momentDate.year();
32
+ const gridData = [];
33
+ const isLeapYear = year % 4 > 0 ? false : true;
34
+ let yearDayCount = 365;
44
35
  if (isLeapYear) {
45
36
  yearDayCount = 366;
46
37
  }
47
- for (var i = 0; i < yearDayCount; i++) {
48
- var day = momentDate.day();
49
- var week = momentDate.week() - 1;
50
- var month = momentDate.month();
38
+ for (let i = 0; i < yearDayCount; i++) {
39
+ const day = momentDate.day();
40
+ let week = momentDate.week() - 1;
41
+ const month = momentDate.month();
51
42
  if (week === 0 && month === 11) {
52
43
  week = 52;
53
44
  }
54
- var yearDate = momentDate.format('YYYY-MM-DD');
55
- var value = statData[yearDate] || 0;
56
- _this.maxValue = Math.max(_this.maxValue, value);
45
+ const yearDate = momentDate.format('YYYY-MM-DD');
46
+ const value = statData[yearDate] || 0;
47
+ this.maxValue = Math.max(this.maxValue, value);
57
48
  gridData.push({
58
49
  date: yearDate,
59
50
  value: statData[yearDate],
60
- day: day,
61
- week: week,
62
- month: month
51
+ day,
52
+ week,
53
+ month
63
54
  });
64
55
  momentDate = momentDate.add(1, 'days');
65
56
  }
66
57
  return gridData;
67
58
  };
68
- _this.getLabel = function (val) {
69
- var currentDate = dayjs(_this.firstDate).add(val * 7, 'days');
70
- var month = currentDate.month();
71
- var monthDate = currentDate.date();
72
- var isFirst = monthDate <= 7 || false;
59
+ this.getLabel = val => {
60
+ const currentDate = dayjs(this.firstDate).add(val * 7, 'days');
61
+ let month = currentDate.month();
62
+ let monthDate = currentDate.date();
63
+ let isFirst = monthDate <= 7 || false;
73
64
 
74
65
  // if the week is the first week of a month
75
66
  // mark it to axis
@@ -78,16 +69,17 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
78
69
  }
79
70
  return '';
80
71
  };
81
- _this.drawChart = function (statData) {
82
- _this.maxValue = 0;
83
- var _this$props = _this.props,
84
- getTableById = _this$props.getTableById,
85
- statItem = _this$props.statItem;
86
- var currentColorOption = COLOR_OPTIONS.filter(function (item) {
87
- return item.name == statItem.data_color;
88
- })[0] || COLOR_OPTIONS[0];
89
- var exampleColors = currentColorOption.exampleColors;
90
- var count = statData.years.length;
72
+ this.drawChart = statData => {
73
+ this.maxValue = 0;
74
+ const {
75
+ getTableById,
76
+ statItem
77
+ } = this.props;
78
+ const currentColorOption = COLOR_OPTIONS.filter(item => item.name == statItem.data_color)[0] || COLOR_OPTIONS[0];
79
+ const {
80
+ exampleColors
81
+ } = currentColorOption;
82
+ const count = statData.years.length;
91
83
  /**
92
84
  * 114: 12 * 7 + 6 * 4 + 8(mistake)
93
85
  * 30: the bottom padding of one calendar
@@ -96,29 +88,29 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
96
88
  * 15: the spacing of calendar
97
89
  */
98
90
 
99
- var grid_size = statItem.grid_size,
100
- grid_distance = statItem.grid_distance;
91
+ let {
92
+ grid_size,
93
+ grid_distance
94
+ } = statItem;
101
95
  grid_size = grid_size || DEFAULT_GRID_SIZE;
102
96
  grid_distance = grid_distance || DEFAULT_GRID_DISTANCE;
103
97
  // height for 1 year
104
- var yearHeight = grid_size * 7 + grid_distance * 6 + 8;
105
- var chartHeight = (yearHeight + 30) * count + 30 + (count - 1) * 15;
106
- _this.chart = new Chart({
107
- container: _this.container,
98
+ const yearHeight = grid_size * 7 + grid_distance * 6 + 8;
99
+ const chartHeight = (yearHeight + 30) * count + 30 + (count - 1) * 15;
100
+ this.chart = new Chart({
101
+ container: this.container,
108
102
  autoFit: false,
109
103
  height: chartHeight,
110
104
  width: grid_size * 53 + grid_distance * 52 + 75,
111
105
  // 75: left padding + right padding
112
106
  padding: [30, 30, 0, 45]
113
107
  });
114
- _this.chart.on('element:click', function (e) {
115
- var clickDate = e.data.data.date;
116
- var data = statData.data.find(function (i) {
117
- return i.name === clickDate;
118
- });
119
- _this.props.toggleStatisticRecordsDialog(data, statItem);
108
+ this.chart.on('element:click', e => {
109
+ const clickDate = e.data.data.date;
110
+ const data = statData.data.find(i => i.name === clickDate);
111
+ this.props.toggleStatisticRecordsDialog(data, statItem);
120
112
  });
121
- _this.chart.tooltip({
113
+ this.chart.tooltip({
122
114
  title: 'date',
123
115
  showMarkers: false,
124
116
  showTitle: false,
@@ -126,24 +118,26 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
126
118
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
127
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>"),
128
120
  domStyles: {
129
- 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
130
- 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
121
+ 'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
122
+ 'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
131
123
  }
132
124
  });
133
- _this.chart.axis(false);
134
- _this.chart.data(statData.data);
135
- var themeColors = _this.getThemeColors();
136
- var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
137
- var table_id = statItem.table_id,
138
- summary_type = statItem.summary_type,
139
- summary_column = statItem.summary_column,
140
- summary_method = statItem.summary_method;
125
+ this.chart.axis(false);
126
+ this.chart.data(statData.data);
127
+ const themeColors = this.getThemeColors();
128
+ let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
129
+ const {
130
+ table_id,
131
+ summary_type,
132
+ summary_column,
133
+ summary_method
134
+ } = statItem;
141
135
  if (summary_type === SUMMARY_TYPE.ADVANCED) {
142
- var table = getTableById(table_id);
143
- var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
136
+ const table = getTableById(table_id);
137
+ const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
144
138
  columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
145
139
  }
146
- _this.chart.facet('list', {
140
+ this.chart.facet('list', {
147
141
  fields: ['year'],
148
142
  cols: 1,
149
143
  showTitle: true,
@@ -158,10 +152,10 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
158
152
  },
159
153
  padding: [0, 0, 15, 0],
160
154
  spacing: [0, 15],
161
- eachView: function eachView(view, facet) {
162
- var groupStatData = _this.transformData(facet.data);
163
- var gridData = _this.generateBackgroundGridData(groupStatData);
164
- var gridView = view.createView();
155
+ eachView: (view, facet) => {
156
+ let groupStatData = this.transformData(facet.data);
157
+ const gridData = this.generateBackgroundGridData(groupStatData);
158
+ const gridView = view.createView();
165
159
  gridView.axis('week', {
166
160
  position: 'top',
167
161
  tickLine: null,
@@ -176,8 +170,8 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
176
170
  fontSize: 12,
177
171
  fill: themeColors.textColor
178
172
  },
179
- formatter: function formatter(val, label, index) {
180
- return _this.getLabel(val);
173
+ formatter: (val, label, index) => {
174
+ return this.getLabel(val);
181
175
  }
182
176
  },
183
177
  grid: null
@@ -208,25 +202,25 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
208
202
  }
209
203
  });
210
204
  gridView.data(gridData);
211
- gridView.polygon().position('week*day*date').color('value', function (value) {
205
+ gridView.polygon().position('week*day*date').color('value', value => {
212
206
  if (!value || value <= 0) {
213
207
  return '#EBEDF0';
214
208
  }
215
- if (value === _this.maxValue) return exampleColors[8];
216
- return exampleColors[Math.floor(value / (_this.maxValue / 9))];
209
+ if (value === this.maxValue) return exampleColors[8];
210
+ return exampleColors[Math.floor(value / (this.maxValue / 9))];
217
211
  }).customInfo({
218
- grid_size: grid_size,
219
- grid_distance: grid_distance
220
- }).shape('boundary-polygon').label(false).tooltip('date*value', function (date, value) {
212
+ grid_size,
213
+ grid_distance
214
+ }).shape('boundary-polygon').label(false).tooltip('date*value', (date, value) => {
221
215
  return {
222
- date: date,
223
- value: _this.getNumberDisplayString(value, columnData, summary_method)
216
+ date,
217
+ value: this.getNumberDisplayString(value, columnData, summary_method)
224
218
  };
225
219
  });
226
220
  gridView.coordinate().reflect('y');
227
221
  }
228
222
  });
229
- _this.chart.legend('value', {
223
+ this.chart.legend('value', {
230
224
  position: 'top-left',
231
225
  layout: 'horizontal',
232
226
  offsetY: -6,
@@ -238,241 +232,221 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
238
232
  fill: themeColors.textColor
239
233
  }
240
234
  },
241
- items: _this.getLegendItems(exampleColors)
235
+ items: this.getLegendItems(exampleColors)
242
236
  });
243
- _this.chart.removeInteraction('legend-filter');
244
- _this.chart.render();
237
+ this.chart.removeInteraction('legend-filter');
238
+ this.chart.render();
245
239
  };
246
240
  // get text width in canvas
247
- _this.getTextWidthInCanvas = function (text) {
248
- var canvas = document.createElement('canvas');
249
- var context = canvas.getContext('2d');
250
- var font = context.font;
251
- var fontStyle = font.slice(font.indexOf('px'));
241
+ this.getTextWidthInCanvas = text => {
242
+ let canvas = document.createElement('canvas');
243
+ const context = canvas.getContext('2d');
244
+ let font = context.font;
245
+ const fontStyle = font.slice(font.indexOf('px'));
252
246
  font = 'bold ' + 12 + fontStyle;
253
247
  context.font = font;
254
248
  return Math.ceil(context.measureText(text).width);
255
249
  };
256
250
  dayjs.locale('en');
257
- _this.state = {
251
+ this.state = {
258
252
  isCalculatingData: true,
259
253
  showResultDescription: true
260
254
  };
261
- _this.calculateData = null;
262
- _this.maxValue = 0;
263
- return _this;
255
+ this.calculateData = null;
256
+ this.maxValue = 0;
264
257
  }
265
- _createClass(HeatMap, [{
266
- key: "componentDidMount",
267
- value: function componentDidMount() {
268
- var _this2 = this;
269
- var _this$props2 = this.props,
270
- statItem = _this$props2.statItem,
271
- chartCalculator = _this$props2.chartCalculator;
272
- registerShape('polygon', 'boundary-polygon', {
273
- draw: function draw(cfg, container) {
274
- if (cfg && cfg.points && cfg.points.length > 0) {
275
- var group = container.addGroup();
276
- var attrs = {
277
- fill: cfg.color,
278
- lineWidth: 1,
279
- stroke: FILL_BORDER_COLOR_MAP[cfg.color]
280
- };
281
- var points = cfg.points,
282
- customInfo = cfg.customInfo;
283
- var grid_size = customInfo.grid_size,
284
- grid_distance = customInfo.grid_distance;
285
- var distance = grid_distance / 2;
286
- var offset = grid_size - 1;
287
- var parsedPoint = this.parsePoints(points);
288
- var _parsedPoint = _slicedToArray(parsedPoint, 4),
289
- p0 = _parsedPoint[0],
290
- p1 = _parsedPoint[1],
291
- p2 = _parsedPoint[2],
292
- p3 = _parsedPoint[3];
293
- p0.y = p0.y + distance;
294
- p1.x = p0.x;
295
- p1.y = p0.y + offset;
296
- p2.x = p0.x + offset;
297
- p2.y = p1.y;
298
- p3.x = p0.x + offset;
299
- p3.y = p0.y;
300
- // get cell path that has radius, the cell radius is 2;
301
- var path = getRectWithCornerRadius(parsedPoint, this.coordinate, 2);
302
- attrs.path = path;
303
- group.addShape('path', {
304
- attrs: attrs,
305
- capture: cfg.data.value > 0,
306
- visible: true
307
- });
308
- return group;
309
- }
258
+ componentDidMount() {
259
+ const {
260
+ statItem,
261
+ chartCalculator
262
+ } = this.props;
263
+ registerShape('polygon', 'boundary-polygon', {
264
+ draw(cfg, container) {
265
+ if (cfg && cfg.points && cfg.points.length > 0) {
266
+ const group = container.addGroup();
267
+ let attrs = {
268
+ fill: cfg.color,
269
+ lineWidth: 1,
270
+ stroke: FILL_BORDER_COLOR_MAP[cfg.color]
271
+ };
272
+ const {
273
+ points,
274
+ customInfo
275
+ } = cfg;
276
+ const {
277
+ grid_size,
278
+ grid_distance
279
+ } = customInfo;
280
+ const distance = grid_distance / 2;
281
+ const offset = grid_size - 1;
282
+ const parsedPoint = this.parsePoints(points);
283
+ let [p0, p1, p2, p3] = parsedPoint;
284
+ p0.y = p0.y + distance;
285
+ p1.x = p0.x;
286
+ p1.y = p0.y + offset;
287
+ p2.x = p0.x + offset;
288
+ p2.y = p1.y;
289
+ p3.x = p0.x + offset;
290
+ p3.y = p0.y;
291
+ // get cell path that has radius, the cell radius is 2;
292
+ const path = getRectWithCornerRadius(parsedPoint, this.coordinate, 2);
293
+ attrs.path = path;
294
+ group.addShape('path', {
295
+ attrs,
296
+ capture: cfg.data.value > 0,
297
+ visible: true
298
+ });
299
+ return group;
310
300
  }
301
+ }
302
+ });
303
+ if (this.container) {
304
+ chartCalculator.calculate(statItem).then(data => {
305
+ const showResultDescription = data.years && data.years.length > 0 ? false : true;
306
+ this.calculateData = data;
307
+ this.setState({
308
+ isCalculatingData: false,
309
+ showResultDescription
310
+ }, () => {
311
+ if (!showResultDescription) {
312
+ this.drawChart(data);
313
+ this.calculateData = data;
314
+ }
315
+ });
316
+ });
317
+ }
318
+ }
319
+ shouldComponentUpdate(nextProps, nextState) {
320
+ const {
321
+ statItem
322
+ } = this.props;
323
+ if (this.canUpdate(this.props, nextProps)) {
324
+ if (!isShapeEqual(nextProps.statItem.layout, statItem.layout)) {
325
+ return false;
326
+ }
327
+ return true;
328
+ }
329
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
330
+ return true;
331
+ }
332
+ return false;
333
+ }
334
+ componentDidUpdate(preProps, preState) {
335
+ const {
336
+ statItem,
337
+ chartCalculator
338
+ } = this.props;
339
+ const {
340
+ isCalculatingData
341
+ } = this.state;
342
+ if (isCalculatingData !== preState.isCalculatingData) return;
343
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
344
+ this.setState({
345
+ isCalculatingData: true
311
346
  });
312
347
  if (this.container) {
313
- chartCalculator.calculate(statItem).then(function (data) {
314
- var showResultDescription = data.years && data.years.length > 0 ? false : true;
315
- _this2.calculateData = data;
316
- _this2.setState({
348
+ chartCalculator.calculate(statItem).then(data => {
349
+ const showResultDescription = data.years && data.years.length > 0 ? false : true;
350
+ this.chart && this.destroyChart();
351
+ this.calculateData = data;
352
+ this.setState({
317
353
  isCalculatingData: false,
318
- showResultDescription: showResultDescription
319
- }, function () {
354
+ showResultDescription
355
+ }, () => {
320
356
  if (!showResultDescription) {
321
- _this2.drawChart(data);
322
- _this2.calculateData = data;
357
+ this.drawChart(data);
323
358
  }
324
359
  });
325
360
  });
326
361
  }
327
- }
328
- }, {
329
- key: "shouldComponentUpdate",
330
- value: function shouldComponentUpdate(nextProps, nextState) {
331
- var statItem = this.props.statItem;
332
- if (this.canUpdate(this.props, nextProps)) {
333
- if (!isShapeEqual(nextProps.statItem.layout, statItem.layout)) {
334
- return false;
335
- }
336
- return true;
337
- }
338
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
339
- return true;
362
+ } else {
363
+ if (!this.state.showResultDescription) {
364
+ this.chart && this.destroyChart();
365
+ this.drawChart(this.calculateData);
340
366
  }
341
- return false;
342
367
  }
343
- }, {
344
- key: "componentDidUpdate",
345
- value: function componentDidUpdate(preProps, preState) {
346
- var _this3 = this;
347
- var _this$props3 = this.props,
348
- statItem = _this$props3.statItem,
349
- chartCalculator = _this$props3.chartCalculator;
350
- var isCalculatingData = this.state.isCalculatingData;
351
- if (isCalculatingData !== preState.isCalculatingData) return;
352
- if (this.shouldCalculateStatItem(preProps, this.props)) {
353
- this.setState({
354
- isCalculatingData: true
355
- });
356
- if (this.container) {
357
- chartCalculator.calculate(statItem).then(function (data) {
358
- var showResultDescription = data.years && data.years.length > 0 ? false : true;
359
- _this3.chart && _this3.destroyChart();
360
- _this3.calculateData = data;
361
- _this3.setState({
362
- isCalculatingData: false,
363
- showResultDescription: showResultDescription
364
- }, function () {
365
- if (!showResultDescription) {
366
- _this3.drawChart(data);
367
- }
368
- });
369
- });
370
- }
371
- } else {
372
- if (!this.state.showResultDescription) {
373
- this.chart && this.destroyChart();
374
- this.drawChart(this.calculateData);
368
+ }
369
+ componentWillUnmount() {
370
+ this.container = null;
371
+ }
372
+ getLegendItems(colors) {
373
+ const text = intl.get('Less');
374
+ const textWidth = this.getTextWidthInCanvas(text);
375
+ const items = [{
376
+ name: text,
377
+ marker: {
378
+ symbol: (x, y, r) => this.getLegendItemPath(x, y, r, 0, textWidth),
379
+ spacing: 0,
380
+ style: {
381
+ fill: '#E1E3E6',
382
+ lineWidth: 1,
383
+ stroke: '#EBEDF0',
384
+ r: 5
375
385
  }
376
386
  }
377
- }
378
- }, {
379
- key: "componentWillUnmount",
380
- value: function componentWillUnmount() {
381
- this.container = null;
382
- }
383
- }, {
384
- key: "getLegendItems",
385
- value: function getLegendItems(colors) {
386
- var _this4 = this;
387
- var text = intl.get('Less');
388
- var textWidth = this.getTextWidthInCanvas(text);
389
- var items = [{
390
- name: text,
387
+ }];
388
+ colors.forEach((color, index) => {
389
+ items.push({
391
390
  marker: {
392
- symbol: function symbol(x, y, r) {
393
- return _this4.getLegendItemPath(x, y, r, 0, textWidth);
394
- },
395
- spacing: 0,
391
+ symbol: (x, y, r) => this.getLegendItemPath(x, y, r, index + 1, textWidth),
392
+ spacing: 2,
396
393
  style: {
397
- fill: '#E1E3E6',
394
+ fill: color,
398
395
  lineWidth: 1,
399
- stroke: '#EBEDF0',
396
+ stroke: FILL_BORDER_COLOR_MAP[color],
400
397
  r: 5
401
398
  }
402
399
  }
403
- }];
404
- colors.forEach(function (color, index) {
405
- items.push({
406
- marker: {
407
- symbol: function symbol(x, y, r) {
408
- return _this4.getLegendItemPath(x, y, r, index + 1, textWidth);
409
- },
410
- spacing: 2,
411
- style: {
412
- fill: color,
413
- lineWidth: 1,
414
- stroke: FILL_BORDER_COLOR_MAP[color],
415
- r: 5
416
- }
417
- }
418
- });
419
400
  });
420
- items[9].name = intl.get('More');
421
- items[9].marker.spacing = 22;
422
- return items;
423
- }
424
- }, {
425
- key: "getLegendItemPath",
426
- value: function getLegendItemPath(x, y, r, index, textWidth) {
427
- // x, y represents the coordinates of the center point of the legend item marker
428
- var p0 = {
429
- x: x - 6,
430
- y: y + 6
431
- };
432
- // translate the lengend marker to right to make the first legend item text to left of the marker
433
- if (index === 0) {
434
- p0.x = p0.x + textWidth + 16;
435
- } else {
436
- p0.x = p0.x + 18;
437
- }
438
- var p1 = {
439
- x: p0.x,
440
- y: p0.y - 12
441
- };
442
- var p2 = {
443
- x: p0.x + 12,
444
- y: p0.y - 12
445
- };
446
- var p3 = {
447
- x: p0.x + 12,
448
- y: p0.y
449
- };
450
- var path = getRectWithCornerRadius([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
451
- return path;
452
- }
453
- }, {
454
- key: "render",
455
- value: function render() {
456
- var _this5 = this;
457
- var _this$state = this.state,
458
- isCalculatingData = _this$state.isCalculatingData,
459
- showResultDescription = _this$state.showResultDescription;
460
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
461
- style: {
462
- overflow: 'auto',
463
- height: '100%',
464
- display: 'flex',
465
- padding: 15
466
- },
467
- ref: function ref(_ref) {
468
- return _this5.container = _ref;
469
- },
470
- className: "".concat(styles['statistic-heatmap-container'], " statistic-chart-container")
471
- }));
401
+ });
402
+ items[9].name = intl.get('More');
403
+ items[9].marker.spacing = 22;
404
+ return items;
405
+ }
406
+ getLegendItemPath(x, y, r, index, textWidth) {
407
+ // x, y represents the coordinates of the center point of the legend item marker
408
+ let p0 = {
409
+ x: x - 6,
410
+ y: y + 6
411
+ };
412
+ // translate the lengend marker to right to make the first legend item text to left of the marker
413
+ if (index === 0) {
414
+ p0.x = p0.x + textWidth + 16;
415
+ } else {
416
+ p0.x = p0.x + 18;
472
417
  }
473
- }]);
474
- return HeatMap;
475
- }(BaseChart);
418
+ const p1 = {
419
+ x: p0.x,
420
+ y: p0.y - 12
421
+ };
422
+ const p2 = {
423
+ x: p0.x + 12,
424
+ y: p0.y - 12
425
+ };
426
+ const p3 = {
427
+ x: p0.x + 12,
428
+ y: p0.y
429
+ };
430
+ const path = getRectWithCornerRadius([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
431
+ return path;
432
+ }
433
+ render() {
434
+ const {
435
+ isCalculatingData,
436
+ showResultDescription
437
+ } = this.state;
438
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
439
+ style: {
440
+ overflow: 'auto',
441
+ height: '100%',
442
+ display: 'flex',
443
+ padding: 15
444
+ },
445
+ ref: ref => this.container = ref,
446
+ className: "".concat(styles['statistic-heatmap-container'], " statistic-chart-container")
447
+ }));
448
+ }
449
+ }
476
450
  HeatMap.propTypes = {
477
451
  statItem: PropTypes.object,
478
452
  chartCalculator: PropTypes.object,