dtable-statistic 4.2.1 → 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 DataSet from '@antv/data-set';
@@ -13,7 +9,7 @@ import { getCurrentTheme, sortDataByGroupSum } from '../utils/common-utils';
13
9
  import { getChartGroups } from '../utils/basic-chart-utils';
14
10
  import { getConvertedColorRules, getLabelColor } from '../utils/color-utils';
15
11
  import { EMPTY_NAME, DEFAULT_NUMBER_FORMAT_OBJECT, SUMMARY_TYPE, STATISTICS_COUNT_SHOW, LABEL_CONFIG_CHANGED, STAT_TYPE, TITLE_AMOUNT, TYPE_COLOR_USING, STATISTICS_COUNT_TYPE } from '../constants';
16
- var propTypes = {
12
+ const propTypes = {
17
13
  isPreview: PropTypes.bool,
18
14
  isEdit: PropTypes.bool,
19
15
  colorThemeName: PropTypes.string,
@@ -23,44 +19,43 @@ var propTypes = {
23
19
  getTableById: PropTypes.func,
24
20
  toggleStatisticRecordsDialog: PropTypes.func
25
21
  };
26
- var BarChart = /*#__PURE__*/function (_BaseChart) {
27
- _inherits(BarChart, _BaseChart);
28
- var _super = _createSuper(BarChart);
29
- function BarChart(props) {
30
- var _this;
31
- _classCallCheck(this, BarChart);
32
- _this = _super.call(this, props);
33
- _this.drawChart = function (originalData) {
34
- var _this$props = _this.props,
35
- getTableById = _this$props.getTableById,
36
- statItem = _this$props.statItem,
37
- colorThemeName = _this$props.colorThemeName;
38
- var type = statItem.type,
39
- table_id = statItem.table_id,
40
- summary_type = statItem.summary_type,
41
- y_axis_column_key = statItem.y_axis_column_key,
42
- y_axis_summary_type = statItem.y_axis_summary_type,
43
- summary_method = statItem.summary_method,
44
- y_axis_summary_method = statItem.y_axis_summary_method,
45
- column_groupby_column_key = statItem.column_groupby_column_key,
46
- column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
47
- sort_type = statItem.sort_type;
48
- var data = originalData;
22
+ class BarChart extends BaseChart {
23
+ constructor(props) {
24
+ super(props);
25
+ this.drawChart = originalData => {
26
+ const {
27
+ getTableById,
28
+ statItem,
29
+ colorThemeName
30
+ } = this.props;
31
+ const {
32
+ type,
33
+ table_id,
34
+ summary_type,
35
+ y_axis_column_key,
36
+ y_axis_summary_type,
37
+ summary_method,
38
+ y_axis_summary_method,
39
+ column_groupby_column_key,
40
+ column_groupby_multiple_numeric_column,
41
+ sort_type
42
+ } = statItem;
43
+ let data = originalData;
49
44
  if (type == STAT_TYPE.BAR_STACK && sort_type) {
50
45
  data = sortDataByGroupSum(originalData, sort_type);
51
46
  }
52
- _this.initChartHandler();
53
- _this.chart.on('interval:click', function (e) {
54
- _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
47
+ this.initChartHandler();
48
+ this.chart.on('interval:click', e => {
49
+ this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
55
50
  });
56
- var isGroupBar = column_groupby_column_key || column_groupby_multiple_numeric_column;
57
- var currentTheme = getCurrentTheme(colorThemeName);
58
- var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
59
- var summaryType = summary_type;
60
- var summaryMethod = summary_method;
51
+ const isGroupBar = column_groupby_column_key || column_groupby_multiple_numeric_column;
52
+ const currentTheme = getCurrentTheme(colorThemeName);
53
+ let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
54
+ let summaryType = summary_type;
55
+ let summaryMethod = summary_method;
61
56
  if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
62
- var table = getTableById(table_id);
63
- var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
57
+ const table = getTableById(table_id);
58
+ const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
64
59
  summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
65
60
  }
66
61
  if (!summaryType && y_axis_summary_type) {
@@ -69,65 +64,70 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
69
64
  if (!summaryMethod && y_axis_summary_method) {
70
65
  summaryMethod = y_axis_summary_method;
71
66
  }
72
- var chartBarColor = '#2a67d1';
67
+ let chartBarColor = '#2a67d1';
73
68
  if (isGroupBar) {
74
69
  chartBarColor = 'group_name';
75
- _this.chart.scale('group_name', {
70
+ this.chart.scale('group_name', {
76
71
  type: 'cat'
77
72
  });
78
73
  } else if (currentTheme && currentTheme.colors) {
79
74
  chartBarColor = currentTheme.colors[0];
80
75
  }
81
- _this.chart.data(data, {
76
+ this.chart.data(data, {
82
77
  'name': {
83
78
  type: 'cat',
84
79
  nice: false
85
80
  }
86
81
  });
87
- var width = _this.chart.coordinateBBox.width;
88
- var chartData = isGroupBar ? getChartGroups(data) : data;
89
- var themeColors = _this.getThemeColors();
90
- var ticks = _this.getTicks(chartData, width);
82
+ const {
83
+ width
84
+ } = this.chart.coordinateBBox;
85
+ const chartData = isGroupBar ? getChartGroups(data) : data;
86
+ const themeColors = this.getThemeColors();
87
+ const ticks = this.getTicks(chartData, width);
91
88
  if (ticks.length > 0) {
92
- _this.chart.scale('name', {
93
- ticks: ticks
89
+ this.chart.scale('name', {
90
+ ticks
94
91
  });
95
92
  }
96
93
 
97
94
  // set Coord type
98
- _this.chart.coordinate('rect');
99
- _this.handleAutoRange(data, summaryColumnData, summaryMethod);
95
+ this.chart.coordinate('rect');
96
+ this.handleAutoRange(data, summaryColumnData, summaryMethod);
100
97
  if (isGroupBar) {
101
- _this.drawBarGroup({
102
- data: data,
103
- themeColors: themeColors,
104
- currentTheme: currentTheme,
105
- summaryColumnData: summaryColumnData,
106
- summaryType: summaryType,
107
- summaryMethod: summaryMethod
98
+ this.drawBarGroup({
99
+ data,
100
+ themeColors,
101
+ currentTheme,
102
+ summaryColumnData,
103
+ summaryType,
104
+ summaryMethod
108
105
  });
109
106
  } else {
110
- _this.drawBar({
111
- themeColors: themeColors,
112
- chartBarColor: chartBarColor,
113
- summaryType: summaryType,
114
- summaryMethod: summaryMethod
107
+ this.drawBar({
108
+ themeColors,
109
+ chartBarColor,
110
+ summaryType,
111
+ summaryMethod
115
112
  });
116
113
  }
117
- _this.setTooltip();
118
- _this.setAxis(themeColors);
119
- _this.setLegend(themeColors);
120
- _this.chart.interaction('active-region');
121
- _this.chart.render();
122
- _this.renderAxisLabel();
114
+ this.setTooltip();
115
+ this.setAxis(themeColors);
116
+ this.setLegend(themeColors);
117
+ this.chart.interaction('active-region');
118
+ this.chart.render();
119
+ this.renderAxisLabel();
123
120
  };
124
- _this.initChartHandler = function () {
125
- var _this$props2 = _this.props,
126
- isPreview = _this$props2.isPreview,
127
- statItem = _this$props2.statItem;
128
- var display_data = statItem.display_data;
129
- var config = {
130
- container: _this.container,
121
+ this.initChartHandler = () => {
122
+ const {
123
+ isPreview,
124
+ statItem
125
+ } = this.props;
126
+ const {
127
+ display_data
128
+ } = statItem;
129
+ let config = {
130
+ container: this.container,
131
131
  autoFit: true,
132
132
  appendPadding: [display_data ? 17 : 0, 0, 0, 0]
133
133
  };
@@ -135,25 +135,31 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
135
135
  config.height = 400;
136
136
  config.width = 700;
137
137
  }
138
- _this.chart = new Chart(config);
138
+ this.chart = new Chart(config);
139
139
  };
140
- _this.drawBar = function (_ref) {
141
- var themeColors = _ref.themeColors,
142
- chartBarColor = _ref.chartBarColor,
143
- summaryType = _ref.summaryType,
144
- summaryMethod = _ref.summaryMethod;
145
- var statItem = _this.props.statItem;
146
- var color_option = statItem.color_option,
147
- display_data = statItem.display_data;
148
- var colorRules = color_option === TYPE_COLOR_USING.USE_RULES && statItem.y_axis_label_color_rules && getConvertedColorRules(statItem.y_axis_label_color_rules);
149
- _this.chart.interval().label(display_data ? 'formatted_value' : false, {
140
+ this.drawBar = _ref => {
141
+ let {
142
+ themeColors,
143
+ chartBarColor,
144
+ summaryType,
145
+ summaryMethod
146
+ } = _ref;
147
+ const {
148
+ statItem
149
+ } = this.props;
150
+ const {
151
+ color_option,
152
+ display_data
153
+ } = statItem;
154
+ const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && statItem.y_axis_label_color_rules && getConvertedColorRules(statItem.y_axis_label_color_rules);
155
+ this.chart.interval().label(display_data ? 'formatted_value' : false, {
150
156
  style: {
151
- fontSize: _this.getLabelFontSize(),
157
+ fontSize: this.getLabelFontSize(),
152
158
  fill: themeColors.textColor
153
159
  }
154
- }).position('name*value').tooltip('name*formatted_value', function (name, value) {
160
+ }).position('name*value').tooltip('name*formatted_value', (name, value) => {
155
161
  return {
156
- value: value,
162
+ value,
157
163
  title: summaryType === STATISTICS_COUNT_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod]),
158
164
  name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
159
165
  };
@@ -163,37 +169,43 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
163
169
  stroke: null
164
170
  }
165
171
  }
166
- }).style('value', function (value) {
167
- var color = getLabelColor({
172
+ }).style('value', value => {
173
+ const color = getLabelColor({
168
174
  chart: statItem,
169
- colorRules: colorRules,
170
- value: value
175
+ colorRules,
176
+ value
171
177
  });
172
178
  return {
173
179
  fill: color || chartBarColor
174
180
  };
175
181
  });
176
182
  };
177
- _this.drawBarGroup = function (_ref2) {
178
- var data = _ref2.data,
179
- themeColors = _ref2.themeColors,
180
- summaryColumnData = _ref2.summaryColumnData,
181
- summaryType = _ref2.summaryType,
182
- summaryMethod = _ref2.summaryMethod,
183
- currentTheme = _ref2.currentTheme;
184
- var statItem = _this.props.statItem;
185
- var chartType = statItem.type,
186
- color_option = statItem.color_option,
187
- display_data = statItem.display_data,
188
- y_axis_use_stack = statItem.y_axis_use_stack,
189
- display_each_block_data = statItem.display_each_block_data;
190
- var labelCfg = {
183
+ this.drawBarGroup = _ref2 => {
184
+ let {
185
+ data,
186
+ themeColors,
187
+ summaryColumnData,
188
+ summaryType,
189
+ summaryMethod,
190
+ currentTheme
191
+ } = _ref2;
192
+ const {
193
+ statItem
194
+ } = this.props;
195
+ const {
196
+ type: chartType,
197
+ color_option,
198
+ display_data,
199
+ y_axis_use_stack,
200
+ display_each_block_data
201
+ } = statItem;
202
+ let labelCfg = {
191
203
  style: {
192
- fontSize: _this.getLabelFontSize(),
204
+ fontSize: this.getLabelFontSize(),
193
205
  fill: themeColors.textColor
194
206
  }
195
207
  };
196
- var displayData = display_data;
208
+ let displayData = display_data;
197
209
  if (chartType == STAT_TYPE.BAR_STACK) {
198
210
  displayData = display_each_block_data;
199
211
  if (displayData) {
@@ -201,7 +213,7 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
201
213
  }
202
214
 
203
215
  // get the total value of each stack
204
- var dv = new DataSet.DataView().source(data);
216
+ const dv = new DataSet.DataView().source(data);
205
217
  dv.transform({
206
218
  type: 'aggregate',
207
219
  fields: ['value'],
@@ -210,9 +222,9 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
210
222
  groupBy: ['name']
211
223
  });
212
224
  if (display_data) {
213
- dv.rows.forEach(function (item) {
214
- _this.chart.annotation().text({
215
- content: _this.getNumberDisplayString(item.value_sum, summaryColumnData, summaryMethod),
225
+ dv.rows.forEach(item => {
226
+ this.chart.annotation().text({
227
+ content: this.getNumberDisplayString(item.value_sum, summaryColumnData, summaryMethod),
216
228
  position: {
217
229
  name: item.name,
218
230
  value: item.value_sum
@@ -223,31 +235,31 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
223
235
  });
224
236
  }
225
237
  }
226
- var groupColorCallback = currentTheme && currentTheme.colors;
238
+ let groupColorCallback = currentTheme && currentTheme.colors;
227
239
 
228
240
  // when the 'Group by' column is a 'single-select' column,
229
241
  // and the user chooses to use the colors from the column.
230
242
  if (color_option === TYPE_COLOR_USING.USE_COLUMN_COLORS) {
231
- var groupColorMapping = {};
232
- data.forEach(function (item) {
243
+ const groupColorMapping = {};
244
+ data.forEach(item => {
233
245
  if (!groupColorMapping[item.group_name]) {
234
246
  groupColorMapping[item.group_name] = item.color;
235
247
  }
236
248
  });
237
- groupColorCallback = function groupColorCallback(group_name) {
249
+ groupColorCallback = group_name => {
238
250
  return groupColorMapping[group_name];
239
251
  };
240
252
  }
241
- _this.chart.scale({
253
+ this.chart.scale({
242
254
  group_name: {
243
255
  type: 'cat'
244
256
  }
245
257
  });
246
- _this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name*raw_name', function (name, value, group_name, raw_name) {
247
- var nameContent = !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name;
248
- var titleContent = !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
258
+ 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) => {
259
+ const nameContent = !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name;
260
+ const titleContent = !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
249
261
  return {
250
- value: value,
262
+ value,
251
263
  title: titleContent,
252
264
  name: nameContent
253
265
  };
@@ -261,14 +273,15 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
261
273
  }
262
274
  });
263
275
  };
264
- _this.handleAutoRange = function (data, summaryColumnData, summaryMethod) {
265
- var _this$props$statItem = _this.props.statItem,
266
- y_axis_auto_range = _this$props$statItem.y_axis_auto_range,
267
- y_axis_min = _this$props$statItem.y_axis_min,
268
- y_axis_max = _this$props$statItem.y_axis_max;
269
- var valueScaleOptions = {
270
- formatter: function formatter(value) {
271
- return _this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
276
+ this.handleAutoRange = (data, summaryColumnData, summaryMethod) => {
277
+ const {
278
+ y_axis_auto_range,
279
+ y_axis_min,
280
+ y_axis_max
281
+ } = this.props.statItem;
282
+ let valueScaleOptions = {
283
+ formatter: value => {
284
+ return this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
272
285
  }
273
286
  };
274
287
 
@@ -284,14 +297,14 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
284
297
  });
285
298
 
286
299
  // set the filter rule
287
- _this.chart.filter('value', function (value) {
300
+ this.chart.filter('value', value => {
288
301
  return value >= y_axis_min;
289
302
  });
290
303
 
291
304
  // filter the data
292
- _this.chart.filterData(data);
305
+ this.chart.filterData(data);
293
306
  }
294
- _this.chart.scale({
307
+ this.chart.scale({
295
308
  // Set the type of the name column so that g2 can draw correctly
296
309
  name: {
297
310
  type: 'cat'
@@ -299,20 +312,20 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
299
312
  value: valueScaleOptions
300
313
  });
301
314
  };
302
- _this.setTooltip = function () {
303
- _this.chart.tooltip({
315
+ this.setTooltip = () => {
316
+ this.chart.tooltip({
304
317
  showTitle: true,
305
318
  showMarkers: false,
306
319
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
307
320
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
308
321
  domStyles: {
309
- 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
310
- 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
322
+ 'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
323
+ 'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
311
324
  }
312
325
  });
313
326
  };
314
- _this.setAxis = function (themeColors) {
315
- _this.chart.axis('name', {
327
+ this.setAxis = themeColors => {
328
+ this.chart.axis('name', {
316
329
  line: {
317
330
  style: themeColors.gridColor
318
331
  },
@@ -321,10 +334,10 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
321
334
  style: {
322
335
  fill: themeColors.textColor
323
336
  },
324
- formatter: _this.labelFormatter
337
+ formatter: this.labelFormatter
325
338
  }
326
339
  });
327
- _this.chart.axis('value', {
340
+ this.chart.axis('value', {
328
341
  label: {
329
342
  style: {
330
343
  fill: themeColors.textColor
@@ -339,15 +352,15 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
339
352
  }
340
353
  });
341
354
  };
342
- _this.setLegend = function (themeColors) {
343
- var legendPosition = 'bottom';
344
- _this.chart.legend('group_name', {
355
+ this.setLegend = themeColors => {
356
+ let legendPosition = 'bottom';
357
+ this.chart.legend('group_name', {
345
358
  position: legendPosition,
346
359
  itemName: {
347
360
  style: {
348
361
  fill: themeColors.textColor
349
362
  },
350
- formatter: function formatter(name) {
363
+ formatter: name => {
351
364
  return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
352
365
  }
353
366
  },
@@ -367,37 +380,39 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
367
380
  }
368
381
  });
369
382
  };
370
- _this.renderAxisLabel = function (newStatItem) {
371
- var _this$props3 = _this.props,
372
- getTableById = _this$props3.getTableById,
373
- statItem = _this$props3.statItem;
383
+ this.renderAxisLabel = newStatItem => {
384
+ let {
385
+ getTableById,
386
+ statItem
387
+ } = this.props;
374
388
  if (newStatItem && newStatItem._id !== statItem._id) {
375
389
  return;
376
390
  }
377
- if (!_this.chart) return;
391
+ if (!this.chart) return;
378
392
  statItem = newStatItem || statItem;
379
- var _statItem = statItem,
380
- type = _statItem.type,
381
- table_id = _statItem.table_id,
382
- x_axis_column_key = _statItem.x_axis_column_key,
383
- y_axis_column_key = _statItem.y_axis_column_key,
384
- show_y_axis_label = _statItem.show_y_axis_label,
385
- show_x_axis_label = _statItem.show_x_axis_label,
386
- y_axis_label_position = _statItem.y_axis_label_position,
387
- x_axis_label_position = _statItem.x_axis_label_position,
388
- y_axis_summary_type = _statItem.y_axis_summary_type,
389
- title_name = _statItem.title_name;
390
- var table = getTableById(table_id);
391
- var autoPadding = _this.chart.autoPadding;
392
- var textColor = _this.getAxisLabelColor();
393
- var xAxisID = "chart-x-axis-label_".concat(statItem._id);
394
- var chartContainer = _this.chart.getCanvas().get('container');
395
- var xLabel = chartContainer.querySelector("#".concat(xAxisID));
393
+ const {
394
+ type,
395
+ table_id,
396
+ x_axis_column_key,
397
+ y_axis_column_key,
398
+ show_y_axis_label,
399
+ show_x_axis_label,
400
+ y_axis_label_position,
401
+ x_axis_label_position,
402
+ y_axis_summary_type,
403
+ title_name
404
+ } = statItem;
405
+ const table = getTableById(table_id);
406
+ const autoPadding = this.chart.autoPadding;
407
+ const textColor = this.getAxisLabelColor();
408
+ const xAxisID = "chart-x-axis-label_".concat(statItem._id);
409
+ const chartContainer = this.chart.getCanvas().get('container');
410
+ const xLabel = chartContainer.querySelector("#".concat(xAxisID));
396
411
  if (!xLabel && show_x_axis_label) {
397
- var div = document.createElement('div');
412
+ const div = document.createElement('div');
398
413
  div.id = xAxisID;
399
414
  div.className = 'statistic-chart-axis-label';
400
- var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
415
+ const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
401
416
  div.innerHTML = "".concat(column ? column.name : '');
402
417
  div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
403
418
  chartContainer.appendChild(div);
@@ -408,160 +423,153 @@ var BarChart = /*#__PURE__*/function (_BaseChart) {
408
423
  if (xLabel && !show_x_axis_label) {
409
424
  xLabel.parentNode.removeChild(xLabel);
410
425
  }
411
- var yAxisID = "chart-y-axis-label_".concat(statItem._id);
412
- var yLabel = chartContainer.querySelector("#".concat(yAxisID));
413
- var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
426
+ const yAxisID = "chart-y-axis-label_".concat(statItem._id);
427
+ const yLabel = chartContainer.querySelector("#".concat(yAxisID));
428
+ let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
414
429
  if (!yLabel && show_y_axis_label) {
415
- var _div = document.createElement('div');
416
- _div.id = yAxisID;
417
- _div.className = 'statistic-chart-axis-label';
430
+ const div = document.createElement('div');
431
+ div.id = yAxisID;
432
+ div.className = 'statistic-chart-axis-label';
418
433
  if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
419
- _div.innerHTML = intl.get(TITLE_AMOUNT);
434
+ div.innerHTML = intl.get(TITLE_AMOUNT);
420
435
  } else {
421
- var _column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
422
- _div.innerHTML = _column.name || '';
436
+ const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
437
+ div.innerHTML = column.name || '';
423
438
  if (type === STAT_TYPE.BAR_STACK) {
424
- _div.innerHTML = title_name || '';
439
+ div.innerHTML = title_name || '';
425
440
  }
426
441
  }
427
- var containerHeight = chartContainer.offsetHeight;
428
- var textAlign = 'center';
442
+ const containerHeight = chartContainer.offsetHeight;
443
+ let textAlign = 'center';
429
444
  if (y_axis_label_position === 'bottom') textAlign = 'left';
430
445
  if (y_axis_label_position === 'top') textAlign = 'right';
431
- _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)"));
432
- chartContainer.appendChild(_div);
446
+ 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)"));
447
+ chartContainer.appendChild(div);
433
448
  }
434
449
  if (yLabel && show_y_axis_label) {
435
- var _containerHeight = chartContainer.offsetHeight;
436
- var _textAlign = 'center';
437
- if (y_axis_label_position === 'bottom') _textAlign = 'left';
438
- if (y_axis_label_position === 'top') _textAlign = 'right';
439
- 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)"));
450
+ const containerHeight = chartContainer.offsetHeight;
451
+ let textAlign = 'center';
452
+ if (y_axis_label_position === 'bottom') textAlign = 'left';
453
+ if (y_axis_label_position === 'top') textAlign = 'right';
454
+ 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)"));
440
455
  }
441
456
  if (yLabel && !show_y_axis_label) {
442
457
  yLabel.parentNode.removeChild(yLabel);
443
458
  }
444
459
  };
445
- _this.destroyChart = function () {
446
- _this.chart.destroy();
447
- _this.chart = null;
460
+ this.destroyChart = () => {
461
+ this.chart.destroy();
462
+ this.chart = null;
448
463
  };
449
- _this.state = {
464
+ this.state = {
450
465
  isCalculatingData: true,
451
466
  showResultDescription: true
452
467
  };
453
- _this.calculateData = null;
454
- return _this;
468
+ this.calculateData = null;
469
+ }
470
+ componentDidMount() {
471
+ const {
472
+ statItem,
473
+ chartCalculator,
474
+ eventBus
475
+ } = this.props;
476
+ this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
477
+ this.renderAxisLabel(newStatItem);
478
+ });
479
+ if (this.container) {
480
+ chartCalculator.calculate(statItem).then(data => {
481
+ if (!data) return;
482
+ let showResultDescription = data.length > 0 ? false : true;
483
+ this.setState({
484
+ isCalculatingData: false,
485
+ showResultDescription
486
+ }, () => {
487
+ if (!showResultDescription) {
488
+ this.drawChart(data);
489
+ this.calculateData = data;
490
+ }
491
+ });
492
+ });
493
+ }
494
+ }
495
+ shouldComponentUpdate(nextProps, nextState) {
496
+ const {
497
+ colorThemeName
498
+ } = this.props;
499
+ if (this.canUpdate(this.props, nextProps)) {
500
+ return true;
501
+ }
502
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
503
+ return true;
504
+ }
505
+ if (nextProps.colorThemeName !== colorThemeName) {
506
+ return true;
507
+ }
508
+ return false;
455
509
  }
456
- _createClass(BarChart, [{
457
- key: "componentDidMount",
458
- value: function componentDidMount() {
459
- var _this2 = this;
460
- var _this$props4 = this.props,
461
- statItem = _this$props4.statItem,
462
- chartCalculator = _this$props4.chartCalculator,
463
- eventBus = _this$props4.eventBus;
464
- this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
465
- _this2.renderAxisLabel(newStatItem);
510
+ componentDidUpdate(preProps, preState) {
511
+ const {
512
+ statItem,
513
+ chartCalculator
514
+ } = this.props;
515
+ const {
516
+ isCalculatingData
517
+ } = this.state;
518
+ if (isCalculatingData !== preState.isCalculatingData) return;
519
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
520
+ this.setState({
521
+ isCalculatingData: true
466
522
  });
467
523
  if (this.container) {
468
- chartCalculator.calculate(statItem).then(function (data) {
469
- if (!data) return;
470
- var showResultDescription = data.length > 0 ? false : true;
471
- _this2.setState({
524
+ chartCalculator.calculate(statItem).then(data => {
525
+ const showResultDescription = data.length > 0 ? false : true;
526
+ this.chart && this.destroyChart();
527
+ this.calculateData = data;
528
+ this.setState({
472
529
  isCalculatingData: false,
473
- showResultDescription: showResultDescription
474
- }, function () {
530
+ showResultDescription
531
+ }, () => {
475
532
  if (!showResultDescription) {
476
- _this2.drawChart(data);
477
- _this2.calculateData = data;
533
+ this.drawChart(data);
534
+ if (this.props.isPreview) this.chart.forceFit();
478
535
  }
479
536
  });
480
537
  });
481
538
  }
482
- }
483
- }, {
484
- key: "shouldComponentUpdate",
485
- value: function shouldComponentUpdate(nextProps, nextState) {
486
- var colorThemeName = this.props.colorThemeName;
487
- if (this.canUpdate(this.props, nextProps)) {
488
- return true;
489
- }
490
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
491
- return true;
492
- }
493
- if (nextProps.colorThemeName !== colorThemeName) {
494
- return true;
495
- }
496
- return false;
497
- }
498
- }, {
499
- key: "componentDidUpdate",
500
- value: function componentDidUpdate(preProps, preState) {
501
- var _this3 = this;
502
- var _this$props5 = this.props,
503
- statItem = _this$props5.statItem,
504
- chartCalculator = _this$props5.chartCalculator;
505
- var isCalculatingData = this.state.isCalculatingData;
506
- if (isCalculatingData !== preState.isCalculatingData) return;
507
- if (this.shouldCalculateStatItem(preProps, this.props)) {
508
- this.setState({
509
- isCalculatingData: true
510
- });
511
- if (this.container) {
512
- chartCalculator.calculate(statItem).then(function (data) {
513
- var showResultDescription = data.length > 0 ? false : true;
514
- _this3.chart && _this3.destroyChart();
515
- _this3.calculateData = data;
516
- _this3.setState({
517
- isCalculatingData: false,
518
- showResultDescription: showResultDescription
519
- }, function () {
520
- if (!showResultDescription) {
521
- _this3.drawChart(data);
522
- if (_this3.props.isPreview) _this3.chart.forceFit();
523
- }
524
- });
525
- });
526
- }
527
- } else {
528
- if (!this.state.showResultDescription) {
529
- this.chart && this.destroyChart();
530
- this.drawChart(this.calculateData);
531
- if (this.props.isPreview) {
532
- this.chart.forceFit();
533
- }
539
+ } else {
540
+ if (!this.state.showResultDescription) {
541
+ this.chart && this.destroyChart();
542
+ this.drawChart(this.calculateData);
543
+ if (this.props.isPreview) {
544
+ this.chart.forceFit();
534
545
  }
535
546
  }
536
547
  }
537
- }, {
538
- key: "componentWillUnmount",
539
- value: function componentWillUnmount() {
540
- this.container = null;
541
- this.unsubscribeStyleChange();
542
- }
543
- }, {
544
- key: "render",
545
- value: function render() {
546
- var _this4 = this;
547
- var statItem = this.props.statItem;
548
- var _this$state = this.state,
549
- isCalculatingData = _this$state.isCalculatingData,
550
- showResultDescription = _this$state.showResultDescription;
551
- var show_y_axis_label = statItem.show_y_axis_label,
552
- show_x_axis_label = statItem.show_x_axis_label;
553
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
554
- ref: function ref(_ref3) {
555
- return _this4.container = _ref3;
556
- },
557
- style: {
558
- padding: show_y_axis_label || show_x_axis_label ? 30 : 20
559
- },
560
- className: "statistic-chart-container"
561
- }));
562
- }
563
- }]);
564
- return BarChart;
565
- }(BaseChart);
548
+ }
549
+ componentWillUnmount() {
550
+ this.container = null;
551
+ this.unsubscribeStyleChange();
552
+ }
553
+ render() {
554
+ const {
555
+ statItem
556
+ } = this.props;
557
+ const {
558
+ isCalculatingData,
559
+ showResultDescription
560
+ } = this.state;
561
+ const {
562
+ show_y_axis_label,
563
+ show_x_axis_label
564
+ } = statItem;
565
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
566
+ ref: ref => this.container = ref,
567
+ style: {
568
+ padding: show_y_axis_label || show_x_axis_label ? 30 : 20
569
+ },
570
+ className: "statistic-chart-container"
571
+ }));
572
+ }
573
+ }
566
574
  BarChart.propTypes = propTypes;
567
575
  export default BarChart;