dtable-statistic 4.2.2 → 4.3.0

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,7 +1,3 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import PropTypes from 'prop-types';
7
3
  import intl from 'react-intl-universal';
@@ -11,7 +7,7 @@ import { Chart } from '../custom-g2';
11
7
  import { getCurrentTheme } from '../utils/common-utils';
12
8
  import { getChartGroups } from '../utils/basic-chart-utils';
13
9
  import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, SUMMARY_TYPE, LABEL_CONFIG_CHANGED, STATISTICS_COUNT_SHOW, TITLE_AMOUNT, TITLE_INCREASE } from '../constants';
14
- var propTypes = {
10
+ const propTypes = {
15
11
  isPreview: PropTypes.bool,
16
12
  isEdit: PropTypes.bool,
17
13
  colorThemeName: PropTypes.string,
@@ -21,82 +17,86 @@ var propTypes = {
21
17
  getTableById: PropTypes.func,
22
18
  toggleStatisticRecordsDialog: PropTypes.func
23
19
  };
24
- var CompareChart = /*#__PURE__*/function (_BaseChart) {
25
- _inherits(CompareChart, _BaseChart);
26
- var _super = _createSuper(CompareChart);
27
- function CompareChart(props) {
28
- var _this;
29
- _classCallCheck(this, CompareChart);
30
- _this = _super.call(this, props);
31
- _this.drawChart = function (data) {
32
- var _this$props = _this.props,
33
- getTableById = _this$props.getTableById,
34
- statItem = _this$props.statItem,
35
- colorThemeName = _this$props.colorThemeName;
36
- var table_id = statItem.table_id,
37
- y_axis_column_key = statItem.y_axis_column_key,
38
- y_axis_summary_type = statItem.y_axis_summary_type,
39
- display_increase = statItem.display_increase;
40
- _this.initChartHandler();
41
- _this.chart.on('interval:click', function (e) {
42
- _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
20
+ class CompareChart extends BaseChart {
21
+ constructor(props) {
22
+ super(props);
23
+ this.drawChart = data => {
24
+ const {
25
+ getTableById,
26
+ statItem,
27
+ colorThemeName
28
+ } = this.props;
29
+ const {
30
+ table_id,
31
+ y_axis_column_key,
32
+ y_axis_summary_type,
33
+ display_increase
34
+ } = statItem;
35
+ this.initChartHandler();
36
+ this.chart.on('interval:click', e => {
37
+ this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
43
38
  });
44
- var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
39
+ let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
45
40
  if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
46
- var table = getTableById(table_id);
47
- var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
41
+ const table = getTableById(table_id);
42
+ const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
48
43
  summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
49
44
  }
50
- _this.chart.data(data, {
45
+ this.chart.data(data, {
51
46
  'name': {
52
47
  type: 'cat',
53
48
  nice: false
54
49
  }
55
50
  });
56
- var width = _this.chart.coordinateBBox.width;
57
- var chartData = getChartGroups(data);
58
- var ticks = _this.getTicks(chartData, width);
51
+ const {
52
+ width
53
+ } = this.chart.coordinateBBox;
54
+ const chartData = getChartGroups(data);
55
+ const ticks = this.getTicks(chartData, width);
59
56
  if (ticks.length > 0) {
60
- _this.chart.scale('name', {
61
- ticks: ticks
57
+ this.chart.scale('name', {
58
+ ticks
62
59
  });
63
60
  }
64
61
 
65
62
  // set Coord type
66
- _this.chart.coordinate('rect');
67
- _this.handleAutoRange(data, summaryColumnData);
68
- _this.chart.scale({
63
+ this.chart.coordinate('rect');
64
+ this.handleAutoRange(data, summaryColumnData);
65
+ this.chart.scale({
69
66
  group_name: {
70
67
  type: 'cat'
71
68
  }
72
69
  });
73
- var currentTheme = getCurrentTheme(colorThemeName);
74
- var themeColors = _this.getThemeColors();
75
- _this.drawBar({
76
- currentTheme: currentTheme,
77
- themeColors: themeColors
70
+ const currentTheme = getCurrentTheme(colorThemeName);
71
+ const themeColors = this.getThemeColors();
72
+ this.drawBar({
73
+ currentTheme,
74
+ themeColors
78
75
  });
79
- _this.setTooltip();
76
+ this.setTooltip();
80
77
  if (display_increase) {
81
- _this.drawIncreaseLine({
82
- themeColors: themeColors
78
+ this.drawIncreaseLine({
79
+ themeColors
83
80
  });
84
81
  }
85
- _this.setAxis(themeColors);
86
- _this.setLegend(themeColors);
87
- _this.chart.interaction('active-region');
88
- _this.chart.removeInteraction('legend-filter');
89
- _this.chart.render();
90
- _this.renderAxisLabel();
82
+ this.setAxis(themeColors);
83
+ this.setLegend(themeColors);
84
+ this.chart.interaction('active-region');
85
+ this.chart.removeInteraction('legend-filter');
86
+ this.chart.render();
87
+ this.renderAxisLabel();
91
88
  };
92
- _this.initChartHandler = function () {
93
- var _this$props2 = _this.props,
94
- isPreview = _this$props2.isPreview,
95
- statItem = _this$props2.statItem;
96
- var display_data = statItem.display_data,
97
- display_increase_percentage = statItem.display_increase_percentage;
98
- var config = {
99
- container: _this.container,
89
+ this.initChartHandler = () => {
90
+ const {
91
+ isPreview,
92
+ statItem
93
+ } = this.props;
94
+ const {
95
+ display_data,
96
+ display_increase_percentage
97
+ } = statItem;
98
+ let config = {
99
+ container: this.container,
100
100
  autoFit: true,
101
101
  appendPadding: [display_data || display_increase_percentage ? 17 : 0, 0, 0, 0]
102
102
  };
@@ -104,17 +104,18 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
104
104
  config.height = 400;
105
105
  config.width = 700;
106
106
  }
107
- _this.chart = new Chart(config);
107
+ this.chart = new Chart(config);
108
108
  };
109
- _this.handleAutoRange = function (data, summaryColumnData) {
110
- var _this$props$statItem = _this.props.statItem,
111
- y_axis_summary_method = _this$props$statItem.y_axis_summary_method,
112
- y_axis_auto_range = _this$props$statItem.y_axis_auto_range,
113
- y_axis_min = _this$props$statItem.y_axis_min,
114
- y_axis_max = _this$props$statItem.y_axis_max;
115
- var valueScaleOptions = {
116
- formatter: function formatter(value) {
117
- return _this.getNumberDisplayString(value, summaryColumnData, y_axis_summary_method);
109
+ this.handleAutoRange = (data, summaryColumnData) => {
110
+ const {
111
+ y_axis_summary_method,
112
+ y_axis_auto_range,
113
+ y_axis_min,
114
+ y_axis_max
115
+ } = this.props.statItem;
116
+ let valueScaleOptions = {
117
+ formatter: value => {
118
+ return this.getNumberDisplayString(value, summaryColumnData, y_axis_summary_method);
118
119
  }
119
120
  };
120
121
 
@@ -130,14 +131,14 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
130
131
  });
131
132
 
132
133
  // set the filter rule
133
- _this.chart.filter('value', function (value) {
134
+ this.chart.filter('value', value => {
134
135
  return value >= y_axis_min;
135
136
  });
136
137
 
137
138
  // filter the data
138
- _this.chart.filterData(data);
139
+ this.chart.filterData(data);
139
140
  }
140
- _this.chart.scale({
141
+ this.chart.scale({
141
142
  // Set the type of the name column so that g2 can draw correctly
142
143
  name: {
143
144
  type: 'cat'
@@ -145,23 +146,26 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
145
146
  value: valueScaleOptions
146
147
  });
147
148
  };
148
- _this.drawBar = function (_ref) {
149
- var themeColors = _ref.themeColors,
150
- currentTheme = _ref.currentTheme;
151
- var _this$props$statItem2 = _this.props.statItem,
152
- y_axis_summary_type = _this$props$statItem2.y_axis_summary_type,
153
- y_axis_summary_method = _this$props$statItem2.y_axis_summary_method,
154
- display_data = _this$props$statItem2.display_data;
155
- _this.chart.interval().label(display_data ? 'formatted_value' : false, {
149
+ this.drawBar = _ref => {
150
+ let {
151
+ themeColors,
152
+ currentTheme
153
+ } = _ref;
154
+ const {
155
+ y_axis_summary_type,
156
+ y_axis_summary_method,
157
+ display_data
158
+ } = this.props.statItem;
159
+ this.chart.interval().label(display_data ? 'formatted_value' : false, {
156
160
  style: {
157
- fontSize: _this.getLabelFontSize(),
161
+ fontSize: this.getLabelFontSize(),
158
162
  fill: themeColors.textColor
159
163
  }
160
- }).position('name*value').color('group_name', currentTheme && currentTheme.colors).tooltip('name*formatted_value*raw_name', function (name, value, raw_name) {
161
- var nameContent = !raw_name && typeof raw_name !== 'number' ? intl.get(EMPTY_NAME) : raw_name;
162
- var titleContent = y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method]);
164
+ }).position('name*value').color('group_name', currentTheme && currentTheme.colors).tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
165
+ const nameContent = !raw_name && typeof raw_name !== 'number' ? intl.get(EMPTY_NAME) : raw_name;
166
+ const titleContent = y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method]);
163
167
  return {
164
- value: value,
168
+ value,
165
169
  title: titleContent,
166
170
  name: nameContent
167
171
  };
@@ -173,57 +177,60 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
173
177
  }
174
178
  });
175
179
  };
176
- _this.setTooltip = function () {
177
- _this.chart.tooltip({
180
+ this.setTooltip = () => {
181
+ this.chart.tooltip({
178
182
  showTitle: true,
179
183
  showMarkers: false,
180
184
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
181
185
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
182
186
  domStyles: {
183
- 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
184
- 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
187
+ 'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
188
+ 'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
185
189
  }
186
190
  });
187
191
  };
188
- _this.drawIncreaseLine = function (_ref2) {
189
- var themeColors = _ref2.themeColors;
190
- var _this$props$statItem3 = _this.props.statItem,
191
- increase_line_color = _this$props$statItem3.increase_line_color,
192
- display_increase_percentage = _this$props$statItem3.display_increase_percentage;
193
- _this.chart.line().position('name*increase_value').size(3).color(increase_line_color || '#fbd44a').shape('smooth').tooltip('name*increase_value', function (name, value) {
192
+ this.drawIncreaseLine = _ref2 => {
193
+ let {
194
+ themeColors
195
+ } = _ref2;
196
+ const {
197
+ increase_line_color,
198
+ display_increase_percentage
199
+ } = this.props.statItem;
200
+ this.chart.line().position('name*increase_value').size(3).color(increase_line_color || '#fbd44a').shape('smooth').tooltip('name*increase_value', (name, value) => {
194
201
  return {
195
202
  title: intl.get(TITLE_INCREASE),
196
- value: _this.getNumberDisplayString(value || 0, {
203
+ value: this.getNumberDisplayString(value || 0, {
197
204
  format: 'percent'
198
205
  }),
199
206
  name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
200
207
  };
201
208
  });
202
- _this.chart.point().label(display_increase_percentage ? 'increase_value' : false, function (value) {
209
+ this.chart.point().label(display_increase_percentage ? 'increase_value' : false, value => {
203
210
  return {
204
- content: _this.getNumberDisplayString(value || 0, {
211
+ content: this.getNumberDisplayString(value || 0, {
205
212
  format: 'percent'
206
213
  }),
207
214
  style: {
208
215
  fill: themeColors.textColor
209
216
  }
210
217
  };
211
- }).color(increase_line_color || '#fbd44a').position('name*increase_value').size(3).tooltip('name*increase_value', function (name, value) {
218
+ }).color(increase_line_color || '#fbd44a').position('name*increase_value').size(3).tooltip('name*increase_value', (name, value) => {
212
219
  return {
213
220
  title: intl.get(TITLE_INCREASE),
214
- value: _this.getNumberDisplayString(value || 0, {
221
+ value: this.getNumberDisplayString(value || 0, {
215
222
  format: 'percent'
216
223
  }),
217
224
  name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
218
225
  };
219
226
  });
220
- _this.chart.axis('increase_value', {
227
+ this.chart.axis('increase_value', {
221
228
  label: null,
222
229
  grid: null
223
230
  });
224
231
  };
225
- _this.setAxis = function (themeColors) {
226
- _this.chart.axis('name', {
232
+ this.setAxis = themeColors => {
233
+ this.chart.axis('name', {
227
234
  line: {
228
235
  style: themeColors.gridColor
229
236
  },
@@ -232,10 +239,10 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
232
239
  style: {
233
240
  fill: themeColors.textColor
234
241
  },
235
- formatter: _this.labelFormatter
242
+ formatter: this.labelFormatter
236
243
  }
237
244
  });
238
- _this.chart.axis('value', {
245
+ this.chart.axis('value', {
239
246
  label: {
240
247
  style: {
241
248
  fill: themeColors.textColor
@@ -250,15 +257,15 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
250
257
  }
251
258
  });
252
259
  };
253
- _this.setLegend = function (themeColors) {
254
- var legendPosition = 'bottom';
255
- _this.chart.legend('group_name', {
260
+ this.setLegend = themeColors => {
261
+ let legendPosition = 'bottom';
262
+ this.chart.legend('group_name', {
256
263
  position: legendPosition,
257
264
  itemName: {
258
265
  style: {
259
266
  fill: themeColors.textColor
260
267
  },
261
- formatter: function formatter(name) {
268
+ formatter: name => {
262
269
  return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
263
270
  }
264
271
  },
@@ -278,35 +285,37 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
278
285
  }
279
286
  });
280
287
  };
281
- _this.renderAxisLabel = function (newStatItem) {
282
- var _this$props3 = _this.props,
283
- getTableById = _this$props3.getTableById,
284
- statItem = _this$props3.statItem;
288
+ this.renderAxisLabel = newStatItem => {
289
+ let {
290
+ getTableById,
291
+ statItem
292
+ } = this.props;
285
293
  if (newStatItem && newStatItem._id !== statItem._id) {
286
294
  return;
287
295
  }
288
- if (!_this.chart) return;
296
+ if (!this.chart) return;
289
297
  statItem = newStatItem || statItem;
290
- var _statItem = statItem,
291
- table_id = _statItem.table_id,
292
- x_axis_column_key = _statItem.x_axis_column_key,
293
- y_axis_column_key = _statItem.y_axis_column_key,
294
- show_y_axis_label = _statItem.show_y_axis_label,
295
- show_x_axis_label = _statItem.show_x_axis_label,
296
- y_axis_label_position = _statItem.y_axis_label_position,
297
- x_axis_label_position = _statItem.x_axis_label_position,
298
- y_axis_summary_type = _statItem.y_axis_summary_type;
299
- var table = getTableById(table_id);
300
- var autoPadding = _this.chart.autoPadding;
301
- var textColor = _this.getAxisLabelColor();
302
- var xAxisID = "chart-x-axis-label_".concat(statItem._id);
303
- var chartContainer = _this.chart.getCanvas().get('container');
304
- var xLabel = chartContainer.querySelector("#".concat(xAxisID));
298
+ const {
299
+ table_id,
300
+ x_axis_column_key,
301
+ y_axis_column_key,
302
+ show_y_axis_label,
303
+ show_x_axis_label,
304
+ y_axis_label_position,
305
+ x_axis_label_position,
306
+ y_axis_summary_type
307
+ } = statItem;
308
+ const table = getTableById(table_id);
309
+ const autoPadding = this.chart.autoPadding;
310
+ const textColor = this.getAxisLabelColor();
311
+ const xAxisID = "chart-x-axis-label_".concat(statItem._id);
312
+ const chartContainer = this.chart.getCanvas().get('container');
313
+ const xLabel = chartContainer.querySelector("#".concat(xAxisID));
305
314
  if (!xLabel && show_x_axis_label) {
306
- var div = document.createElement('div');
315
+ const div = document.createElement('div');
307
316
  div.id = xAxisID;
308
317
  div.className = 'statistic-chart-axis-label';
309
- var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
318
+ const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
310
319
  div.innerHTML = "".concat(column ? column.name : '');
311
320
  div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
312
321
  chartContainer.appendChild(div);
@@ -317,158 +326,151 @@ var CompareChart = /*#__PURE__*/function (_BaseChart) {
317
326
  if (xLabel && !show_x_axis_label) {
318
327
  xLabel.parentNode.removeChild(xLabel);
319
328
  }
320
- var yAxisID = "chart-y-axis-label_".concat(statItem._id);
321
- var yLabel = chartContainer.querySelector("#".concat(yAxisID));
322
- var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
329
+ const yAxisID = "chart-y-axis-label_".concat(statItem._id);
330
+ const yLabel = chartContainer.querySelector("#".concat(yAxisID));
331
+ let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
323
332
  if (!yLabel && show_y_axis_label) {
324
- var _div = document.createElement('div');
325
- _div.id = yAxisID;
326
- _div.className = 'statistic-chart-axis-label';
333
+ const div = document.createElement('div');
334
+ div.id = yAxisID;
335
+ div.className = 'statistic-chart-axis-label';
327
336
  if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
328
- _div.innerHTML = intl.get(TITLE_AMOUNT);
337
+ div.innerHTML = intl.get(TITLE_AMOUNT);
329
338
  } else {
330
- var _column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
331
- _div.innerHTML = _column.name || '';
339
+ const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
340
+ div.innerHTML = column.name || '';
332
341
  }
333
- var containerHeight = chartContainer.offsetHeight;
334
- var textAlign = 'center';
342
+ const containerHeight = chartContainer.offsetHeight;
343
+ let textAlign = 'center';
335
344
  if (y_axis_label_position === 'bottom') textAlign = 'left';
336
345
  if (y_axis_label_position === 'top') textAlign = 'right';
337
- _div.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
338
- chartContainer.appendChild(_div);
346
+ div.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
347
+ chartContainer.appendChild(div);
339
348
  }
340
349
  if (yLabel && show_y_axis_label) {
341
- var _containerHeight = chartContainer.offsetHeight;
342
- var _textAlign = 'center';
343
- if (y_axis_label_position === 'bottom') _textAlign = 'left';
344
- if (y_axis_label_position === 'top') _textAlign = 'right';
345
- yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(_containerHeight, "px; text-align: ").concat(_textAlign, "; top: 0; left: 0px; transform: translate(-").concat(_containerHeight / 2 + 12, "px, ").concat((_containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
350
+ const containerHeight = chartContainer.offsetHeight;
351
+ let textAlign = 'center';
352
+ if (y_axis_label_position === 'bottom') textAlign = 'left';
353
+ if (y_axis_label_position === 'top') textAlign = 'right';
354
+ yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
346
355
  }
347
356
  if (yLabel && !show_y_axis_label) {
348
357
  yLabel.parentNode.removeChild(yLabel);
349
358
  }
350
359
  };
351
- _this.destroyChart = function () {
352
- _this.chart.destroy();
353
- _this.chart = null;
360
+ this.destroyChart = () => {
361
+ this.chart.destroy();
362
+ this.chart = null;
354
363
  };
355
- _this.state = {
364
+ this.state = {
356
365
  isCalculatingData: true,
357
366
  showResultDescription: true
358
367
  };
359
- _this.calculateData = null;
360
- return _this;
368
+ this.calculateData = null;
361
369
  }
362
- _createClass(CompareChart, [{
363
- key: "componentDidMount",
364
- value: function componentDidMount() {
365
- var _this2 = this;
366
- var _this$props4 = this.props,
367
- statItem = _this$props4.statItem,
368
- chartCalculator = _this$props4.chartCalculator,
369
- eventBus = _this$props4.eventBus;
370
- this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
371
- _this2.renderAxisLabel(newStatItem);
370
+ componentDidMount() {
371
+ const {
372
+ statItem,
373
+ chartCalculator,
374
+ eventBus
375
+ } = this.props;
376
+ this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
377
+ this.renderAxisLabel(newStatItem);
378
+ });
379
+ if (this.container) {
380
+ chartCalculator.calculate(statItem).then(data => {
381
+ let showResultDescription = data.length > 0 ? false : true;
382
+ this.setState({
383
+ isCalculatingData: false,
384
+ showResultDescription
385
+ }, () => {
386
+ if (!showResultDescription) {
387
+ this.drawChart(data);
388
+ this.calculateData = data;
389
+ }
390
+ });
391
+ });
392
+ }
393
+ }
394
+ shouldComponentUpdate(nextProps, nextState) {
395
+ const {
396
+ colorThemeName
397
+ } = this.props;
398
+ if (this.canUpdate(this.props, nextProps)) {
399
+ return true;
400
+ }
401
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
402
+ return true;
403
+ }
404
+ if (nextProps.colorThemeName !== colorThemeName) {
405
+ return true;
406
+ }
407
+ return false;
408
+ }
409
+ componentDidUpdate(preProps, preState) {
410
+ const {
411
+ statItem,
412
+ chartCalculator
413
+ } = this.props;
414
+ const {
415
+ isCalculatingData
416
+ } = this.state;
417
+ if (isCalculatingData !== preState.isCalculatingData) return;
418
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
419
+ this.setState({
420
+ isCalculatingData: true
372
421
  });
373
422
  if (this.container) {
374
- chartCalculator.calculate(statItem).then(function (data) {
375
- var showResultDescription = data.length > 0 ? false : true;
376
- _this2.setState({
423
+ chartCalculator.calculate(statItem).then(data => {
424
+ const showResultDescription = data.length > 0 ? false : true;
425
+ this.chart && this.destroyChart();
426
+ this.calculateData = data;
427
+ this.setState({
377
428
  isCalculatingData: false,
378
- showResultDescription: showResultDescription
379
- }, function () {
429
+ showResultDescription
430
+ }, () => {
380
431
  if (!showResultDescription) {
381
- _this2.drawChart(data);
382
- _this2.calculateData = data;
432
+ this.drawChart(data);
433
+ if (this.props.isPreview) {
434
+ this.chart.forceFit();
435
+ }
383
436
  }
384
437
  });
385
438
  });
386
439
  }
387
- }
388
- }, {
389
- key: "shouldComponentUpdate",
390
- value: function shouldComponentUpdate(nextProps, nextState) {
391
- var colorThemeName = this.props.colorThemeName;
392
- if (this.canUpdate(this.props, nextProps)) {
393
- return true;
394
- }
395
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
396
- return true;
397
- }
398
- if (nextProps.colorThemeName !== colorThemeName) {
399
- return true;
400
- }
401
- return false;
402
- }
403
- }, {
404
- key: "componentDidUpdate",
405
- value: function componentDidUpdate(preProps, preState) {
406
- var _this3 = this;
407
- var _this$props5 = this.props,
408
- statItem = _this$props5.statItem,
409
- chartCalculator = _this$props5.chartCalculator;
410
- var isCalculatingData = this.state.isCalculatingData;
411
- if (isCalculatingData !== preState.isCalculatingData) return;
412
- if (this.shouldCalculateStatItem(preProps, this.props)) {
413
- this.setState({
414
- isCalculatingData: true
415
- });
416
- if (this.container) {
417
- chartCalculator.calculate(statItem).then(function (data) {
418
- var showResultDescription = data.length > 0 ? false : true;
419
- _this3.chart && _this3.destroyChart();
420
- _this3.calculateData = data;
421
- _this3.setState({
422
- isCalculatingData: false,
423
- showResultDescription: showResultDescription
424
- }, function () {
425
- if (!showResultDescription) {
426
- _this3.drawChart(data);
427
- if (_this3.props.isPreview) {
428
- _this3.chart.forceFit();
429
- }
430
- }
431
- });
432
- });
433
- }
434
- } else {
435
- if (!this.state.showResultDescription) {
436
- this.chart && this.destroyChart();
437
- this.drawChart(this.calculateData);
438
- if (this.props.isPreview) {
439
- this.chart.forceFit();
440
- }
440
+ } else {
441
+ if (!this.state.showResultDescription) {
442
+ this.chart && this.destroyChart();
443
+ this.drawChart(this.calculateData);
444
+ if (this.props.isPreview) {
445
+ this.chart.forceFit();
441
446
  }
442
447
  }
443
448
  }
444
- }, {
445
- key: "componentWillUnmount",
446
- value: function componentWillUnmount() {
447
- this.container = null;
448
- this.unsubscribeStyleChange();
449
- }
450
- }, {
451
- key: "render",
452
- value: function render() {
453
- var _this4 = this;
454
- var statItem = this.props.statItem;
455
- var _this$state = this.state,
456
- isCalculatingData = _this$state.isCalculatingData,
457
- showResultDescription = _this$state.showResultDescription;
458
- var show_y_axis_label = statItem.show_y_axis_label,
459
- show_x_axis_label = statItem.show_x_axis_label;
460
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
461
- ref: function ref(_ref3) {
462
- return _this4.container = _ref3;
463
- },
464
- style: {
465
- padding: show_y_axis_label || show_x_axis_label ? 30 : 20
466
- },
467
- className: "statistic-chart-container"
468
- }));
469
- }
470
- }]);
471
- return CompareChart;
472
- }(BaseChart);
449
+ }
450
+ componentWillUnmount() {
451
+ this.container = null;
452
+ this.unsubscribeStyleChange();
453
+ }
454
+ render() {
455
+ const {
456
+ statItem
457
+ } = this.props;
458
+ const {
459
+ isCalculatingData,
460
+ showResultDescription
461
+ } = this.state;
462
+ const {
463
+ show_y_axis_label,
464
+ show_x_axis_label
465
+ } = statItem;
466
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
467
+ ref: ref => this.container = ref,
468
+ style: {
469
+ padding: show_y_axis_label || show_x_axis_label ? 30 : 20
470
+ },
471
+ className: "statistic-chart-container"
472
+ }));
473
+ }
474
+ }
473
475
  CompareChart.propTypes = propTypes;
474
476
  export default CompareChart;