dtable-statistic 4.0.2-test-2

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 (210) hide show
  1. package/README.md +3 -0
  2. package/es/api/dtable-db-api.js +43 -0
  3. package/es/assets/css/color-picker.css +53 -0
  4. package/es/assets/css/color-rules-popover.css +144 -0
  5. package/es/assets/css/color-theme-dialog.css +40 -0
  6. package/es/assets/css/dashboard.css +562 -0
  7. package/es/assets/css/dialog.css +415 -0
  8. package/es/assets/css/mobile-dashboard.module.css +91 -0
  9. package/es/assets/css/slider.css +77 -0
  10. package/es/assets/css/statistic-chart.module.css +11 -0
  11. package/es/assets/css/statistic-custom-title.module.css +3 -0
  12. package/es/assets/css/statistic-custom.module.css +4 -0
  13. package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
  14. package/es/assets/css/statistic-time-picker.module.css +21 -0
  15. package/es/assets/css/theme.css +61 -0
  16. package/es/assets/images/icon.png +0 -0
  17. package/es/calculator/base-calculator.js +111 -0
  18. package/es/calculator/basic-chart-calculator.js +571 -0
  19. package/es/calculator/combination-calculator.js +296 -0
  20. package/es/calculator/compare-bar-calculator.js +291 -0
  21. package/es/calculator/completeness-calculator.js +307 -0
  22. package/es/calculator/copy-value.js +47 -0
  23. package/es/calculator/dashboard-calculator.js +146 -0
  24. package/es/calculator/heat-map-calculator.js +225 -0
  25. package/es/calculator/horizontal-bar-calculator.js +100 -0
  26. package/es/calculator/index.js +88 -0
  27. package/es/calculator/map-calculator.js +169 -0
  28. package/es/calculator/mirror-calculator.js +217 -0
  29. package/es/calculator/number-card-calculator.js +135 -0
  30. package/es/calculator/pivot-table-calculator.js +810 -0
  31. package/es/calculator/scatter-calculator.js +150 -0
  32. package/es/calculator/thread-manager.js +70 -0
  33. package/es/calculator/trend-calculator.js +204 -0
  34. package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
  35. package/es/calculator/workers/calculator.worker.js +22 -0
  36. package/es/calculator/workers/card-calculator-worker.js +28 -0
  37. package/es/calculator/workers/combination-calculator-worker.js +257 -0
  38. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
  39. package/es/calculator/workers/completeness-calculator-worker.js +153 -0
  40. package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
  41. package/es/calculator/workers/mirror-calculator-worker.js +132 -0
  42. package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
  43. package/es/calculator/workers/scatter-calculator-worker.js +67 -0
  44. package/es/calculator/workers/trend-calculator-worker.js +93 -0
  45. package/es/calculator/world-map-calculator.js +193 -0
  46. package/es/components/common-add-tool.js +19 -0
  47. package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
  48. package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
  49. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
  50. package/es/components/dialog/color-theme-dialog.js +71 -0
  51. package/es/components/dialog/enlarged-chart-dialog.js +73 -0
  52. package/es/components/dialog/new-table-dialog.js +113 -0
  53. package/es/components/dialog/new-view-dialog.js +87 -0
  54. package/es/components/dialog/rename-view-dialog.js +87 -0
  55. package/es/components/dialog/statistic-record-dialog/index.css +114 -0
  56. package/es/components/dialog/statistic-record-dialog/index.js +174 -0
  57. package/es/components/dialog/table-select-dialog.js +93 -0
  58. package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
  59. package/es/components/dtable-popover.js +109 -0
  60. package/es/components/dtable-search-input.js +137 -0
  61. package/es/components/dtable-select.js +104 -0
  62. package/es/components/index.js +11 -0
  63. package/es/components/loading.js +8 -0
  64. package/es/components/modal-portal.js +36 -0
  65. package/es/components/popover/color-rules/color-rule.js +179 -0
  66. package/es/components/popover/color-rules/index.js +87 -0
  67. package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
  68. package/es/components/popover/color-rules/rule-filters/index.css +214 -0
  69. package/es/components/popover/color-rules/rule-filters/index.js +97 -0
  70. package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
  71. package/es/components/popover/color-rules-popover.js +213 -0
  72. package/es/components/popover/color-selector-popover.js +85 -0
  73. package/es/components/seatable-radio/index.css +51 -0
  74. package/es/components/seatable-radio/index.js +28 -0
  75. package/es/components/select/index.js +2 -0
  76. package/es/components/select/option-group.css +104 -0
  77. package/es/components/select/option-group.js +225 -0
  78. package/es/components/select/option.js +51 -0
  79. package/es/components/select/select.css +211 -0
  80. package/es/components/select/select.js +157 -0
  81. package/es/components/toast/alert.js +130 -0
  82. package/es/components/toast/index.js +3 -0
  83. package/es/components/toast/toast.js +164 -0
  84. package/es/components/toast/toastManager.js +150 -0
  85. package/es/components/toast/toaster.js +64 -0
  86. package/es/constants/color-rules.js +8 -0
  87. package/es/constants/dtable-select-style.js +61 -0
  88. package/es/constants/event-types.js +1 -0
  89. package/es/constants/index.js +501 -0
  90. package/es/constants/key-codes.js +102 -0
  91. package/es/constants/zIndexes.js +1 -0
  92. package/es/custom-g2.js +614 -0
  93. package/es/dashboard.js +408 -0
  94. package/es/desktop-dashboard.js +299 -0
  95. package/es/index.js +33 -0
  96. package/es/locale/index.js +17 -0
  97. package/es/locale/lang/de.js +237 -0
  98. package/es/locale/lang/en.js +237 -0
  99. package/es/locale/lang/fr.js +237 -0
  100. package/es/locale/lang/zh_CN.js +237 -0
  101. package/es/mobile-dashboard.js +103 -0
  102. package/es/model/collaborators.js +11 -0
  103. package/es/model/stat-item.js +340 -0
  104. package/es/model/statistic-dashboard.js +8 -0
  105. package/es/service/chart-service.js +192 -0
  106. package/es/service/dashboard-service.js +415 -0
  107. package/es/stat-editor/chart-name-editor.js +75 -0
  108. package/es/stat-editor/index.js +74 -0
  109. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
  110. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
  111. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
  112. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
  113. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
  114. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
  115. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
  116. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
  117. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
  118. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
  119. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
  120. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
  121. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
  122. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
  123. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
  124. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
  125. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
  126. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
  127. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
  128. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
  129. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
  130. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
  131. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
  132. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
  133. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
  134. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
  135. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
  136. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
  137. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
  138. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
  139. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
  140. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
  141. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
  143. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
  144. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
  145. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
  146. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
  147. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
  148. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
  149. package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
  150. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
  151. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
  152. package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
  153. package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
  154. package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
  155. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
  156. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
  157. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
  158. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
  159. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
  160. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
  161. package/es/stat-list/chart-preview.js +139 -0
  162. package/es/stat-list/index.js +275 -0
  163. package/es/stat-view/area-chart.js +521 -0
  164. package/es/stat-view/bar-chart.js +568 -0
  165. package/es/stat-view/base-chart.js +44 -0
  166. package/es/stat-view/basic-number-card.js +255 -0
  167. package/es/stat-view/combination-chart.js +558 -0
  168. package/es/stat-view/compare-chart.js +485 -0
  169. package/es/stat-view/completeness-chart.js +389 -0
  170. package/es/stat-view/custom-bar.js +433 -0
  171. package/es/stat-view/dashboard-chart.js +317 -0
  172. package/es/stat-view/heat-map.js +501 -0
  173. package/es/stat-view/horizontal-bar-chart.js +569 -0
  174. package/es/stat-view/index.js +183 -0
  175. package/es/stat-view/line-chart.js +505 -0
  176. package/es/stat-view/map.js +428 -0
  177. package/es/stat-view/mirror.js +285 -0
  178. package/es/stat-view/pie-chart.js +326 -0
  179. package/es/stat-view/pivot-table/index.js +206 -0
  180. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
  181. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
  182. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
  183. package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
  184. package/es/stat-view/ring-chart.js +416 -0
  185. package/es/stat-view/scatter-chart.js +367 -0
  186. package/es/stat-view/treemap-chart.js +318 -0
  187. package/es/stat-view/trend-chart.js +299 -0
  188. package/es/stat-view/world-map.js +443 -0
  189. package/es/tabs/index.js +252 -0
  190. package/es/tabs/statistic-tabs.module.css +154 -0
  191. package/es/tabs/tab.js +167 -0
  192. package/es/utils/basic-chart-utils.js +24 -0
  193. package/es/utils/cell-format.js +110 -0
  194. package/es/utils/cell-value.js +27 -0
  195. package/es/utils/collaborator.js +31 -0
  196. package/es/utils/color-utils.js +112 -0
  197. package/es/utils/column-utils.js +18 -0
  198. package/es/utils/column.js +13 -0
  199. package/es/utils/common-utils.js +303 -0
  200. package/es/utils/date-format.js +65 -0
  201. package/es/utils/export-table-utils.js +632 -0
  202. package/es/utils/index.js +26 -0
  203. package/es/utils/object.js +26 -0
  204. package/es/utils/row-utils.js +115 -0
  205. package/es/utils/search.js +67 -0
  206. package/es/utils/sql-utils.js +293 -0
  207. package/es/utils/stat-utils.js +353 -0
  208. package/es/utils/trend-utils.js +136 -0
  209. package/index.js +1 -0
  210. package/package.json +188 -0
@@ -0,0 +1,558 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import intl from 'react-intl-universal';
10
+ import { TableUtils, getNumberDisplayString } from 'dtable-store';
11
+ import BaseChart from './base-chart';
12
+ import { Chart } from '../custom-g2';
13
+ import { Loading } from '../components';
14
+ import { getCurrentTheme, getLabelFontSize } from '../utils/common-utils';
15
+ import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_COLORS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, LABEL_CONFIG_CHANGED, SUMMARY_TYPE, NO_STATISTIC_RESULTS, TITLE_AMOUNT, LEGEND_LEFT, LEGEND_RIGHT } from '../constants';
16
+ var propTypes = {
17
+ isPreview: PropTypes.bool,
18
+ isEnlarge: PropTypes.bool,
19
+ isEdit: PropTypes.bool,
20
+ theme: PropTypes.string,
21
+ colorThemeName: PropTypes.string,
22
+ statItem: PropTypes.object,
23
+ chartCalculator: PropTypes.object,
24
+ eventBus: PropTypes.object,
25
+ getTableById: PropTypes.func,
26
+ toggleStatisticRecordsDialog: PropTypes.func
27
+ };
28
+ var CombinationChart = /*#__PURE__*/function (_BaseChart) {
29
+ _inherits(CombinationChart, _BaseChart);
30
+ var _super = _createSuper(CombinationChart);
31
+ function CombinationChart(props) {
32
+ var _this;
33
+ _classCallCheck(this, CombinationChart);
34
+ _this = _super.call(this, props);
35
+ _this.componentDidMount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
36
+ var _this$props, statItem, chartCalculator, eventBus, data, showResultDescription;
37
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
38
+ while (1) {
39
+ switch (_context.prev = _context.next) {
40
+ case 0:
41
+ _this$props = _this.props, statItem = _this$props.statItem, chartCalculator = _this$props.chartCalculator, eventBus = _this$props.eventBus;
42
+ _this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
43
+ _this.renderAxisLabel(newStatItem);
44
+ });
45
+ if (_this.container) {
46
+ _context.next = 4;
47
+ break;
48
+ }
49
+ return _context.abrupt("return");
50
+ case 4:
51
+ _context.next = 6;
52
+ return chartCalculator.calculate(statItem);
53
+ case 6:
54
+ data = _context.sent;
55
+ showResultDescription = data.length > 0 ? false : true;
56
+ _this.setState({
57
+ isCalculatingData: false,
58
+ showResultDescription: showResultDescription
59
+ }, function () {
60
+ if (!showResultDescription) {
61
+ _this.drawChart(data);
62
+ _this.calculateData = data;
63
+ }
64
+ });
65
+ case 9:
66
+ case "end":
67
+ return _context.stop();
68
+ }
69
+ }
70
+ }, _callee);
71
+ }));
72
+ _this.componentDidUpdate = /*#__PURE__*/function () {
73
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(preProps, preState) {
74
+ var _this$props2, statItem, chartCalculator, isCalculatingData, data, showResultDescription;
75
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
76
+ while (1) {
77
+ switch (_context2.prev = _context2.next) {
78
+ case 0:
79
+ _this$props2 = _this.props, statItem = _this$props2.statItem, chartCalculator = _this$props2.chartCalculator;
80
+ isCalculatingData = _this.state.isCalculatingData;
81
+ if (!(isCalculatingData !== preState.isCalculatingData)) {
82
+ _context2.next = 4;
83
+ break;
84
+ }
85
+ return _context2.abrupt("return");
86
+ case 4:
87
+ if (!_this.shouldCalculateStatItem(preProps, _this.props)) {
88
+ _context2.next = 16;
89
+ break;
90
+ }
91
+ _this.setState({
92
+ isCalculatingData: true
93
+ });
94
+ if (!_this.container) {
95
+ _context2.next = 14;
96
+ break;
97
+ }
98
+ _context2.next = 9;
99
+ return chartCalculator.calculate(statItem);
100
+ case 9:
101
+ data = _context2.sent;
102
+ showResultDescription = data.length > 0 ? false : true;
103
+ _this.chart && _this.destroyChart();
104
+ _this.calculateData = data;
105
+ _this.setState({
106
+ isCalculatingData: false,
107
+ showResultDescription: showResultDescription
108
+ }, function () {
109
+ if (!showResultDescription) {
110
+ _this.drawChart(data);
111
+ if (_this.props.isPreview) _this.chart.forceFit();
112
+ }
113
+ });
114
+ case 14:
115
+ _context2.next = 17;
116
+ break;
117
+ case 16:
118
+ if (!_this.state.showResultDescription) {
119
+ _this.chart && _this.destroyChart();
120
+ _this.drawChart(_this.calculateData);
121
+ if (_this.props.isPreview) {
122
+ _this.chart.forceFit();
123
+ }
124
+ }
125
+ case 17:
126
+ case "end":
127
+ return _context2.stop();
128
+ }
129
+ }
130
+ }, _callee2);
131
+ }));
132
+ return function (_x, _x2) {
133
+ return _ref2.apply(this, arguments);
134
+ };
135
+ }();
136
+ _this.renderAxisLabel = function (newStatItem) {
137
+ var _this$props3 = _this.props,
138
+ getTableById = _this$props3.getTableById,
139
+ statItem = _this$props3.statItem,
140
+ theme = _this$props3.theme,
141
+ isEnlarge = _this$props3.isEnlarge,
142
+ isPreview = _this$props3.isPreview;
143
+ if (newStatItem && newStatItem._id !== statItem._id) {
144
+ return;
145
+ }
146
+ if (!_this.chart) return;
147
+ statItem = newStatItem || statItem;
148
+ var _statItem = statItem,
149
+ table_id = _statItem.table_id,
150
+ x_axis_column_key = _statItem.x_axis_column_key,
151
+ show_y_axis_left_label = _statItem.show_y_axis_left_label,
152
+ show_y_axis_right_label = _statItem.show_y_axis_right_label,
153
+ show_x_axis_label = _statItem.show_x_axis_label,
154
+ y_axis_left_label_position = _statItem.y_axis_left_label_position,
155
+ y_axis_right_label_position = _statItem.y_axis_right_label_position,
156
+ y_axis_left_summary_column = _statItem.y_axis_left_summary_column,
157
+ y_axis_right_summary_column = _statItem.y_axis_right_summary_column,
158
+ x_axis_label_position = _statItem.x_axis_label_position,
159
+ y_axis_left_summary_method = _statItem.y_axis_left_summary_method,
160
+ y_axis_right_summary_method = _statItem.y_axis_right_summary_method;
161
+ var table = getTableById(table_id);
162
+ var autoPadding = _this.chart.autoPadding;
163
+ var themeColors = STAT_ITEM_THEME_COLORS.light;
164
+ if (theme === 'dark' && !isEnlarge && isPreview) {
165
+ themeColors = STAT_ITEM_THEME_COLORS.dark;
166
+ }
167
+ var xAxisID = "chart-x-axis-label_".concat(statItem._id);
168
+ var chartContainer = _this.chart.getCanvas().get('container');
169
+ var xLabel = chartContainer.querySelector("#".concat(xAxisID));
170
+ if (!xLabel && show_x_axis_label) {
171
+ var div = document.createElement('div');
172
+ div.id = xAxisID;
173
+ div.className = 'statistic-chart-axis-label';
174
+ var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
175
+ div.innerHTML = "".concat(column ? column.name : '');
176
+ div.setAttribute('style', "color:".concat(themeColors.textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
177
+ chartContainer.appendChild(div);
178
+ }
179
+ if (xLabel && show_x_axis_label) {
180
+ xLabel.setAttribute('style', "color:".concat(themeColors.textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
181
+ }
182
+ if (xLabel && !show_x_axis_label) {
183
+ xLabel.parentNode.removeChild(xLabel);
184
+ }
185
+ var yAxisLeftID = "chart-y-axis-left-label_".concat(statItem._id);
186
+ var yAxisLeftLabel = chartContainer.querySelector("#".concat(yAxisLeftID));
187
+ if (!yAxisLeftLabel && show_y_axis_left_label) {
188
+ var _div = document.createElement('div');
189
+ _div.id = yAxisLeftID;
190
+ _div.className = 'statistic-chart-axis-label';
191
+ var yAxisColumn = TableUtils.getTableColumnByKey(table, y_axis_left_summary_column);
192
+ var labeContent = yAxisColumn ? intl.get(STATISTICS_COUNT_SHOW[y_axis_left_summary_method]) : intl.get(STATISTICS_COUNT_SHOW.count);
193
+ _div.innerHTML = labeContent;
194
+ var containerHeight = chartContainer.offsetHeight;
195
+ var textAlign = 'center';
196
+ if (y_axis_left_label_position === 'bottom') textAlign = 'left';
197
+ if (y_axis_left_label_position === 'top') textAlign = 'right';
198
+ _div.setAttribute('style', "color:".concat(themeColors.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)"));
199
+ chartContainer.appendChild(_div);
200
+ }
201
+ if (yAxisLeftLabel && show_y_axis_left_label) {
202
+ var _containerHeight = chartContainer.offsetHeight;
203
+ var _textAlign = 'center';
204
+ if (y_axis_left_label_position === 'bottom') _textAlign = 'left';
205
+ if (y_axis_left_label_position === 'top') _textAlign = 'right';
206
+ yAxisLeftLabel.setAttribute('style', "color:".concat(themeColors.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)"));
207
+ }
208
+ if (yAxisLeftLabel && !show_y_axis_left_label) {
209
+ yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
210
+ }
211
+ var yAxisRightID = "chart-y-axis-right-label_".concat(statItem._id);
212
+ var yAxisRightLabel = chartContainer.querySelector("#".concat(yAxisRightID));
213
+ if (!yAxisRightLabel && show_y_axis_right_label) {
214
+ var _div2 = document.createElement('div');
215
+ _div2.id = yAxisRightID;
216
+ _div2.className = 'statistic-chart-axis-label';
217
+ var _yAxisColumn = TableUtils.getTableColumnByKey(table, y_axis_right_summary_column);
218
+ var _labeContent = _yAxisColumn ? intl.get(STATISTICS_COUNT_SHOW[y_axis_right_summary_method]) : intl.get(STATISTICS_COUNT_SHOW.count);
219
+ _div2.innerHTML = _labeContent;
220
+ var _containerHeight2 = chartContainer.offsetHeight;
221
+ var _textAlign2 = 'center';
222
+ if (y_axis_right_label_position === 'bottom') _textAlign2 = 'right';
223
+ if (y_axis_right_label_position === 'top') _textAlign2 = 'left';
224
+ _div2.setAttribute('style', "color:".concat(themeColors.textColor, "; position: absolute; width: ").concat(_containerHeight2, "px; padding-right: ").concat(autoPadding.bottom, "px; text-align: ").concat(_textAlign2, "; top: 0; right: 0px; transform: translate(").concat(_containerHeight2 / 2 + 12, "px, ").concat((_containerHeight2 - autoPadding.bottom) / 2 - 6, "px) rotate(-270deg)"));
225
+ chartContainer.appendChild(_div2);
226
+ }
227
+ if (yAxisRightLabel && show_y_axis_right_label) {
228
+ var _containerHeight3 = chartContainer.offsetHeight;
229
+ var _textAlign3 = 'center';
230
+ if (y_axis_right_label_position === 'bottom') _textAlign3 = 'right';
231
+ if (y_axis_right_label_position === 'top') _textAlign3 = 'left';
232
+ yAxisRightLabel.setAttribute('style', "color:".concat(themeColors.textColor, "; position: absolute; width: ").concat(_containerHeight3, "px; padding-right: ").concat(autoPadding.bottom, "px; text-align: ").concat(_textAlign3, "; top: 0; right: 0px; transform: translate(").concat(_containerHeight3 / 2 + 12, "px, ").concat((_containerHeight3 - autoPadding.bottom) / 2 - 6, "px) rotate(-270deg)"));
233
+ }
234
+ if (yAxisRightLabel && !show_y_axis_right_label) {
235
+ yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
236
+ }
237
+ };
238
+ _this.drawChart = function (data) {
239
+ var _this$props4 = _this.props,
240
+ getTableById = _this$props4.getTableById,
241
+ isPreview = _this$props4.isPreview,
242
+ statItem = _this$props4.statItem,
243
+ isEnlarge = _this$props4.isEnlarge,
244
+ theme = _this$props4.theme,
245
+ colorThemeName = _this$props4.colorThemeName;
246
+ var currentTheme = getCurrentTheme(colorThemeName);
247
+ var table_id = statItem.table_id,
248
+ y_axis_left_summary_column = statItem.y_axis_left_summary_column,
249
+ y_axis_right_summary_column = statItem.y_axis_right_summary_column,
250
+ y_axis_left_summary_method = statItem.y_axis_left_summary_method,
251
+ y_axis_right_summary_method = statItem.y_axis_right_summary_method,
252
+ y_axis_left_summary_type = statItem.y_axis_left_summary_type,
253
+ y_axis_right_summary_type = statItem.y_axis_right_summary_type,
254
+ y_axis_left_group_by_multiple_numeric_column = statItem.y_axis_left_group_by_multiple_numeric_column,
255
+ _statItem$y_axis_auto = statItem.y_axis_auto_range_left,
256
+ y_axis_auto_range_left = _statItem$y_axis_auto === void 0 ? true : _statItem$y_axis_auto,
257
+ _statItem$y_axis_min_ = statItem.y_axis_min_left,
258
+ y_axis_min_left = _statItem$y_axis_min_ === void 0 ? 0 : _statItem$y_axis_min_,
259
+ _statItem$y_axis_max_ = statItem.y_axis_max_left,
260
+ y_axis_max_left = _statItem$y_axis_max_ === void 0 ? 0 : _statItem$y_axis_max_,
261
+ _statItem$y_axis_auto2 = statItem.y_axis_auto_range_right,
262
+ y_axis_auto_range_right = _statItem$y_axis_auto2 === void 0 ? true : _statItem$y_axis_auto2,
263
+ _statItem$y_axis_min_2 = statItem.y_axis_min_right,
264
+ y_axis_min_right = _statItem$y_axis_min_2 === void 0 ? 0 : _statItem$y_axis_min_2,
265
+ _statItem$y_axis_max_2 = statItem.y_axis_max_right,
266
+ y_axis_max_right = _statItem$y_axis_max_2 === void 0 ? 0 : _statItem$y_axis_max_2,
267
+ _statItem$display_dat = statItem.display_data,
268
+ display_data = _statItem$display_dat === void 0 ? false : _statItem$display_dat,
269
+ _statItem$label_font_ = statItem.label_font_size,
270
+ label_font_size = _statItem$label_font_ === void 0 ? 12 : _statItem$label_font_;
271
+ if (isPreview) {
272
+ _this.chart = new Chart({
273
+ container: _this.container,
274
+ autoFit: true,
275
+ appendPadding: [display_data ? 20 : 3, 0, 0, 0]
276
+ });
277
+ } else {
278
+ _this.chart = new Chart({
279
+ container: _this.container,
280
+ autoFit: true,
281
+ height: 400,
282
+ width: 700,
283
+ appendPadding: [display_data ? 20 : 3, 0, 0, 0]
284
+ });
285
+ }
286
+ _this.chart.data(data);
287
+ _this.chart.coordinate('rect');
288
+ _this.chart.on('element:click', function (e) {
289
+ if (e.data.data) {
290
+ _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
291
+ }
292
+ });
293
+ var table = getTableById(table_id);
294
+ var column1 = TableUtils.getTableColumnByKey(table, y_axis_left_summary_column) || {};
295
+ var column2 = TableUtils.getTableColumnByKey(table, y_axis_right_summary_column) || {};
296
+ var column1Data = column1.data || DEFAULT_NUMBER_FORMAT_OBJECT;
297
+ var column2Data = column2.data || DEFAULT_NUMBER_FORMAT_OBJECT;
298
+ var leftValueScaleOptions = {
299
+ formatter: function formatter(value) {
300
+ return getNumberDisplayString(value, column1Data);
301
+ }
302
+ };
303
+ var rightValueScaleOptions = {
304
+ formatter: function formatter(value) {
305
+ return getNumberDisplayString(value, column2Data);
306
+ }
307
+ };
308
+ if (!y_axis_auto_range_left) {
309
+ leftValueScaleOptions = Object.assign({}, leftValueScaleOptions, {
310
+ min: y_axis_min_left,
311
+ max: y_axis_max_left
312
+ });
313
+ }
314
+ if (!y_axis_auto_range_right) {
315
+ rightValueScaleOptions = Object.assign({}, rightValueScaleOptions, {
316
+ min: y_axis_min_right,
317
+ max: y_axis_max_right
318
+ });
319
+ }
320
+ _this.chart.scale({
321
+ name: {
322
+ type: 'cat'
323
+ },
324
+ // Automatic adjustment of maximum and minimum values
325
+ // Automatic adjustment of maximum and minimum values
326
+ value_left: leftValueScaleOptions,
327
+ value_right: rightValueScaleOptions
328
+ });
329
+ var themeColors = STAT_ITEM_THEME_COLORS.light;
330
+ if (theme === 'dark' && !isEnlarge && isPreview) {
331
+ themeColors = STAT_ITEM_THEME_COLORS.dark;
332
+ }
333
+ _this.chart.axis('name', {
334
+ label: {
335
+ style: {
336
+ fill: themeColors.textColor
337
+ },
338
+ formatter: function formatter(name) {
339
+ if (name === '' || name == null) {
340
+ return intl.get(EMPTY_NAME);
341
+ }
342
+ return name;
343
+ }
344
+ },
345
+ line: {
346
+ style: themeColors.gridColor
347
+ }
348
+ });
349
+ _this.chart.axis('value_left', {
350
+ grid: {
351
+ line: {
352
+ style: {
353
+ stroke: themeColors.gridColor
354
+ }
355
+ }
356
+ },
357
+ label: {
358
+ style: {
359
+ fill: themeColors.textColor
360
+ }
361
+ }
362
+ });
363
+ _this.chart.axis('value_right', {
364
+ grid: null,
365
+ label: {
366
+ style: {
367
+ fill: themeColors.textColor
368
+ }
369
+ }
370
+ });
371
+ var legendPosition = 'bottom';
372
+ _this.chart.legend({
373
+ custom: true,
374
+ position: legendPosition,
375
+ itemName: {
376
+ style: {
377
+ fill: themeColors.textColor
378
+ }
379
+ },
380
+ items: _this.getLegend(table, currentTheme)
381
+ });
382
+ _this.chart.interval().position('name*value_left').color('color', function (color) {
383
+ if (!y_axis_left_group_by_multiple_numeric_column) {
384
+ return currentTheme && currentTheme.colors[0];
385
+ }
386
+ return color;
387
+ }).adjust('dodge').tooltip('name*value_left', function (name, value) {
388
+ return {
389
+ title: y_axis_left_summary_type == SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_left_summary_method]),
390
+ value: getNumberDisplayString(value, column1Data),
391
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
392
+ };
393
+ });
394
+ _this.chart.tooltip({
395
+ showMarkers: false
396
+ });
397
+ _this.chart.line().position('name*value_right').color(currentTheme && currentTheme.colors[1]).size(3).tooltip('name*value_right', function (name, value) {
398
+ return {
399
+ title: y_axis_right_summary_type == SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_right_summary_method]),
400
+ value: getNumberDisplayString(value, column2Data),
401
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
402
+ };
403
+ });
404
+ _this.chart.point().position('name*value_right').color(currentTheme && currentTheme.colors[1]).size(3).shape('circle').label(display_data ? 'value_right' : false, {
405
+ style: {
406
+ fontSize: getLabelFontSize(label_font_size),
407
+ fill: themeColors.textColor
408
+ }
409
+ }).tooltip('name*value_right', function (name, value) {
410
+ return {
411
+ title: y_axis_right_summary_type == SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_right_summary_method]),
412
+ value: getNumberDisplayString(value, column2Data),
413
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
414
+ };
415
+ });
416
+ _this.chart.removeInteraction('legend-filter');
417
+ _this.chart.render();
418
+ _this.renderAxisLabel();
419
+ };
420
+ _this.getLegend = function (table, colorTheme) {
421
+ var statItem = _this.props.statItem;
422
+ var y_axis_left_group_by_multiple_numeric_column = statItem.y_axis_left_group_by_multiple_numeric_column,
423
+ y_axis_left_summary_column = statItem.y_axis_left_summary_column,
424
+ y_axis_right_summary_column = statItem.y_axis_right_summary_column,
425
+ y_axis_left_group_by_numeric_columns = statItem.y_axis_left_group_by_numeric_columns;
426
+ var legendItems = [];
427
+ var column1 = TableUtils.getTableColumnByKey(table, y_axis_left_summary_column) || {};
428
+ var column2 = TableUtils.getTableColumnByKey(table, y_axis_right_summary_column) || {};
429
+ if (!y_axis_left_group_by_multiple_numeric_column) {
430
+ legendItems.push({
431
+ value: 'value_left',
432
+ name: column1.name || intl.get(LEGEND_LEFT),
433
+ marker: {
434
+ symbol: 'square',
435
+ style: {
436
+ fill: colorTheme && colorTheme.colors[0],
437
+ r: 5
438
+ }
439
+ }
440
+ }, {
441
+ value: 'value_right',
442
+ name: column2.name || intl.get(LEGEND_RIGHT),
443
+ marker: {
444
+ symbol: 'hyphen',
445
+ style: {
446
+ stroke: colorTheme && colorTheme.colors[1],
447
+ r: 5,
448
+ lineWidth: 3
449
+ }
450
+ }
451
+ });
452
+ } else {
453
+ legendItems.push({
454
+ value: 'value_left',
455
+ name: column1.name || intl.get(LEGEND_LEFT),
456
+ marker: {
457
+ fill: LABEL_COLORS[0],
458
+ symbol: 'square',
459
+ style: {
460
+ r: 5
461
+ }
462
+ }
463
+ });
464
+ y_axis_left_group_by_numeric_columns.forEach(function (item, index) {
465
+ var column = TableUtils.getTableColumnByKey(table, item.column_key) || {};
466
+ legendItems.push({
467
+ value: 'group_name',
468
+ name: column.name || intl.get(LEGEND_LEFT),
469
+ marker: {
470
+ symbol: 'square',
471
+ style: {
472
+ fill: LABEL_COLORS[(index + 1) % 12],
473
+ r: 5
474
+ }
475
+ }
476
+ });
477
+ });
478
+ legendItems.push({
479
+ value: 'value_right',
480
+ name: column2.name || intl.get(LEGEND_RIGHT),
481
+ marker: {
482
+ symbol: 'hyphen',
483
+ style: {
484
+ stroke: colorTheme && colorTheme.colors[1],
485
+ r: 5,
486
+ lineWidth: 3
487
+ }
488
+ }
489
+ });
490
+ }
491
+ return legendItems;
492
+ };
493
+ _this.destroyChart = function () {
494
+ _this.chart.destroy();
495
+ _this.chart = null;
496
+ };
497
+ _this.state = {
498
+ isCalculatingData: true,
499
+ showResultDescription: true
500
+ };
501
+ _this.calculateData = null;
502
+ return _this;
503
+ }
504
+ _createClass(CombinationChart, [{
505
+ key: "shouldComponentUpdate",
506
+ value: function shouldComponentUpdate(nextProps, nextState) {
507
+ var _this$props5 = this.props,
508
+ theme = _this$props5.theme,
509
+ colorThemeName = _this$props5.colorThemeName;
510
+ if (this.canUpdate(this.props, nextProps)) {
511
+ return true;
512
+ }
513
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
514
+ return true;
515
+ }
516
+ if (nextProps.theme !== theme) {
517
+ return true;
518
+ }
519
+ if (nextProps.colorThemeName !== colorThemeName) {
520
+ return true;
521
+ }
522
+ return false;
523
+ }
524
+ }, {
525
+ key: "componentWillUnmount",
526
+ value: function componentWillUnmount() {
527
+ this.container = null;
528
+ this.unsubscribeStyleChange();
529
+ }
530
+ }, {
531
+ key: "render",
532
+ value: function render() {
533
+ var _this2 = this;
534
+ var statItem = this.props.statItem;
535
+ var _this$state = this.state,
536
+ isCalculatingData = _this$state.isCalculatingData,
537
+ showResultDescription = _this$state.showResultDescription;
538
+ var show_y_axis_left_label = statItem.show_y_axis_left_label,
539
+ show_x_axis_label = statItem.show_x_axis_label;
540
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
541
+ className: 'statistic-chart-loading-container'
542
+ }, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
543
+ className: 'statistic-chart-text'
544
+ }, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
545
+ ref: function ref(_ref3) {
546
+ return _this2.container = _ref3;
547
+ },
548
+ style: {
549
+ padding: show_y_axis_left_label || show_x_axis_label ? 30 : 20
550
+ },
551
+ className: "statistic-chart-container"
552
+ }));
553
+ }
554
+ }]);
555
+ return CombinationChart;
556
+ }(BaseChart);
557
+ CombinationChart.propTypes = propTypes;
558
+ export default CombinationChart;