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