dtable-statistic 4.2.2 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/es/api/dtable-db-api.js +31 -37
  2. package/es/calculator/base-calculator.js +49 -99
  3. package/es/calculator/basic-chart-calculator.js +335 -559
  4. package/es/calculator/combination-calculator.js +231 -299
  5. package/es/calculator/compare-bar-calculator.js +184 -281
  6. package/es/calculator/completeness-calculator.js +203 -288
  7. package/es/calculator/copy-value.js +18 -18
  8. package/es/calculator/dashboard-calculator.js +68 -137
  9. package/es/calculator/heat-map-calculator.js +139 -220
  10. package/es/calculator/horizontal-bar-calculator.js +64 -93
  11. package/es/calculator/index.js +53 -69
  12. package/es/calculator/map-calculator.js +98 -174
  13. package/es/calculator/mirror-calculator.js +137 -216
  14. package/es/calculator/number-card-calculator.js +58 -126
  15. package/es/calculator/pivot-table-calculator.js +750 -792
  16. package/es/calculator/scatter-calculator.js +72 -140
  17. package/es/calculator/thread-manager.js +48 -67
  18. package/es/calculator/trend-calculator.js +107 -191
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
  20. package/es/calculator/workers/calculator.worker.js +22 -6
  21. package/es/calculator/workers/card-calculator-worker.js +16 -14
  22. package/es/calculator/workers/combination-calculator-worker.js +128 -135
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
  24. package/es/calculator/workers/completeness-calculator-worker.js +56 -49
  25. package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
  26. package/es/calculator/workers/mirror-calculator-worker.js +52 -52
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
  28. package/es/calculator/workers/scatter-calculator-worker.js +34 -32
  29. package/es/calculator/workers/trend-calculator-worker.js +33 -29
  30. package/es/calculator/world-map-calculator.js +120 -197
  31. package/es/components/common-add-tool.js +7 -5
  32. package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
  34. package/es/components/dialog/color-theme-dialog.js +34 -47
  35. package/es/components/dialog/delete-confirmation-dialog.js +7 -5
  36. package/es/components/dialog/enlarged-chart-dialog.js +68 -81
  37. package/es/components/dialog/new-table-dialog.js +62 -80
  38. package/es/components/dialog/new-view-dialog.js +50 -62
  39. package/es/components/dialog/rename-view-dialog.js +49 -58
  40. package/es/components/dialog/statistic-record-dialog/index.js +233 -231
  41. package/es/components/dialog/statistic-types-dialog/index.js +40 -49
  42. package/es/components/dialog/table-select-dialog.js +61 -70
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
  44. package/es/components/dtable-popover.js +62 -81
  45. package/es/components/dtable-search-input.js +89 -99
  46. package/es/components/dtable-select.js +55 -74
  47. package/es/components/icon.js +5 -3
  48. package/es/components/loading.js +1 -1
  49. package/es/components/modal-portal.js +15 -32
  50. package/es/components/popover/color-rules/color-rule.js +137 -141
  51. package/es/components/popover/color-rules/index.js +58 -66
  52. package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
  53. package/es/components/popover/color-rules/rule-filters/index.js +50 -58
  54. package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
  55. package/es/components/popover/color-rules-popover.js +117 -121
  56. package/es/components/popover/color-selector-popover.js +60 -70
  57. package/es/components/seatable-radio/index.js +2 -2
  58. package/es/components/select/option-group.js +139 -157
  59. package/es/components/select/option.js +26 -40
  60. package/es/components/select/select.js +97 -112
  61. package/es/components/toast/alert.js +65 -80
  62. package/es/components/toast/index.js +1 -1
  63. package/es/components/toast/toast.js +76 -103
  64. package/es/components/toast/toastManager.js +57 -93
  65. package/es/components/toast/toaster.js +58 -56
  66. package/es/constants/color-rules.js +8 -5
  67. package/es/constants/dtable-select-style.js +44 -48
  68. package/es/constants/event-types.js +4 -4
  69. package/es/constants/index.js +328 -242
  70. package/es/constants/map.js +2 -2
  71. package/es/constants/model.js +20 -20
  72. package/es/constants/regions.js +1 -1
  73. package/es/constants/zIndexes.js +1 -1
  74. package/es/custom-g2.js +11 -11
  75. package/es/dashboard.js +343 -333
  76. package/es/desktop-dashboard.js +217 -224
  77. package/es/index.js +45 -58
  78. package/es/locale/index.js +3 -3
  79. package/es/locale/lang/de.js +1 -1
  80. package/es/locale/lang/en.js +7 -7
  81. package/es/locale/lang/fr.js +1 -1
  82. package/es/locale/lang/zh_CN.js +1 -1
  83. package/es/mobile-dashboard.js +76 -89
  84. package/es/model/bar-group.js +34 -44
  85. package/es/model/bar.js +26 -36
  86. package/es/model/base-model.js +11 -12
  87. package/es/model/basic-number-card.js +10 -20
  88. package/es/model/collaborators.js +10 -11
  89. package/es/model/combination.js +32 -42
  90. package/es/model/compare-bar.js +30 -40
  91. package/es/model/completeness-group.js +19 -29
  92. package/es/model/completeness.js +14 -24
  93. package/es/model/custom-bar.js +14 -24
  94. package/es/model/dashboard.js +9 -19
  95. package/es/model/generic-model.js +187 -197
  96. package/es/model/heat-map.js +16 -26
  97. package/es/model/horizontal-bar-group.js +32 -42
  98. package/es/model/horizontal-bar.js +26 -36
  99. package/es/model/index.js +31 -3
  100. package/es/model/map.js +20 -30
  101. package/es/model/mirror.js +15 -25
  102. package/es/model/pie.js +21 -31
  103. package/es/model/ring.js +23 -33
  104. package/es/model/scatter.js +11 -21
  105. package/es/model/statistic-dashboard.js +7 -8
  106. package/es/model/table.js +19 -29
  107. package/es/model/trend.js +15 -25
  108. package/es/model/world-map.js +17 -27
  109. package/es/service/chart-service.js +69 -65
  110. package/es/service/dashboard-service.js +421 -419
  111. package/es/service/map-json.js +112 -132
  112. package/es/stat-editor/chart-name-editor.js +44 -58
  113. package/es/stat-editor/index.js +59 -70
  114. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
  115. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
  116. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
  117. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
  118. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
  119. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
  120. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
  121. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
  122. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
  123. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
  124. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
  125. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
  126. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
  127. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
  128. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
  129. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
  130. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
  131. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
  132. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
  133. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
  134. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
  135. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
  136. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
  137. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
  138. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
  139. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
  140. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
  141. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
  143. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
  144. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
  148. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
  149. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
  150. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
  151. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
  152. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
  153. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
  154. package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
  155. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
  156. package/es/stat-editor/stat-settings/map/map-level.js +31 -43
  157. package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
  158. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
  159. package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
  160. package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
  161. package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
  162. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
  163. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
  164. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
  165. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
  166. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
  167. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
  168. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
  169. package/es/stat-list/chart-preview.js +85 -98
  170. package/es/stat-list/index.js +170 -178
  171. package/es/stat-view/area-chart.js +282 -274
  172. package/es/stat-view/bar-chart.js +300 -292
  173. package/es/stat-view/base-chart.js +58 -52
  174. package/es/stat-view/basic-number-card.js +115 -168
  175. package/es/stat-view/combination-chart.js +298 -334
  176. package/es/stat-view/compare-chart.js +256 -254
  177. package/es/stat-view/completeness-chart.js +194 -206
  178. package/es/stat-view/custom-bar.js +221 -223
  179. package/es/stat-view/dashboard-chart.js +122 -180
  180. package/es/stat-view/heat-map.js +268 -294
  181. package/es/stat-view/horizontal-bar-chart.js +291 -281
  182. package/es/stat-view/index.js +136 -152
  183. package/es/stat-view/line-chart.js +267 -265
  184. package/es/stat-view/map.js +246 -246
  185. package/es/stat-view/mirror.js +141 -152
  186. package/es/stat-view/pie-chart.js +143 -156
  187. package/es/stat-view/pivot-table/index.js +113 -118
  188. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
  189. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
  190. package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
  191. package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
  192. package/es/stat-view/ring-chart.js +189 -200
  193. package/es/stat-view/scatter-chart.js +162 -213
  194. package/es/stat-view/treemap-chart.js +136 -200
  195. package/es/stat-view/trend-chart.js +137 -183
  196. package/es/stat-view/world-map.js +233 -243
  197. package/es/tabs/index.js +164 -169
  198. package/es/tabs/tab.js +101 -116
  199. package/es/utils/basic-chart-utils.js +7 -9
  200. package/es/utils/cell-format.js +48 -51
  201. package/es/utils/cell-value.js +1 -1
  202. package/es/utils/collaborator.js +15 -14
  203. package/es/utils/color-utils.js +48 -37
  204. package/es/utils/column-utils.js +47 -33
  205. package/es/utils/column.js +1 -1
  206. package/es/utils/common-utils.js +111 -117
  207. package/es/utils/date-format.js +17 -17
  208. package/es/utils/export-table-utils.js +507 -396
  209. package/es/utils/index.js +6 -6
  210. package/es/utils/map.js +30 -34
  211. package/es/utils/model.js +3 -5
  212. package/es/utils/object.js +4 -4
  213. package/es/utils/pivot-table.js +20 -20
  214. package/es/utils/row-utils.js +41 -33
  215. package/es/utils/search.js +18 -20
  216. package/es/utils/sql-utils.js +132 -98
  217. package/es/utils/stat-utils.js +303 -320
  218. package/es/utils/trend-utils.js +57 -67
  219. package/package.json +2 -2
@@ -1,7 +1,3 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import PropTypes from 'prop-types';
7
3
  import intl from 'react-intl-universal';
@@ -11,7 +7,7 @@ import { Chart } from '../custom-g2';
11
7
  import { getCurrentTheme } from '../utils/common-utils';
12
8
  import { getChartGroups } from '../utils/basic-chart-utils';
13
9
  import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, STATISTICS_COUNT_SHOW, SUMMARY_TYPE, TITLE_AMOUNT, USEABLE_COLOR_TYPES } from '../constants';
14
- var propTypes = {
10
+ const propTypes = {
15
11
  isPreview: PropTypes.bool,
16
12
  isEdit: PropTypes.bool,
17
13
  colorThemeName: PropTypes.string,
@@ -21,35 +17,34 @@ var propTypes = {
21
17
  getTableById: PropTypes.func,
22
18
  toggleStatisticRecordsDialog: PropTypes.func
23
19
  };
24
- var LineChart = /*#__PURE__*/function (_BaseChart) {
25
- _inherits(LineChart, _BaseChart);
26
- var _super = _createSuper(LineChart);
27
- function LineChart(props) {
28
- var _this;
29
- _classCallCheck(this, LineChart);
30
- _this = _super.call(this, props);
31
- _this.drawChart = function (data) {
32
- var _this$props = _this.props,
33
- getTableById = _this$props.getTableById,
34
- statItem = _this$props.statItem,
35
- colorThemeName = _this$props.colorThemeName;
36
- var table_id = statItem.table_id,
37
- summary_type = statItem.summary_type,
38
- y_axis_column_key = statItem.y_axis_column_key,
39
- y_axis_summary_type = statItem.y_axis_summary_type,
40
- summary_method = statItem.summary_method,
41
- y_axis_summary_method = statItem.y_axis_summary_method,
42
- column_groupby_column_key = statItem.column_groupby_column_key,
43
- column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column;
44
- _this.initChartHandler();
45
- _this.chart.on('element:click', function (e) {
20
+ class LineChart extends BaseChart {
21
+ constructor(props) {
22
+ super(props);
23
+ this.drawChart = data => {
24
+ const {
25
+ getTableById,
26
+ statItem,
27
+ colorThemeName
28
+ } = this.props;
29
+ const {
30
+ table_id,
31
+ summary_type,
32
+ y_axis_column_key,
33
+ y_axis_summary_type,
34
+ summary_method,
35
+ y_axis_summary_method,
36
+ column_groupby_column_key,
37
+ column_groupby_multiple_numeric_column
38
+ } = statItem;
39
+ this.initChartHandler();
40
+ this.chart.on('element:click', e => {
46
41
  if (e.data && e.data.data) {
47
- _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
42
+ this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
48
43
  }
49
44
  });
50
- var summaryType = summary_type;
51
- var summaryMethod = summary_method;
52
- var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
45
+ let summaryType = summary_type;
46
+ let summaryMethod = summary_method;
47
+ let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
53
48
  if (!summaryType && y_axis_summary_type) {
54
49
  summaryType = y_axis_summary_type;
55
50
  }
@@ -57,64 +52,68 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
57
52
  summaryMethod = y_axis_summary_method;
58
53
  }
59
54
  if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
60
- var table = getTableById(table_id);
61
- var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
55
+ const table = getTableById(table_id);
56
+ const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
62
57
  summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
63
58
  }
64
- var currentTheme = getCurrentTheme(colorThemeName);
65
- var chartBarColor = currentTheme && currentTheme.colors[0] || '#2a67d1';
66
- var isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
59
+ const currentTheme = getCurrentTheme(colorThemeName);
60
+ const chartBarColor = currentTheme && currentTheme.colors[0] || '#2a67d1';
61
+ const isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
67
62
  if (isGroup) {
68
- _this.chart.scale('group_name', {
63
+ this.chart.scale('group_name', {
69
64
  type: 'cat'
70
65
  });
71
66
  }
72
- _this.chart.data(data, {
67
+ this.chart.data(data, {
73
68
  'name': {
74
69
  type: 'cat',
75
70
  nice: false
76
71
  }
77
72
  });
78
- var width = _this.chart.coordinateBBox.width;
79
- var chartData = isGroup ? getChartGroups(data) : data;
80
- var ticks = _this.getTicks(chartData, width);
81
- var labelCount = _this.getLabelCount(ticks, chartData);
73
+ const {
74
+ width
75
+ } = this.chart.coordinateBBox;
76
+ const chartData = isGroup ? getChartGroups(data) : data;
77
+ const ticks = this.getTicks(chartData, width);
78
+ const labelCount = this.getLabelCount(ticks, chartData);
82
79
  if (ticks.length > 0) {
83
- _this.chart.scale('name', {
80
+ this.chart.scale('name', {
84
81
  type: 'cat',
85
- ticks: ticks
82
+ ticks
86
83
  });
87
84
  }
88
- var themeColors = _this.getThemeColors();
85
+ const themeColors = this.getThemeColors();
89
86
 
90
87
  // set Coord type
91
- _this.chart.coordinate('rect');
92
- _this.handleAutoRange(data, summaryColumnData, summaryMethod);
88
+ this.chart.coordinate('rect');
89
+ this.handleAutoRange(data, summaryColumnData, summaryMethod);
93
90
  if (isGroup) {
94
- _this.drawLineGroup({
95
- data: data,
96
- currentTheme: currentTheme,
97
- themeColors: themeColors
91
+ this.drawLineGroup({
92
+ data,
93
+ currentTheme,
94
+ themeColors
98
95
  });
99
96
  } else {
100
- _this.drawLine({
101
- summaryType: summaryType,
102
- summaryMethod: summaryMethod,
103
- chartBarColor: chartBarColor,
104
- themeColors: themeColors
97
+ this.drawLine({
98
+ summaryType,
99
+ summaryMethod,
100
+ chartBarColor,
101
+ themeColors
105
102
  });
106
103
  }
107
- _this.setTooltip();
108
- _this.setAxis(themeColors, labelCount);
109
- _this.setTheme();
110
- _this.setLegend(themeColors);
111
- _this.chart.render();
112
- _this.renderAxisLabel();
104
+ this.setTooltip();
105
+ this.setAxis(themeColors, labelCount);
106
+ this.setTheme();
107
+ this.setLegend(themeColors);
108
+ this.chart.render();
109
+ this.renderAxisLabel();
113
110
  };
114
- _this.initChartHandler = function () {
115
- var isPreview = _this.props.isPreview;
116
- var config = {
117
- container: _this.container
111
+ this.initChartHandler = () => {
112
+ const {
113
+ isPreview
114
+ } = this.props;
115
+ let config = {
116
+ container: this.container
118
117
  };
119
118
  if (isPreview) {
120
119
  config.autoFit = true;
@@ -122,16 +121,17 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
122
121
  config.height = 400;
123
122
  config.width = 700;
124
123
  }
125
- _this.chart = new Chart(config);
124
+ this.chart = new Chart(config);
126
125
  };
127
- _this.handleAutoRange = function (data, summaryColumnData, summaryMethod) {
128
- var _this$props$statItem = _this.props.statItem,
129
- y_axis_auto_range = _this$props$statItem.y_axis_auto_range,
130
- y_axis_min = _this$props$statItem.y_axis_min,
131
- y_axis_max = _this$props$statItem.y_axis_max;
132
- var valueScaleOptions = {
133
- formatter: function formatter(value) {
134
- return _this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
126
+ this.handleAutoRange = (data, summaryColumnData, summaryMethod) => {
127
+ const {
128
+ y_axis_auto_range,
129
+ y_axis_min,
130
+ y_axis_max
131
+ } = this.props.statItem;
132
+ let valueScaleOptions = {
133
+ formatter: value => {
134
+ return this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
135
135
  }
136
136
  };
137
137
 
@@ -147,80 +147,87 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
147
147
  });
148
148
 
149
149
  // set the filter rule
150
- _this.chart.filter('value', function (value) {
150
+ this.chart.filter('value', value => {
151
151
  return value >= y_axis_min;
152
152
  });
153
153
 
154
154
  // filter the data
155
- _this.chart.filterData(data);
155
+ this.chart.filterData(data);
156
156
  }
157
- _this.chart.scale({
157
+ this.chart.scale({
158
158
  value: valueScaleOptions
159
159
  });
160
160
  };
161
- _this.drawLine = function (_ref) {
162
- var summaryType = _ref.summaryType,
163
- summaryMethod = _ref.summaryMethod,
164
- chartBarColor = _ref.chartBarColor,
165
- themeColors = _ref.themeColors;
166
- var display_data = _this.props.statItem.display_data;
167
- _this.chart.line().position('name*value').color(chartBarColor).tooltip('name*formatted_value', function (name, value) {
161
+ this.drawLine = _ref => {
162
+ let {
163
+ summaryType,
164
+ summaryMethod,
165
+ chartBarColor,
166
+ themeColors
167
+ } = _ref;
168
+ const {
169
+ display_data
170
+ } = this.props.statItem;
171
+ this.chart.line().position('name*value').color(chartBarColor).tooltip('name*formatted_value', (name, value) => {
168
172
  return {
169
- value: value,
173
+ value,
170
174
  name: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
171
175
  };
172
176
  });
173
- _this.chart.point().label(display_data ? 'value' : false, {
177
+ this.chart.point().label(display_data ? 'value' : false, {
174
178
  style: {
175
- fontSize: _this.getLabelFontSize(),
179
+ fontSize: this.getLabelFontSize(),
176
180
  fill: themeColors.textColor
177
181
  }
178
182
  }).position('name*value').color(chartBarColor).shape('circle').size(3).style({
179
183
  lineWidth: 1,
180
184
  stroke: '#fff'
181
- }).tooltip('name*formatted_value', function (name, value) {
185
+ }).tooltip('name*formatted_value', (name, value) => {
182
186
  return {
183
- value: value,
187
+ value,
184
188
  name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
185
189
  title: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
186
190
  };
187
191
  });
188
192
  };
189
- _this.drawLineGroup = function (_ref2) {
190
- var data = _ref2.data,
191
- currentTheme = _ref2.currentTheme,
192
- themeColors = _ref2.themeColors;
193
- var _this$props$statItem2 = _this.props.statItem,
194
- display_data = _this$props$statItem2.display_data,
195
- color_option = _this$props$statItem2.color_option;
196
- var groupColorCallback = currentTheme && currentTheme.colors;
193
+ this.drawLineGroup = _ref2 => {
194
+ let {
195
+ data,
196
+ currentTheme,
197
+ themeColors
198
+ } = _ref2;
199
+ const {
200
+ display_data,
201
+ color_option
202
+ } = this.props.statItem;
203
+ let groupColorCallback = currentTheme && currentTheme.colors;
197
204
  // when the 'Group by' column is a 'single-select' column,
198
205
  // and the user chooses to use the colors from the column.
199
206
  if (color_option === USEABLE_COLOR_TYPES[1]) {
200
- var groupColorMapping = {};
201
- data.forEach(function (item) {
207
+ const groupColorMapping = {};
208
+ data.forEach(item => {
202
209
  if (!groupColorMapping[item.group_name]) {
203
210
  groupColorMapping[item.group_name] = item.color;
204
211
  }
205
212
  });
206
- groupColorCallback = function groupColorCallback(group_name) {
213
+ groupColorCallback = group_name => {
207
214
  return groupColorMapping[group_name];
208
215
  };
209
216
  }
210
- _this.chart.scale({
217
+ this.chart.scale({
211
218
  group_name: {
212
219
  type: 'cat'
213
220
  }
214
221
  });
215
- _this.chart.line().position('name*value').color('group_name', groupColorCallback);
216
- _this.chart.point().label(display_data ? 'formatted_value' : false, {
222
+ this.chart.line().position('name*value').color('group_name', groupColorCallback);
223
+ this.chart.point().label(display_data ? 'formatted_value' : false, {
217
224
  style: {
218
- fontSize: _this.getLabelFontSize(),
225
+ fontSize: this.getLabelFontSize(),
219
226
  fill: themeColors.textColor
220
227
  }
221
- }).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name', function (name, value, group_name) {
228
+ }).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name', (name, value, group_name) => {
222
229
  return {
223
- value: value,
230
+ value,
224
231
  title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
225
232
  name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
226
233
  };
@@ -229,20 +236,20 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
229
236
  stroke: '#fff'
230
237
  });
231
238
  };
232
- _this.setTooltip = function () {
233
- _this.chart.tooltip({
239
+ this.setTooltip = () => {
240
+ this.chart.tooltip({
234
241
  showCrosshairs: true,
235
242
  showTitle: true,
236
243
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
237
244
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
238
245
  domStyles: {
239
- 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
240
- 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
246
+ 'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
247
+ 'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
241
248
  }
242
249
  });
243
250
  };
244
- _this.setAxis = function (themeColors, labelCount) {
245
- _this.chart.axis('name', {
251
+ this.setAxis = (themeColors, labelCount) => {
252
+ this.chart.axis('name', {
246
253
  line: {
247
254
  style: themeColors.gridColor
248
255
  },
@@ -253,10 +260,10 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
253
260
  offset: 20,
254
261
  autoRotate: true,
255
262
  rotate: labelCount > 11 ? 0.3 : 0,
256
- formatter: _this.labelFormatter
263
+ formatter: this.labelFormatter
257
264
  }
258
265
  });
259
- _this.chart.axis('value', {
266
+ this.chart.axis('value', {
260
267
  label: {
261
268
  style: {
262
269
  fill: themeColors.textColor
@@ -271,8 +278,8 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
271
278
  }
272
279
  });
273
280
  };
274
- _this.setTheme = function () {
275
- _this.chart.theme({
281
+ this.setTheme = () => {
282
+ this.chart.theme({
276
283
  geometries: {
277
284
  point: {
278
285
  circle: {
@@ -287,14 +294,14 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
287
294
  }
288
295
  });
289
296
  };
290
- _this.setLegend = function (themeColors) {
291
- _this.chart.legend('group_name', {
297
+ this.setLegend = themeColors => {
298
+ this.chart.legend('group_name', {
292
299
  position: 'bottom',
293
300
  itemName: {
294
301
  style: {
295
302
  fill: themeColors.textColor
296
303
  },
297
- formatter: function formatter(name) {
304
+ formatter: name => {
298
305
  return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
299
306
  }
300
307
  },
@@ -314,35 +321,37 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
314
321
  }
315
322
  });
316
323
  };
317
- _this.renderAxisLabel = function (newStatItem) {
318
- var _this$props2 = _this.props,
319
- getTableById = _this$props2.getTableById,
320
- statItem = _this$props2.statItem;
324
+ this.renderAxisLabel = newStatItem => {
325
+ let {
326
+ getTableById,
327
+ statItem
328
+ } = this.props;
321
329
  if (newStatItem && newStatItem._id !== statItem._id) {
322
330
  return;
323
331
  }
324
- if (!_this.chart) return;
332
+ if (!this.chart) return;
325
333
  statItem = newStatItem || statItem;
326
- var _statItem = statItem,
327
- table_id = _statItem.table_id,
328
- x_axis_column_key = _statItem.x_axis_column_key,
329
- y_axis_column_key = _statItem.y_axis_column_key,
330
- show_y_axis_label = _statItem.show_y_axis_label,
331
- show_x_axis_label = _statItem.show_x_axis_label,
332
- y_axis_label_position = _statItem.y_axis_label_position,
333
- x_axis_label_position = _statItem.x_axis_label_position,
334
- y_axis_summary_type = _statItem.y_axis_summary_type;
335
- var table = getTableById(table_id);
336
- var autoPadding = _this.chart.autoPadding;
337
- var textColor = _this.getAxisLabelColor();
338
- var xAxisID = "chart-x-axis-label_".concat(statItem._id);
339
- var chartContainer = _this.chart.getCanvas().get('container');
340
- var xLabel = chartContainer.querySelector("#".concat(xAxisID));
334
+ const {
335
+ table_id,
336
+ x_axis_column_key,
337
+ y_axis_column_key,
338
+ show_y_axis_label,
339
+ show_x_axis_label,
340
+ y_axis_label_position,
341
+ x_axis_label_position,
342
+ y_axis_summary_type
343
+ } = statItem;
344
+ const table = getTableById(table_id);
345
+ const autoPadding = this.chart.autoPadding;
346
+ const textColor = this.getAxisLabelColor();
347
+ const xAxisID = "chart-x-axis-label_".concat(statItem._id);
348
+ const chartContainer = this.chart.getCanvas().get('container');
349
+ const xLabel = chartContainer.querySelector("#".concat(xAxisID));
341
350
  if (!xLabel && show_x_axis_label) {
342
- var div = document.createElement('div');
351
+ const div = document.createElement('div');
343
352
  div.id = xAxisID;
344
353
  div.className = 'statistic-chart-axis-label';
345
- var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
354
+ const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
346
355
  div.innerHTML = "".concat(column ? column.name : '');
347
356
  div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
348
357
  chartContainer.appendChild(div);
@@ -353,157 +362,150 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
353
362
  if (xLabel && !show_x_axis_label) {
354
363
  xLabel.parentNode.removeChild(xLabel);
355
364
  }
356
- var yAxisID = "chart-y-axis-label_".concat(statItem._id);
357
- var yLabel = chartContainer.querySelector("#".concat(yAxisID));
358
- var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
365
+ const yAxisID = "chart-y-axis-label_".concat(statItem._id);
366
+ const yLabel = chartContainer.querySelector("#".concat(yAxisID));
367
+ let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
359
368
  if (!yLabel && show_y_axis_label) {
360
- var _div = document.createElement('div');
361
- _div.id = yAxisID;
362
- _div.className = 'statistic-chart-axis-label';
369
+ const div = document.createElement('div');
370
+ div.id = yAxisID;
371
+ div.className = 'statistic-chart-axis-label';
363
372
  if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
364
- _div.innerHTML = intl.get(TITLE_AMOUNT);
373
+ div.innerHTML = intl.get(TITLE_AMOUNT);
365
374
  } else {
366
- var _column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
367
- _div.innerHTML = _column.name || '';
375
+ const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
376
+ div.innerHTML = column.name || '';
368
377
  }
369
- var containerHeight = chartContainer.offsetHeight;
370
- var textAlign = 'center';
378
+ const containerHeight = chartContainer.offsetHeight;
379
+ let textAlign = 'center';
371
380
  if (y_axis_label_position === 'bottom') textAlign = 'left';
372
381
  if (y_axis_label_position === 'top') textAlign = 'right';
373
- _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)"));
374
- chartContainer.appendChild(_div);
382
+ 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)"));
383
+ chartContainer.appendChild(div);
375
384
  }
376
385
  if (yLabel && show_y_axis_label) {
377
- var _containerHeight = chartContainer.offsetHeight;
378
- var _textAlign = 'center';
379
- if (y_axis_label_position === 'bottom') _textAlign = 'left';
380
- if (y_axis_label_position === 'top') _textAlign = 'right';
381
- 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)"));
386
+ const containerHeight = chartContainer.offsetHeight;
387
+ let textAlign = 'center';
388
+ if (y_axis_label_position === 'bottom') textAlign = 'left';
389
+ if (y_axis_label_position === 'top') textAlign = 'right';
390
+ 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)"));
382
391
  }
383
392
  if (yLabel && !show_y_axis_label) {
384
393
  yLabel.parentNode.removeChild(yLabel);
385
394
  }
386
395
  };
387
- _this.destroyChart = function () {
388
- _this.chart.destroy();
389
- _this.chart = null;
396
+ this.destroyChart = () => {
397
+ this.chart.destroy();
398
+ this.chart = null;
390
399
  };
391
- _this.state = {
400
+ this.state = {
392
401
  isCalculatingData: true,
393
402
  showResultDescription: true
394
403
  };
395
- _this.calculateData = null;
396
- return _this;
404
+ this.calculateData = null;
405
+ }
406
+ componentDidMount() {
407
+ const {
408
+ statItem,
409
+ chartCalculator,
410
+ eventBus
411
+ } = this.props;
412
+ this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
413
+ this.renderAxisLabel(newStatItem);
414
+ });
415
+ if (this.container) {
416
+ chartCalculator.calculate(statItem).then(data => {
417
+ const showResultDescription = data.length > 0 ? false : true;
418
+ this.setState({
419
+ isCalculatingData: false,
420
+ showResultDescription
421
+ }, () => {
422
+ if (!showResultDescription) {
423
+ this.drawChart(data);
424
+ this.calculateData = data;
425
+ }
426
+ });
427
+ });
428
+ }
429
+ }
430
+ shouldComponentUpdate(nextProps, nextState) {
431
+ const {
432
+ colorThemeName
433
+ } = this.props;
434
+ if (this.canUpdate(this.props, nextProps)) {
435
+ return true;
436
+ }
437
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
438
+ return true;
439
+ }
440
+ if (nextProps.colorThemeName !== colorThemeName) {
441
+ return true;
442
+ }
443
+ return false;
397
444
  }
398
- _createClass(LineChart, [{
399
- key: "componentDidMount",
400
- value: function componentDidMount() {
401
- var _this2 = this;
402
- var _this$props3 = this.props,
403
- statItem = _this$props3.statItem,
404
- chartCalculator = _this$props3.chartCalculator,
405
- eventBus = _this$props3.eventBus;
406
- this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
407
- _this2.renderAxisLabel(newStatItem);
445
+ componentDidUpdate(preProps, preState) {
446
+ const {
447
+ statItem,
448
+ chartCalculator
449
+ } = this.props;
450
+ const {
451
+ isCalculatingData
452
+ } = this.state;
453
+ if (isCalculatingData !== preState.isCalculatingData) return;
454
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
455
+ this.setState({
456
+ isCalculatingData: true
408
457
  });
409
458
  if (this.container) {
410
- chartCalculator.calculate(statItem).then(function (data) {
411
- var showResultDescription = data.length > 0 ? false : true;
412
- _this2.setState({
459
+ chartCalculator.calculate(statItem).then(data => {
460
+ const showResultDescription = data.length > 0 ? false : true;
461
+ this.chart && this.destroyChart();
462
+ this.calculateData = data;
463
+ this.setState({
413
464
  isCalculatingData: false,
414
- showResultDescription: showResultDescription
415
- }, function () {
465
+ showResultDescription
466
+ }, () => {
416
467
  if (!showResultDescription) {
417
- _this2.drawChart(data);
418
- _this2.calculateData = data;
468
+ this.drawChart(data);
469
+ if (this.props.isPreview) this.chart.forceFit();
419
470
  }
420
471
  });
421
472
  });
422
473
  }
423
- }
424
- }, {
425
- key: "shouldComponentUpdate",
426
- value: function shouldComponentUpdate(nextProps, nextState) {
427
- var colorThemeName = this.props.colorThemeName;
428
- if (this.canUpdate(this.props, nextProps)) {
429
- return true;
430
- }
431
- if (nextState.isCalculatingData !== this.state.isCalculatingData) {
432
- return true;
433
- }
434
- if (nextProps.colorThemeName !== colorThemeName) {
435
- return true;
436
- }
437
- return false;
438
- }
439
- }, {
440
- key: "componentDidUpdate",
441
- value: function componentDidUpdate(preProps, preState) {
442
- var _this3 = this;
443
- var _this$props4 = this.props,
444
- statItem = _this$props4.statItem,
445
- chartCalculator = _this$props4.chartCalculator;
446
- var isCalculatingData = this.state.isCalculatingData;
447
- if (isCalculatingData !== preState.isCalculatingData) return;
448
- if (this.shouldCalculateStatItem(preProps, this.props)) {
449
- this.setState({
450
- isCalculatingData: true
451
- });
452
- if (this.container) {
453
- chartCalculator.calculate(statItem).then(function (data) {
454
- var showResultDescription = data.length > 0 ? false : true;
455
- _this3.chart && _this3.destroyChart();
456
- _this3.calculateData = data;
457
- _this3.setState({
458
- isCalculatingData: false,
459
- showResultDescription: showResultDescription
460
- }, function () {
461
- if (!showResultDescription) {
462
- _this3.drawChart(data);
463
- if (_this3.props.isPreview) _this3.chart.forceFit();
464
- }
465
- });
466
- });
467
- }
468
- } else {
469
- if (!this.state.showResultDescription) {
470
- this.chart && this.destroyChart();
471
- this.drawChart(this.calculateData);
472
- if (this.props.isPreview) {
473
- this.chart.forceFit();
474
- }
474
+ } else {
475
+ if (!this.state.showResultDescription) {
476
+ this.chart && this.destroyChart();
477
+ this.drawChart(this.calculateData);
478
+ if (this.props.isPreview) {
479
+ this.chart.forceFit();
475
480
  }
476
481
  }
477
482
  }
478
- }, {
479
- key: "componentWillUnmount",
480
- value: function componentWillUnmount() {
481
- this.container = null;
482
- this.unsubscribeStyleChange();
483
- }
484
- }, {
485
- key: "render",
486
- value: function render() {
487
- var _this4 = this;
488
- var statItem = this.props.statItem;
489
- var _this$state = this.state,
490
- isCalculatingData = _this$state.isCalculatingData,
491
- showResultDescription = _this$state.showResultDescription;
492
- var show_y_axis_label = statItem.show_y_axis_label,
493
- show_x_axis_label = statItem.show_x_axis_label;
494
- var style = {
495
- padding: show_y_axis_label || show_x_axis_label ? 30 : 20
496
- };
497
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
498
- ref: function ref(_ref3) {
499
- return _this4.container = _ref3;
500
- },
501
- style: style,
502
- className: "statistic-chart-container"
503
- }));
504
- }
505
- }]);
506
- return LineChart;
507
- }(BaseChart);
483
+ }
484
+ componentWillUnmount() {
485
+ this.container = null;
486
+ this.unsubscribeStyleChange();
487
+ }
488
+ render() {
489
+ const {
490
+ statItem
491
+ } = this.props;
492
+ const {
493
+ isCalculatingData,
494
+ showResultDescription
495
+ } = this.state;
496
+ const {
497
+ show_y_axis_label,
498
+ show_x_axis_label
499
+ } = statItem;
500
+ const style = {
501
+ padding: show_y_axis_label || show_x_axis_label ? 30 : 20
502
+ };
503
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
504
+ ref: ref => this.container = ref,
505
+ style: style,
506
+ className: "statistic-chart-container"
507
+ }));
508
+ }
509
+ }
508
510
  LineChart.propTypes = propTypes;
509
511
  export default LineChart;