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,183 @@
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
+ import React from 'react';
6
+ import PivotTable from './pivot-table';
7
+ import BarChart from './bar-chart';
8
+ import CompareChart from './compare-chart';
9
+ import HorizontalBarChart from './horizontal-bar-chart';
10
+ import CompletenessChart from './completeness-chart';
11
+ import LineChart from './line-chart';
12
+ import AreaChart from './area-chart';
13
+ import PieChart from './pie-chart';
14
+ import RingChart from './ring-chart';
15
+ import ScatterChart from './scatter-chart';
16
+ import CombinationChart from './combination-chart';
17
+ import Map from './map';
18
+ import WorldMap from './world-map';
19
+ import HeatMap from './heat-map';
20
+ import Mirror from './mirror';
21
+ import BasicNumberCard from './basic-number-card';
22
+ import TrendChart from './trend-chart';
23
+ import DashboardChart from './dashboard-chart';
24
+ import TreeMap from './treemap-chart';
25
+ import CustomBar from './custom-bar';
26
+ import { STAT_TYPE } from '../constants';
27
+ var StatView = /*#__PURE__*/function (_React$Component) {
28
+ _inherits(StatView, _React$Component);
29
+ var _super = _createSuper(StatView);
30
+ function StatView() {
31
+ var _this;
32
+ _classCallCheck(this, StatView);
33
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
34
+ args[_key] = arguments[_key];
35
+ }
36
+ _this = _super.call.apply(_super, [this].concat(args));
37
+ _this.getStatData = function () {
38
+ if (!_this.chartView || !_this.chartView.getStatData) return null;
39
+ return _this.chartView.getStatData();
40
+ };
41
+ return _this;
42
+ }
43
+ _createClass(StatView, [{
44
+ key: "render",
45
+ value: function render() {
46
+ var _this2 = this;
47
+ var _this$props = this.props,
48
+ isPreview = _this$props.isPreview,
49
+ isEnlarge = _this$props.isEnlarge,
50
+ isEdit = _this$props.isEdit,
51
+ refresh = _this$props.refresh,
52
+ theme = _this$props.theme,
53
+ colorThemeName = _this$props.colorThemeName,
54
+ statItem = _this$props.statItem,
55
+ chartCalculator = _this$props.chartCalculator,
56
+ eventBus = _this$props.eventBus,
57
+ getTableById = _this$props.getTableById,
58
+ toggleStatisticRecordsDialog = _this$props.toggleStatisticRecordsDialog;
59
+ var viewProps = {
60
+ isPreview: isPreview,
61
+ isEnlarge: isEnlarge,
62
+ isEdit: isEdit,
63
+ refresh: refresh,
64
+ theme: theme,
65
+ colorThemeName: colorThemeName,
66
+ statItem: statItem,
67
+ chartCalculator: chartCalculator,
68
+ eventBus: eventBus,
69
+ getTableById: getTableById,
70
+ toggleStatisticRecordsDialog: toggleStatisticRecordsDialog,
71
+ ref: function ref(_ref) {
72
+ _this2.chartView = _ref;
73
+ }
74
+ };
75
+ switch (statItem.type) {
76
+ case STAT_TYPE.BAR:
77
+ case STAT_TYPE.BAR_GROUP:
78
+ case STAT_TYPE.BAR_STACK:
79
+ {
80
+ return /*#__PURE__*/React.createElement(BarChart, viewProps);
81
+ }
82
+ case STAT_TYPE.COMPARE_BAR:
83
+ {
84
+ return /*#__PURE__*/React.createElement(CompareChart, viewProps);
85
+ }
86
+ case STAT_TYPE.HORIZONTAL_BAR:
87
+ case STAT_TYPE.HORIZONTAL_GROUP_BAR:
88
+ case STAT_TYPE.STACKED_HORIZONTAL_BAR:
89
+ {
90
+ return /*#__PURE__*/React.createElement(HorizontalBarChart, viewProps);
91
+ }
92
+ case STAT_TYPE.COMPLETENESS_CHART:
93
+ case STAT_TYPE.GROUP_COMPLETENESS_CHART:
94
+ {
95
+ return /*#__PURE__*/React.createElement(CompletenessChart, viewProps);
96
+ }
97
+ case STAT_TYPE.LINE:
98
+ case STAT_TYPE.GROUP_LINE:
99
+ {
100
+ return /*#__PURE__*/React.createElement(LineChart, viewProps);
101
+ }
102
+ case STAT_TYPE.AREA_CHART:
103
+ case STAT_TYPE.AREA_GROUP_CHART:
104
+ {
105
+ return /*#__PURE__*/React.createElement(AreaChart, viewProps);
106
+ }
107
+ case STAT_TYPE.PIE:
108
+ {
109
+ return /*#__PURE__*/React.createElement(PieChart, viewProps);
110
+ }
111
+ case STAT_TYPE.RING:
112
+ {
113
+ return /*#__PURE__*/React.createElement(RingChart, viewProps);
114
+ }
115
+ case STAT_TYPE.SCATTER:
116
+ {
117
+ return /*#__PURE__*/React.createElement(ScatterChart, viewProps);
118
+ }
119
+ case STAT_TYPE.COMBINATION_CHART:
120
+ {
121
+ return /*#__PURE__*/React.createElement(CombinationChart, viewProps);
122
+ }
123
+ case STAT_TYPE.MAP:
124
+ case STAT_TYPE.MAP_BUBBLE:
125
+ {
126
+ viewProps.isPreview = viewProps.isEnlarge ? false : viewProps.isPreview;
127
+ return /*#__PURE__*/React.createElement(Map, viewProps);
128
+ }
129
+ case STAT_TYPE.WORLD_MAP:
130
+ case STAT_TYPE.WORLD_MAP_BUBBLE:
131
+ {
132
+ viewProps.isPreview = viewProps.isEnlarge ? false : viewProps.isPreview;
133
+ return /*#__PURE__*/React.createElement(WorldMap, viewProps);
134
+ }
135
+ case STAT_TYPE.HEAT_MAP:
136
+ {
137
+ viewProps.isPreview = viewProps.isEnlarge ? false : viewProps.isPreview;
138
+ return /*#__PURE__*/React.createElement(HeatMap, viewProps);
139
+ }
140
+ case STAT_TYPE.MIRROR:
141
+ {
142
+ viewProps.isPreview = viewProps.isEnlarge ? false : viewProps.isPreview;
143
+ return /*#__PURE__*/React.createElement(Mirror, viewProps);
144
+ }
145
+ case STAT_TYPE.BASIC_NUMBER_CARD:
146
+ {
147
+ return /*#__PURE__*/React.createElement(BasicNumberCard, viewProps);
148
+ }
149
+ case STAT_TYPE.TREND_CHART:
150
+ {
151
+ return /*#__PURE__*/React.createElement(TrendChart, viewProps);
152
+ }
153
+ case STAT_TYPE.DASHBOARD:
154
+ {
155
+ return /*#__PURE__*/React.createElement(DashboardChart, viewProps);
156
+ }
157
+ case STAT_TYPE.TREEMAP:
158
+ {
159
+ return /*#__PURE__*/React.createElement(TreeMap, viewProps);
160
+ }
161
+ case STAT_TYPE.PIVOT_TABLE:
162
+ {
163
+ return /*#__PURE__*/React.createElement(PivotTable, viewProps);
164
+ }
165
+ case STAT_TYPE.CUSTOM_BAR:
166
+ {
167
+ return /*#__PURE__*/React.createElement(CustomBar, viewProps);
168
+ }
169
+ default:
170
+ {
171
+ return null;
172
+ }
173
+ }
174
+ }
175
+ }]);
176
+ return StatView;
177
+ }(React.Component);
178
+ StatView.defaultProps = {
179
+ isPreview: false,
180
+ isEnlarge: false,
181
+ isEdit: false
182
+ };
183
+ export default StatView;
@@ -0,0 +1,505 @@
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
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import intl from 'react-intl-universal';
8
+ import { TableUtils, getNumberDisplayString } from 'dtable-store';
9
+ import BaseChart from './base-chart';
10
+ import { Chart } from '../custom-g2';
11
+ import { Loading } from '../components';
12
+ import { getCurrentTheme, getLabelFontSize } from '../utils/common-utils';
13
+ import { getChartDisplayLabels, getChartGroups } from '../utils/basic-chart-utils';
14
+ import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_AMOUNT, USEABLE_COLOR_TYPES } from '../constants';
15
+ var propTypes = {
16
+ isPreview: PropTypes.bool,
17
+ isEnlarge: PropTypes.bool,
18
+ isEdit: PropTypes.bool,
19
+ theme: PropTypes.string,
20
+ colorThemeName: PropTypes.string,
21
+ statItem: PropTypes.object,
22
+ chartCalculator: PropTypes.object,
23
+ eventBus: PropTypes.object,
24
+ getTableById: PropTypes.func,
25
+ toggleStatisticRecordsDialog: PropTypes.func
26
+ };
27
+ var LineChart = /*#__PURE__*/function (_BaseChart) {
28
+ _inherits(LineChart, _BaseChart);
29
+ var _super = _createSuper(LineChart);
30
+ function LineChart(props) {
31
+ var _this;
32
+ _classCallCheck(this, LineChart);
33
+ _this = _super.call(this, props);
34
+ _this.drawChart = function (data) {
35
+ var _this$props = _this.props,
36
+ getTableById = _this$props.getTableById,
37
+ isPreview = _this$props.isPreview,
38
+ statItem = _this$props.statItem,
39
+ isEnlarge = _this$props.isEnlarge,
40
+ theme = _this$props.theme,
41
+ colorThemeName = _this$props.colorThemeName;
42
+ var currentTheme = getCurrentTheme(colorThemeName);
43
+ if (isPreview) {
44
+ _this.chart = new Chart({
45
+ container: _this.container,
46
+ autoFit: true
47
+ });
48
+ } else {
49
+ _this.chart = new Chart({
50
+ container: _this.container,
51
+ height: 400,
52
+ width: 700
53
+ });
54
+ }
55
+ _this.chart.on('element:click', function (e) {
56
+ if (e.data && e.data.data) {
57
+ _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
58
+ }
59
+ });
60
+ var table_id = statItem.table_id,
61
+ summary_type = statItem.summary_type,
62
+ y_axis_column_key = statItem.y_axis_column_key,
63
+ y_axis_summary_type = statItem.y_axis_summary_type,
64
+ summary_method = statItem.summary_method,
65
+ y_axis_summary_method = statItem.y_axis_summary_method,
66
+ column_groupby_column_key = statItem.column_groupby_column_key,
67
+ display_data = statItem.display_data,
68
+ y_axis_auto_range = statItem.y_axis_auto_range,
69
+ y_axis_min = statItem.y_axis_min,
70
+ y_axis_max = statItem.y_axis_max,
71
+ column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
72
+ color_option = statItem.color_option;
73
+ if (!summary_type && y_axis_summary_type) {
74
+ summary_type = y_axis_summary_type;
75
+ }
76
+ if (!summary_method && y_axis_summary_method) {
77
+ summary_method = y_axis_summary_method;
78
+ }
79
+ var chartBarColor = currentTheme && currentTheme.colors[0] || '#2a67d1';
80
+ if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
81
+ _this.chart.scale('group_name', {
82
+ type: 'cat'
83
+ });
84
+ }
85
+ _this.chart.data(data, {
86
+ 'name': {
87
+ type: 'cat',
88
+ nice: false
89
+ }
90
+ });
91
+ var width = _this.chart.coordinateBBox.width;
92
+ var chartData,
93
+ columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
94
+ if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
95
+ chartData = getChartGroups(data);
96
+ } else {
97
+ chartData = data;
98
+ }
99
+ var labelCount = chartData.length;
100
+ if (Math.floor(width / labelCount) <= 20) {
101
+ var displayLabels = getChartDisplayLabels(width, 20, chartData);
102
+ labelCount = displayLabels.length;
103
+ _this.chart.scale('name', {
104
+ type: 'cat',
105
+ ticks: displayLabels
106
+ });
107
+ }
108
+ if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
109
+ var table = getTableById(table_id);
110
+ var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
111
+ columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
112
+ }
113
+ var themeColors = STAT_ITEM_THEME_COLORS.light;
114
+ if (theme === 'dark' && !isEnlarge && isPreview) {
115
+ themeColors = STAT_ITEM_THEME_COLORS.dark;
116
+ }
117
+
118
+ // set Coord type
119
+ _this.chart.coordinate('rect');
120
+ var valueScaleOptions = {
121
+ formatter: function formatter(value) {
122
+ return getNumberDisplayString(value, columnData);
123
+ }
124
+ };
125
+ if (y_axis_auto_range == undefined || y_axis_auto_range) {
126
+ valueScaleOptions = Object.assign({}, valueScaleOptions, {
127
+ nice: true
128
+ });
129
+ } else {
130
+ valueScaleOptions = Object.assign({}, valueScaleOptions, {
131
+ min: y_axis_min,
132
+ max: y_axis_max
133
+ });
134
+ // set the filter rule
135
+ _this.chart.filter('value', function (value) {
136
+ return value >= y_axis_min;
137
+ });
138
+ // filter the data
139
+ _this.chart.filterData(data);
140
+ }
141
+ _this.chart.scale({
142
+ value: valueScaleOptions
143
+ });
144
+ if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
145
+ var groupColorCallback = currentTheme && currentTheme.colors;
146
+ // when the 'Group by' column is a 'single-select' column,
147
+ // and the user chooses to use the colors from the column.
148
+ if (color_option === USEABLE_COLOR_TYPES[1]) {
149
+ var groupColorMapping = {};
150
+ data.forEach(function (item) {
151
+ if (!groupColorMapping[item.group_name]) {
152
+ groupColorMapping[item.group_name] = item.color;
153
+ }
154
+ });
155
+ groupColorCallback = function groupColorCallback(group_name) {
156
+ return groupColorMapping[group_name];
157
+ };
158
+ }
159
+ _this.chart.scale({
160
+ group_name: {
161
+ type: 'cat'
162
+ }
163
+ });
164
+ _this.chart.line().position('name*value').color('group_name', groupColorCallback);
165
+ _this.chart.point().label(display_data ? 'value' : false, {
166
+ style: {
167
+ fontSize: _this.getLabelFontSize(),
168
+ fill: themeColors.textColor
169
+ }
170
+ }).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*value*group_name', function (name, value, group_name) {
171
+ return {
172
+ title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
173
+ value: getNumberDisplayString(value, columnData),
174
+ name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
175
+ };
176
+ }).shape('circle').style({
177
+ lineWidth: 1,
178
+ stroke: '#fff'
179
+ });
180
+ } else {
181
+ _this.chart.line().position('name*value').color(chartBarColor).tooltip('name*value', function (name, value) {
182
+ return {
183
+ name: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method]),
184
+ value: getNumberDisplayString(value, columnData)
185
+ };
186
+ });
187
+ _this.chart.point().label(display_data ? 'value' : false, {
188
+ style: {
189
+ fontSize: _this.getLabelFontSize(),
190
+ fill: themeColors.textColor
191
+ }
192
+ }).position('name*value').color(chartBarColor).shape('circle').size(3).style({
193
+ lineWidth: 1,
194
+ stroke: '#fff'
195
+ }).tooltip('name*value', function (name, value) {
196
+ return {
197
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
198
+ value: getNumberDisplayString(value, columnData),
199
+ title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method])
200
+ };
201
+ });
202
+ }
203
+ _this.chart.tooltip({
204
+ showCrosshairs: true,
205
+ showTitle: true,
206
+ containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
207
+ itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
208
+ domStyles: {
209
+ 'g2-tooltip': {
210
+ borderRadius: '2px',
211
+ backgroundColor: '#fff',
212
+ padding: '10px'
213
+ },
214
+ 'tooltip-item': {
215
+ marginTop: '5px'
216
+ }
217
+ }
218
+ });
219
+ _this.chart.axis('name', {
220
+ line: {
221
+ style: themeColors.gridColor
222
+ },
223
+ label: {
224
+ style: {
225
+ fill: themeColors.textColor
226
+ },
227
+ offset: 20,
228
+ autoRotate: true,
229
+ rotate: labelCount > 11 ? 0.3 : 0,
230
+ formatter: function formatter(name) {
231
+ var label = name;
232
+ if (name.length > 10) {
233
+ label = "".concat(name.slice(0, 10), "...");
234
+ }
235
+ if (name === '' || name === 'undefined') {
236
+ label = intl.get(EMPTY_NAME);
237
+ }
238
+ return label;
239
+ }
240
+ }
241
+ });
242
+ _this.chart.axis('value', {
243
+ label: {
244
+ style: {
245
+ fill: themeColors.textColor
246
+ }
247
+ },
248
+ grid: {
249
+ line: {
250
+ style: {
251
+ stroke: themeColors.gridColor
252
+ }
253
+ }
254
+ }
255
+ });
256
+ _this.chart.theme({
257
+ geometries: {
258
+ point: {
259
+ circle: {
260
+ active: {
261
+ style: {
262
+ stroke: 'rgba(0, 0, 0, 0)',
263
+ r: 4
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
269
+ });
270
+ _this.chart.legend('group_name', {
271
+ position: 'bottom',
272
+ itemName: {
273
+ style: {
274
+ fill: themeColors.textColor
275
+ },
276
+ formatter: function formatter(name) {
277
+ return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
278
+ }
279
+ },
280
+ pageNavigator: {
281
+ text: {
282
+ style: {
283
+ fill: themeColors.textColor
284
+ }
285
+ },
286
+ marker: {
287
+ style: {
288
+ fill: themeColors.legendPageNavigatorMarkerColor,
289
+ inactiveFill: themeColors.legendPageNavigatorMarkerColor,
290
+ inactiveOpacity: 0.45
291
+ }
292
+ }
293
+ }
294
+ });
295
+ _this.chart.render();
296
+ _this.renderAxisLabel();
297
+ };
298
+ _this.renderAxisLabel = function (newStatItem) {
299
+ var _this$props2 = _this.props,
300
+ getTableById = _this$props2.getTableById,
301
+ statItem = _this$props2.statItem,
302
+ isEnlarge = _this$props2.isEnlarge,
303
+ isPreview = _this$props2.isPreview,
304
+ theme = _this$props2.theme;
305
+ if (newStatItem && newStatItem._id !== statItem._id) {
306
+ return;
307
+ }
308
+ if (!_this.chart) return;
309
+ statItem = newStatItem || statItem;
310
+ var _statItem = statItem,
311
+ table_id = _statItem.table_id,
312
+ x_axis_column_key = _statItem.x_axis_column_key,
313
+ y_axis_column_key = _statItem.y_axis_column_key,
314
+ show_y_axis_label = _statItem.show_y_axis_label,
315
+ show_x_axis_label = _statItem.show_x_axis_label,
316
+ y_axis_label_position = _statItem.y_axis_label_position,
317
+ x_axis_label_position = _statItem.x_axis_label_position,
318
+ y_axis_summary_type = _statItem.y_axis_summary_type;
319
+ var table = getTableById(table_id);
320
+ var autoPadding = _this.chart.autoPadding;
321
+ var textColor = '#999999';
322
+ if (theme === 'dark' && !isEnlarge && isPreview) {
323
+ textColor = '#ffffff';
324
+ }
325
+ var xAxisID = "chart-x-axis-label_".concat(statItem._id);
326
+ var chartContainer = _this.chart.getCanvas().get('container');
327
+ var xLabel = chartContainer.querySelector("#".concat(xAxisID));
328
+ if (!xLabel && show_x_axis_label) {
329
+ var div = document.createElement('div');
330
+ div.id = xAxisID;
331
+ div.className = 'statistic-chart-axis-label';
332
+ var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
333
+ div.innerHTML = "".concat(column ? column.name : '');
334
+ div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
335
+ chartContainer.appendChild(div);
336
+ }
337
+ if (xLabel && show_x_axis_label) {
338
+ xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
339
+ }
340
+ if (xLabel && !show_x_axis_label) {
341
+ xLabel.parentNode.removeChild(xLabel);
342
+ }
343
+ var yAxisID = "chart-y-axis-label_".concat(statItem._id);
344
+ var yLabel = chartContainer.querySelector("#".concat(yAxisID));
345
+ var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
346
+ if (!yLabel && show_y_axis_label) {
347
+ var _div = document.createElement('div');
348
+ _div.id = yAxisID;
349
+ _div.className = 'statistic-chart-axis-label';
350
+ if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
351
+ _div.innerHTML = intl.get(TITLE_AMOUNT);
352
+ } else {
353
+ var _column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
354
+ _div.innerHTML = _column.name || '';
355
+ }
356
+ var containerHeight = chartContainer.offsetHeight;
357
+ var textAlign = 'center';
358
+ if (y_axis_label_position === 'bottom') textAlign = 'left';
359
+ if (y_axis_label_position === 'top') textAlign = 'right';
360
+ _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)"));
361
+ chartContainer.appendChild(_div);
362
+ }
363
+ if (yLabel && show_y_axis_label) {
364
+ var _containerHeight = chartContainer.offsetHeight;
365
+ var _textAlign = 'center';
366
+ if (y_axis_label_position === 'bottom') _textAlign = 'left';
367
+ if (y_axis_label_position === 'top') _textAlign = 'right';
368
+ 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)"));
369
+ }
370
+ if (yLabel && !show_y_axis_label) {
371
+ yLabel.parentNode.removeChild(yLabel);
372
+ }
373
+ };
374
+ _this.destroyChart = function () {
375
+ _this.chart.destroy();
376
+ _this.chart = null;
377
+ };
378
+ _this.getLabelFontSize = function () {
379
+ var statItem = _this.props.statItem;
380
+ var label_font_size = statItem.label_font_size;
381
+ return getLabelFontSize(label_font_size);
382
+ };
383
+ _this.state = {
384
+ isCalculatingData: true,
385
+ showResultDescription: true
386
+ };
387
+ _this.calculateData = null;
388
+ return _this;
389
+ }
390
+ _createClass(LineChart, [{
391
+ key: "componentDidMount",
392
+ value: function componentDidMount() {
393
+ var _this2 = this;
394
+ var _this$props3 = this.props,
395
+ statItem = _this$props3.statItem,
396
+ chartCalculator = _this$props3.chartCalculator,
397
+ eventBus = _this$props3.eventBus;
398
+ this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
399
+ _this2.renderAxisLabel(newStatItem);
400
+ });
401
+ if (this.container) {
402
+ chartCalculator.calculate(statItem).then(function (data) {
403
+ var showResultDescription = data.length > 0 ? false : true;
404
+ _this2.setState({
405
+ isCalculatingData: false,
406
+ showResultDescription: showResultDescription
407
+ }, function () {
408
+ if (!showResultDescription) {
409
+ _this2.drawChart(data);
410
+ _this2.calculateData = data;
411
+ }
412
+ });
413
+ });
414
+ }
415
+ }
416
+ }, {
417
+ key: "shouldComponentUpdate",
418
+ value: function shouldComponentUpdate(nextProps, nextState) {
419
+ var colorThemeName = this.props.colorThemeName;
420
+ if (this.canUpdate(this.props, nextProps)) {
421
+ return true;
422
+ }
423
+ if (nextState.isCalculatingData !== this.state.isCalculatingData) {
424
+ return true;
425
+ }
426
+ if (nextProps.colorThemeName !== colorThemeName) {
427
+ return true;
428
+ }
429
+ return false;
430
+ }
431
+ }, {
432
+ key: "componentDidUpdate",
433
+ value: function componentDidUpdate(preProps, preState) {
434
+ var _this3 = this;
435
+ var _this$props4 = this.props,
436
+ statItem = _this$props4.statItem,
437
+ chartCalculator = _this$props4.chartCalculator;
438
+ var isCalculatingData = this.state.isCalculatingData;
439
+ if (isCalculatingData !== preState.isCalculatingData) return;
440
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
441
+ this.setState({
442
+ isCalculatingData: true
443
+ });
444
+ if (this.container) {
445
+ chartCalculator.calculate(statItem).then(function (data) {
446
+ var showResultDescription = data.length > 0 ? false : true;
447
+ _this3.chart && _this3.destroyChart();
448
+ _this3.calculateData = data;
449
+ _this3.setState({
450
+ isCalculatingData: false,
451
+ showResultDescription: showResultDescription
452
+ }, function () {
453
+ if (!showResultDescription) {
454
+ _this3.drawChart(data);
455
+ if (_this3.props.isPreview) _this3.chart.forceFit();
456
+ }
457
+ });
458
+ });
459
+ }
460
+ } else {
461
+ if (!this.state.showResultDescription) {
462
+ this.chart && this.destroyChart();
463
+ this.drawChart(this.calculateData);
464
+ if (this.props.isPreview) {
465
+ this.chart.forceFit();
466
+ }
467
+ }
468
+ }
469
+ }
470
+ }, {
471
+ key: "componentWillUnmount",
472
+ value: function componentWillUnmount() {
473
+ this.container = null;
474
+ this.unsubscribeStyleChange();
475
+ }
476
+ }, {
477
+ key: "render",
478
+ value: function render() {
479
+ var _this4 = this;
480
+ var statItem = this.props.statItem;
481
+ var _this$state = this.state,
482
+ isCalculatingData = _this$state.isCalculatingData,
483
+ showResultDescription = _this$state.showResultDescription;
484
+ var show_y_axis_label = statItem.show_y_axis_label,
485
+ show_x_axis_label = statItem.show_x_axis_label;
486
+ var style = {
487
+ padding: show_y_axis_label || show_x_axis_label ? 30 : 20
488
+ };
489
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
490
+ className: 'statistic-chart-loading-container'
491
+ }, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
492
+ className: 'statistic-chart-text'
493
+ }, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
494
+ ref: function ref(_ref) {
495
+ return _this4.container = _ref;
496
+ },
497
+ style: style,
498
+ className: "statistic-chart-container"
499
+ }));
500
+ }
501
+ }]);
502
+ return LineChart;
503
+ }(BaseChart);
504
+ LineChart.propTypes = propTypes;
505
+ export default LineChart;