sea-chart 0.0.1-beta

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 (213) hide show
  1. package/README.md +120 -0
  2. package/dist/assets/icons/area-chart.svg +10 -0
  3. package/dist/assets/icons/bar-chart.svg +12 -0
  4. package/dist/assets/icons/card.svg +22 -0
  5. package/dist/assets/icons/combination-chart.svg +17 -0
  6. package/dist/assets/icons/dtable-logo.svg +16 -0
  7. package/dist/assets/icons/facet-chart.svg +12 -0
  8. package/dist/assets/icons/gauge.svg +18 -0
  9. package/dist/assets/icons/heat-map.svg +14 -0
  10. package/dist/assets/icons/histogram.svg +12 -0
  11. package/dist/assets/icons/line-chart.svg +12 -0
  12. package/dist/assets/icons/map.svg +20 -0
  13. package/dist/assets/icons/pie-chart.svg +11 -0
  14. package/dist/assets/icons/rectangular-tree-diagram.svg +10 -0
  15. package/dist/assets/icons/scatter-chart.svg +15 -0
  16. package/dist/assets/icons/type-change.svg +17 -0
  17. package/dist/assets/img/area-chart.png +0 -0
  18. package/dist/assets/img/area-group-chart.png +0 -0
  19. package/dist/assets/img/bar-group.png +0 -0
  20. package/dist/assets/img/bar-stack.png +0 -0
  21. package/dist/assets/img/bar.png +0 -0
  22. package/dist/assets/img/combination-chart.png +0 -0
  23. package/dist/assets/img/compared-chart.png +0 -0
  24. package/dist/assets/img/completeness-chart.png +0 -0
  25. package/dist/assets/img/custom-bar.png +0 -0
  26. package/dist/assets/img/dashboard-chart.png +0 -0
  27. package/dist/assets/img/group-completeness-chart.png +0 -0
  28. package/dist/assets/img/group_line.png +0 -0
  29. package/dist/assets/img/heat-map.png +0 -0
  30. package/dist/assets/img/horizontal-bar.png +0 -0
  31. package/dist/assets/img/horizontal-group-bar.png +0 -0
  32. package/dist/assets/img/line.png +0 -0
  33. package/dist/assets/img/map-bubble.png +0 -0
  34. package/dist/assets/img/map.png +0 -0
  35. package/dist/assets/img/mirror.png +0 -0
  36. package/dist/assets/img/number-card.png +0 -0
  37. package/dist/assets/img/pie.png +0 -0
  38. package/dist/assets/img/pivot-table.png +0 -0
  39. package/dist/assets/img/ring.png +0 -0
  40. package/dist/assets/img/scatter.png +0 -0
  41. package/dist/assets/img/stacked-horizontal-bar.png +0 -0
  42. package/dist/assets/img/treemap.png +0 -0
  43. package/dist/assets/img/trend-chart.png +0 -0
  44. package/dist/assets/img/world-map-bubble.png +0 -0
  45. package/dist/assets/img/world-map.png +0 -0
  46. package/dist/components/collaborator/index.js +26 -0
  47. package/dist/components/icon/index.css +5 -0
  48. package/dist/components/icon/index.js +24 -0
  49. package/dist/components/index.js +8 -0
  50. package/dist/components/loading/index.css +54 -0
  51. package/dist/components/loading/index.js +12 -0
  52. package/dist/components/number-input/index.js +31 -0
  53. package/dist/components/pixel-editor/index.css +29 -0
  54. package/dist/components/pixel-editor/index.js +38 -0
  55. package/dist/components/select-group/index.css +67 -0
  56. package/dist/components/select-group/index.js +52 -0
  57. package/dist/components/types-dialog/index.css +97 -0
  58. package/dist/components/types-dialog/index.js +116 -0
  59. package/dist/constants/geolocation.js +11 -0
  60. package/dist/constants/index.js +184 -0
  61. package/dist/constants/model.js +187 -0
  62. package/dist/constants/style.js +15 -0
  63. package/dist/constants/type-image.js +59 -0
  64. package/dist/constants/type.js +124 -0
  65. package/dist/context.js +33 -0
  66. package/dist/editor/index.css +0 -0
  67. package/dist/editor/index.js +36 -0
  68. package/dist/index.js +6 -0
  69. package/dist/intl.js +37 -0
  70. package/dist/locale/index.js +18 -0
  71. package/dist/locale/lang/de.js +141 -0
  72. package/dist/locale/lang/en.js +143 -0
  73. package/dist/locale/lang/es.js +141 -0
  74. package/dist/locale/lang/fr.js +141 -0
  75. package/dist/locale/lang/pt.js +141 -0
  76. package/dist/locale/lang/ru.js +141 -0
  77. package/dist/locale/lang/zh_CN.js +143 -0
  78. package/dist/model/area-group.js +41 -0
  79. package/dist/model/area.js +32 -0
  80. package/dist/model/bar-group.js +44 -0
  81. package/dist/model/bar-stack.js +41 -0
  82. package/dist/model/bar.js +38 -0
  83. package/dist/model/base-model.js +9 -0
  84. package/dist/model/basic-number-card.js +22 -0
  85. package/dist/model/chart.js +23 -0
  86. package/dist/model/combination.js +38 -0
  87. package/dist/model/compare-bar.js +39 -0
  88. package/dist/model/completeness-group.js +24 -0
  89. package/dist/model/completeness.js +18 -0
  90. package/dist/model/dashboard.js +16 -0
  91. package/dist/model/generic-model.js +224 -0
  92. package/dist/model/heat-map.js +23 -0
  93. package/dist/model/horizontal-bar.js +38 -0
  94. package/dist/model/horizontal-group-bar.js +43 -0
  95. package/dist/model/index.js +63 -0
  96. package/dist/model/line-group.js +44 -0
  97. package/dist/model/line.js +38 -0
  98. package/dist/model/map-bubble.js +27 -0
  99. package/dist/model/map.js +27 -0
  100. package/dist/model/mirror.js +26 -0
  101. package/dist/model/pie.js +26 -0
  102. package/dist/model/ring.js +26 -0
  103. package/dist/model/scatter.js +19 -0
  104. package/dist/model/stacked-horizontal-bar.js +32 -0
  105. package/dist/model/table.js +23 -0
  106. package/dist/model/tree-map.js +20 -0
  107. package/dist/model/trend.js +24 -0
  108. package/dist/model/user.js +15 -0
  109. package/dist/model/world-map-bubble.js +26 -0
  110. package/dist/model/world-map.js +26 -0
  111. package/dist/settings/advance-bar-settings/data-settings.js +143 -0
  112. package/dist/settings/advance-bar-settings/index.js +3 -0
  113. package/dist/settings/advance-bar-settings/style-settings.js +161 -0
  114. package/dist/settings/bar-settings/data-settings.js +162 -0
  115. package/dist/settings/bar-settings/index.js +3 -0
  116. package/dist/settings/bar-settings/style-settings.js +179 -0
  117. package/dist/settings/basic-number-card/data-settings.js +126 -0
  118. package/dist/settings/basic-number-card/index.js +3 -0
  119. package/dist/settings/basic-number-card/style-settings.js +42 -0
  120. package/dist/settings/combination-settings/data-settings.js +279 -0
  121. package/dist/settings/combination-settings/index.js +3 -0
  122. package/dist/settings/combination-settings/style-settings.js +174 -0
  123. package/dist/settings/dashboard-settings/data-settings.js +179 -0
  124. package/dist/settings/dashboard-settings/index.js +2 -0
  125. package/dist/settings/data-settings.js +73 -0
  126. package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
  127. package/dist/settings/horizontal-bar-settings/index.js +3 -0
  128. package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
  129. package/dist/settings/index.css +85 -0
  130. package/dist/settings/index.js +76 -0
  131. package/dist/settings/pie-settings/data-settings.js +146 -0
  132. package/dist/settings/pie-settings/index.js +3 -0
  133. package/dist/settings/pie-settings/style-settings.js +141 -0
  134. package/dist/settings/style-settings.js +118 -0
  135. package/dist/settings/table-settings/data-settings.js +549 -0
  136. package/dist/settings/table-settings/index.js +2 -0
  137. package/dist/settings/time-comparison-settings/data-settings.js +172 -0
  138. package/dist/settings/time-comparison-settings/index.js +3 -0
  139. package/dist/settings/time-comparison-settings/style-settings.js +213 -0
  140. package/dist/settings/widgets/basic-summary/index.css +12 -0
  141. package/dist/settings/widgets/basic-summary/index.js +176 -0
  142. package/dist/settings/widgets/chart-type/index.css +31 -0
  143. package/dist/settings/widgets/chart-type/index.js +59 -0
  144. package/dist/settings/widgets/common-data-settings.js +48 -0
  145. package/dist/settings/widgets/data-filter/index.css +17 -0
  146. package/dist/settings/widgets/data-filter/index.js +89 -0
  147. package/dist/settings/widgets/data-sort.js +44 -0
  148. package/dist/settings/widgets/date-summary-item.js +111 -0
  149. package/dist/settings/widgets/display-values-settings/index.css +13 -0
  150. package/dist/settings/widgets/display-values-settings/index.js +42 -0
  151. package/dist/settings/widgets/divider/index.css +4 -0
  152. package/dist/settings/widgets/divider/index.js +12 -0
  153. package/dist/settings/widgets/font-settings/font-size-settings.js +33 -0
  154. package/dist/settings/widgets/font-settings/font-weight-settings.js +44 -0
  155. package/dist/settings/widgets/font-settings/index.js +3 -0
  156. package/dist/settings/widgets/group-by.js +160 -0
  157. package/dist/settings/widgets/label-color.js +30 -0
  158. package/dist/settings/widgets/min-max-setting.js +52 -0
  159. package/dist/settings/widgets/mininum-slice-percent.js +63 -0
  160. package/dist/settings/widgets/numeric-summary-item.js +90 -0
  161. package/dist/settings/widgets/select-table/index.css +0 -0
  162. package/dist/settings/widgets/select-table/index.js +38 -0
  163. package/dist/settings/widgets/stack.js +50 -0
  164. package/dist/settings/widgets/summary-method-setting.js +66 -0
  165. package/dist/settings/widgets/summary-settings.js +411 -0
  166. package/dist/settings/widgets/switch/index.css +37 -0
  167. package/dist/settings/widgets/switch/index.js +24 -0
  168. package/dist/settings/widgets/text-horizontal-settings.js +25 -0
  169. package/dist/settings/widgets/time-picker.js +173 -0
  170. package/dist/settings/widgets/title-settings/index.js +60 -0
  171. package/dist/settings/widgets/title-settings/title-text.js +25 -0
  172. package/dist/settings/widgets/x-axios.js +0 -0
  173. package/dist/settings/widgets/y-axis-group-settings.js +438 -0
  174. package/dist/utils/cell-format-utils.js +42 -0
  175. package/dist/utils/chart-data-sql.js +606 -0
  176. package/dist/utils/chart-utils.js +1800 -0
  177. package/dist/utils/chart.js +6 -0
  178. package/dist/utils/collaborator-utils.js +39 -0
  179. package/dist/utils/column-2-sql-column.js +551 -0
  180. package/dist/utils/column-utils.js +208 -0
  181. package/dist/utils/custom-g2.js +612 -0
  182. package/dist/utils/date-translate.js +66 -0
  183. package/dist/utils/index.js +48 -0
  184. package/dist/utils/key-generator.js +13 -0
  185. package/dist/utils/object-utils.js +45 -0
  186. package/dist/utils/options-utils.js +60 -0
  187. package/dist/view/index.css +53 -0
  188. package/dist/view/index.js +189 -0
  189. package/dist/view/title/index.css +3 -0
  190. package/dist/view/title/index.js +46 -0
  191. package/dist/view/wrapper/area.js +150 -0
  192. package/dist/view/wrapper/bar-group.js +148 -0
  193. package/dist/view/wrapper/bar.js +138 -0
  194. package/dist/view/wrapper/basic-number-card.js +127 -0
  195. package/dist/view/wrapper/chart-component.js +261 -0
  196. package/dist/view/wrapper/combination.js +399 -0
  197. package/dist/view/wrapper/dashboard.js +164 -0
  198. package/dist/view/wrapper/horizontal-bar-group.js +149 -0
  199. package/dist/view/wrapper/horizontal-bar.js +140 -0
  200. package/dist/view/wrapper/horizontal-component.js +78 -0
  201. package/dist/view/wrapper/index.js +200 -0
  202. package/dist/view/wrapper/line-group.js +145 -0
  203. package/dist/view/wrapper/line.js +157 -0
  204. package/dist/view/wrapper/pie.js +185 -0
  205. package/dist/view/wrapper/ring.js +264 -0
  206. package/dist/view/wrapper/table/index.css +103 -0
  207. package/dist/view/wrapper/table/index.js +31 -0
  208. package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
  209. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
  210. package/dist/view/wrapper/table/pivot-table-display-name.js +247 -0
  211. package/dist/view/wrapper/table/two-dimension-table.js +249 -0
  212. package/dist/view/wrapper/treemap.js +186 -0
  213. package/package.json +151 -0
@@ -0,0 +1,264 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS } from '../../constants';
4
+ import { ChartUtils } from '../../utils';
5
+ import ChartComponent from './chart-component';
6
+ import intl from '../../intl';
7
+ class Ring extends ChartComponent {
8
+ constructor(props) {
9
+ var _this;
10
+ super(props);
11
+ _this = this;
12
+ this.createChart = () => {
13
+ const {
14
+ canvasStyle
15
+ } = this.props;
16
+ this.initChart(this.container, canvasStyle, 0);
17
+ };
18
+ this.destroyChart = () => {
19
+ this.chart.destroy();
20
+ this.chart = null;
21
+ };
22
+ this.clearChart = () => {
23
+ this.chart.annotation().clear(true);
24
+ this.chart.clear(true);
25
+ };
26
+ this.drawChart = () => {
27
+ let {
28
+ result: data,
29
+ chart,
30
+ tables,
31
+ summaryColumn
32
+ } = this.props;
33
+ if (data.length === 0) return;
34
+ this.sum = data.total;
35
+ this.chart.coordinate('theta', {
36
+ radius: 0.95,
37
+ innerRadius: 0.7
38
+ });
39
+ const {
40
+ show_legend,
41
+ display_label,
42
+ label_position,
43
+ label_font_size,
44
+ summary_method
45
+ } = chart.config;
46
+ const {
47
+ data: newData,
48
+ colorSet,
49
+ total
50
+ } = ChartUtils.formatPieChartData(data, chart, tables);
51
+ if (!Array.isArray(newData)) return;
52
+ this.sum = total;
53
+ this.loadData(newData);
54
+ this.chart.on('interval:click', e => {
55
+ this.props.toggleRecords(e.data.data);
56
+ });
57
+ if (show_legend) {
58
+ this.chart.legend('name', {
59
+ position: 'right',
60
+ custom: true,
61
+ itemName: {
62
+ style: {
63
+ fill: '#6e6e6e'
64
+ }
65
+ },
66
+ items: newData.map((obj, index) => {
67
+ let name = obj.name;
68
+ if (!obj.name && typeof obj.name !== 'number') {
69
+ name = intl.get('Empty');
70
+ } else if (obj.name === '_Others') {
71
+ name = intl.get('Others');
72
+ }
73
+ return {
74
+ name,
75
+ value: obj.value,
76
+ marker: {
77
+ symbol: 'circle',
78
+ style: {
79
+ r: 5,
80
+ fill: colorSet[index]
81
+ }
82
+ }
83
+ };
84
+ })
85
+ });
86
+ } else {
87
+ this.chart.legend(false);
88
+ }
89
+
90
+ // Do not automatically adjust the maximum and minimum values in pie chart
91
+ this.chart.scale({
92
+ value: {
93
+ nice: false
94
+ }
95
+ });
96
+ this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', (value, percent) => {
97
+ const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
98
+ return {
99
+ content: this.getLabel(displayValue, percent)
100
+ };
101
+ }, {
102
+ offset: !label_position || label_position === CHART_LABEL_POSITIONS[0] ? -2 : undefined,
103
+ style: {
104
+ fill: '#000000',
105
+ fontSize: ChartUtils.getLabelFontSize(label_font_size),
106
+ shadowBlur: 2,
107
+ shadowColor: 'rgba(0, 0, 0, .45)'
108
+ }
109
+ }).tooltip('name*value*percent', (name, value, percent) => {
110
+ let title = name;
111
+ if (!name || name === 'undefined') {
112
+ title = intl.get('Empty');
113
+ } else if (name === '_Others') {
114
+ title = intl.get('Others');
115
+ }
116
+ const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
117
+ return {
118
+ name: title,
119
+ value: display_label ? this.getLabel(displayValue, percent) : displayValue
120
+ };
121
+ }).state({
122
+ active: {
123
+ style: {
124
+ fillOpacity: 0.7,
125
+ border: 'none',
126
+ stroke: 0
127
+ }
128
+ }
129
+ });
130
+ this.chart.tooltip({
131
+ showTitle: false,
132
+ showMarkers: false,
133
+ itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
134
+ });
135
+ this.chart.interaction('chart-active');
136
+ this.setAnnotation({
137
+ name: intl.get('Total'),
138
+ value: ChartUtils.getSummaryValueDisplayString(summaryColumn, this.sum, summary_method)
139
+ }, '#000000');
140
+ this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, '#000000', {
141
+ summaryColumn,
142
+ summaryMethod: summary_method
143
+ }));
144
+ this.chart.on('interval:mouseleave', evt => this.onLeaveRingChart(evt, '#000000', {
145
+ summaryColumn,
146
+ summaryMethod: summary_method
147
+ }));
148
+ this.chart.render();
149
+ };
150
+ this.getLabel = (value, percent) => {
151
+ const {
152
+ display_label,
153
+ label_format
154
+ } = this.props.chart.config;
155
+ if (!display_label) {
156
+ return '';
157
+ }
158
+ switch (label_format) {
159
+ case CHART_LABEL_FORMATS[0]:
160
+ return percent;
161
+ case CHART_LABEL_FORMATS[1]:
162
+ return value;
163
+ case CHART_LABEL_FORMATS[2]:
164
+ return "".concat(value, " (").concat(percent, ")");
165
+ default:
166
+ return percent;
167
+ }
168
+ };
169
+ this.setAnnotation = function (content, fontColor) {
170
+ let {
171
+ summaryColumn,
172
+ summaryMethod
173
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
174
+ let name = content.name;
175
+ if (!name || name === 'undefined') {
176
+ name = intl.get('Empty');
177
+ } else if (name === '_Others') {
178
+ name = intl.get('Others');
179
+ }
180
+ _this.chart.annotation().text({
181
+ content: name,
182
+ position: ['50%', '50%'],
183
+ style: {
184
+ fontSize: 12,
185
+ fill: fontColor,
186
+ fontWeight: '300',
187
+ textAlign: 'center'
188
+ },
189
+ offsetY: -20
190
+ }).text({
191
+ position: ['50%', '50%'],
192
+ content: summaryColumn ? ChartUtils.getSummaryValueDisplayString(summaryColumn, content.value, summaryMethod) : content.value,
193
+ style: {
194
+ fontSize: 20,
195
+ fill: fontColor,
196
+ textAlign: 'center'
197
+ },
198
+ offsetY: 20
199
+ });
200
+ };
201
+ this.onEnterRingChart = (ev, color, _ref) => {
202
+ let {
203
+ summaryColumn,
204
+ summaryMethod
205
+ } = _ref;
206
+ const item = ev.data.data;
207
+ this.chart.annotation().clear(true);
208
+ this.setAnnotation(item, color, {
209
+ summaryColumn,
210
+ summaryMethod
211
+ });
212
+ this.chart.render(true);
213
+ };
214
+ this.onLeaveRingChart = (ev, color, _ref2) => {
215
+ let {
216
+ summaryColumn,
217
+ summaryMethod
218
+ } = _ref2;
219
+ this.chart.annotation().clear(true);
220
+ this.setAnnotation({
221
+ name: intl.get('Total'),
222
+ value: this.sum
223
+ }, color, {
224
+ summaryColumn,
225
+ summaryMethod
226
+ });
227
+ this.chart.render(true);
228
+ };
229
+ this.sum = 0;
230
+ this.chart = null;
231
+ }
232
+ componentDidMount() {
233
+ this.createChart();
234
+ this.drawChart();
235
+ }
236
+ componentDidUpdate(prevProps) {
237
+ if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
238
+ this.chart && this.destroyChart();
239
+ this.sum = 0;
240
+ this.createChart();
241
+ this.drawChart();
242
+ }
243
+ }
244
+ componentWillUnmount() {
245
+ this.chart && this.destroyChart();
246
+ }
247
+ render() {
248
+ return /*#__PURE__*/React.createElement("div", {
249
+ className: "sea-chart-container w-100",
250
+ ref: ref => this.container = ref
251
+ });
252
+ }
253
+ }
254
+ Ring.propTypes = {
255
+ canvasStyle: PropTypes.object,
256
+ chart: PropTypes.object,
257
+ groupbyColumn: PropTypes.object,
258
+ columnGroupbyColumn: PropTypes.object,
259
+ summaryColumn: PropTypes.object,
260
+ result: PropTypes.array,
261
+ tables: PropTypes.array,
262
+ toggleRecords: PropTypes.func
263
+ };
264
+ export default Ring;
@@ -0,0 +1,103 @@
1
+ .sea-chart-pivot-table {
2
+ width: 100%;
3
+ position: relative;
4
+ }
5
+
6
+ .sea-chart-pivot-table thead {
7
+ border-top: 1px solid #ccc;
8
+ }
9
+
10
+ .sea-chart-pivot-table tr {
11
+ border-bottom: 1px solid #ccc;
12
+ text-align: center;
13
+ }
14
+
15
+ .sea-chart-pivot-table th {
16
+ color: #212529;
17
+ }
18
+
19
+ .sea-chart-pivot-table th,
20
+ .sea-chart-pivot-table td {
21
+ padding: 10px;
22
+ border-right: 1px solid #ccc;
23
+ border-left: 1px solid #ccc;
24
+ border-bottom: none;
25
+ overflow: hidden;
26
+ min-width: 100px;
27
+ width: 150px;
28
+ max-width: 150px;
29
+ font-weight: 400;
30
+ text-overflow: ellipsis;
31
+ white-space: nowrap;
32
+ text-align: center;
33
+ }
34
+
35
+ .sea-chart-pivot-table .column-title,
36
+ .sea-chart-pivot-table .row-title {
37
+ padding: 0;
38
+ text-align: center;
39
+ color: inherit;
40
+ }
41
+
42
+ .sea-chart-pivot-table .column-title {
43
+ caption-side: top;
44
+ }
45
+
46
+ .sea-chart-pivot-table .row-title {
47
+ position: absolute;
48
+ transform: rotate(-90deg);
49
+ width: 100px;
50
+ left: -60px;
51
+ top: 50%;
52
+ overflow: hidden;
53
+ white-space: nowrap;
54
+ text-overflow: ellipsis;
55
+ }
56
+
57
+ .sea-chart-pivot-table .pivot-cell {
58
+ position: relative;
59
+ overflow: hidden;
60
+ }
61
+
62
+ .sea-chart-pivot-table .pivot-cell:hover {
63
+ cursor: pointer;
64
+ }
65
+
66
+ .sea-chart-pivot-table .selected-pivot-cell {
67
+ border-bottom: 1px solid #66afe9;
68
+ border-right: 1px solid #66afe9;
69
+ }
70
+
71
+ .sea-chart-pivot-table .selected-pivot-cell-top {
72
+ border-bottom: 1px solid #66afe9;
73
+ }
74
+
75
+ .sea-chart-pivot-table .selected-pivot-cell-left {
76
+ border-right: 1px solid #66afe9 ;
77
+ }
78
+
79
+ .sea-chart-pivot-table .selected-pivot-cell-border {
80
+ display: inline-block;
81
+ width: 100%;
82
+ height: 100%;
83
+ position: absolute;
84
+ top: 0px;
85
+ left: 0px;
86
+ border: 1px solid #66afe9;
87
+ }
88
+
89
+ .sea-chart-pivot-table .pivot-empty-cell i {
90
+ display: inline-block;
91
+ height: 6px;
92
+ width: 16px;
93
+ border-radius: 6px;
94
+ background: #f1f1f1;
95
+ }
96
+
97
+ .sea-chart-pivot-table td>div {
98
+ white-space: nowrap;
99
+ text-overflow: ellipsis;
100
+ overflow: hidden;
101
+ font-size: 13px;
102
+ max-width: 100%;
103
+ }
@@ -0,0 +1,31 @@
1
+ import React, { PureComponent } from 'react';
2
+ import TwoDimensionTable from './two-dimension-table';
3
+ import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
4
+ import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
5
+ import intl from '../../../intl';
6
+ import './index.css';
7
+ class Table extends PureComponent {
8
+ render() {
9
+ const {
10
+ groupbyColumn,
11
+ columnGroupbyColumn,
12
+ result
13
+ } = this.props;
14
+ const {
15
+ pivot_columns
16
+ } = result;
17
+ if (!groupbyColumn) return '';
18
+ if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
19
+ return /*#__PURE__*/React.createElement("div", null, intl.get('There_are_too_many_statistics_entries_to_display'));
20
+ }
21
+ if (columnGroupbyColumn) {
22
+ return /*#__PURE__*/React.createElement(TwoDimensionTable, this.props);
23
+ }
24
+ if (!Array.isArray(pivot_columns)) return null;
25
+ if (pivot_columns.length < 2) {
26
+ return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, this.props);
27
+ }
28
+ return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, this.props);
29
+ }
30
+ }
31
+ export default Table;
@@ -0,0 +1,144 @@
1
+ import React, { PureComponent } from 'react';
2
+ import classnames from 'classnames';
3
+ import PivotTableDisplayName from './pivot-table-display-name';
4
+ import { ChartUtils, ObjectUtils } from '../../../utils';
5
+ import intl from '../../../intl';
6
+ class OneDimensionTableNoNumericColumns extends PureComponent {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.renderHeader = () => {
10
+ const {
11
+ groupbyColumn,
12
+ selectedCell
13
+ } = this.props;
14
+ const {
15
+ name: groupName
16
+ } = groupbyColumn;
17
+ const {
18
+ rowIdx: selectRowIdx,
19
+ cellIdx: selectedCellIdx
20
+ } = selectedCell || {};
21
+ const isSelectedTotalCellBottom = selectRowIdx === 0 && selectedCellIdx === 0;
22
+ return /*#__PURE__*/React.createElement("thead", {
23
+ className: "seatable-table-header-sm"
24
+ }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
25
+ className: "pivot-table-header"
26
+ }, groupName), /*#__PURE__*/React.createElement("th", {
27
+ className: classnames('pivot-table-header', {
28
+ 'selected-pivot-cell-top': isSelectedTotalCellBottom
29
+ })
30
+ }, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
31
+ };
32
+ this.toggleRecords = (cell, selectedCell) => {
33
+ if (window.isMobile) return;
34
+ const {
35
+ rowIdx: selectedRowIdx,
36
+ cellIdx: selectedCellIdx
37
+ } = this.props.selectedCell || {};
38
+ const {
39
+ rowIdx,
40
+ cellIdx
41
+ } = selectedCell;
42
+ if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
43
+ this.props.toggleRecords(cell, selectedCell);
44
+ };
45
+ this.onClickTotals = (recordsList, selectedCell) => {
46
+ if (window.isMobile) return;
47
+ const rows = recordsList.flat();
48
+ const total = rows.length;
49
+ this.toggleRecords({
50
+ rows,
51
+ total
52
+ }, selectedCell);
53
+ };
54
+ this.renderRows = () => {
55
+ const {
56
+ result,
57
+ groupbyColumn,
58
+ selectedCell,
59
+ summaryColumn
60
+ } = this.props;
61
+ const {
62
+ pivot_rows,
63
+ pivot_columns_total
64
+ } = result;
65
+ const {
66
+ rowIdx: selectRowIdx,
67
+ cellIdx: selectedCellIdx
68
+ } = selectedCell || {};
69
+ const pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
70
+ let pivotColumnCells = [];
71
+ const isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
72
+ const isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
73
+ // eslint-disable-next-line
74
+ const total = ObjectUtils.hasOwnProperty(pivot_columns_total, 'total') ? pivot_columns_total['total'] : 0;
75
+ const summaryDisplayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, total);
76
+ const isValidSummaryDisplayValue = ChartUtils.isValidValue(summaryDisplayValue);
77
+ return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map((rowItem, rowIdx) => {
78
+ const {
79
+ name,
80
+ total,
81
+ rows
82
+ } = rowItem;
83
+ let isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
84
+ // let pivotRowCells = [];
85
+ let isSelectedTotalCell = selectRowIdx === rowIdx && selectedCellIdx === 0;
86
+ let isSelectedTotalCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === 0;
87
+ let isSelectedTotalCellLeft = selectRowIdx === rowIdx && selectedCellIdx === 0;
88
+ pivotColumnCells[rowIdx] = rows;
89
+ const totalDisplayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, total.total);
90
+ const isValidTotalDisplayValue = ChartUtils.isValidValue(totalDisplayValue);
91
+ return /*#__PURE__*/React.createElement("tr", {
92
+ key: 'table-row-' + rowIdx
93
+ }, /*#__PURE__*/React.createElement("td", {
94
+ className: classnames('pivot-row-name', {
95
+ 'selected-pivot-cell-left': isSelectedRowNameRight
96
+ })
97
+ }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
98
+ value: name,
99
+ column: groupbyColumn
100
+ })), /*#__PURE__*/React.createElement("td", {
101
+ className: classnames('pivot-cell', {
102
+ 'pivot-empty-cell': !isValidTotalDisplayValue,
103
+ 'selected-pivot-cell': isSelectedTotalCell,
104
+ 'selected-pivot-cell-top': isSelectedTotalCellTop,
105
+ 'selected-pivot-cell-left': isSelectedTotalCellLeft
106
+ })
107
+ // onClick={() => this.toggleRecords({rows: Array.isArray(rows) && rows.length > 0 ? rows : pivotRowCells, total: total}, {rowIdx, cellIdx: 0})}
108
+ ,
109
+ total: totalDisplayValue
110
+ }, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
111
+ className: classnames({
112
+ 'selected-pivot-cell-border': isSelectedTotalCell
113
+ })
114
+ })));
115
+ }), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
116
+ className: classnames('pivot-column-total', {
117
+ 'selected-pivot-cell-left': isSelectRowTotalCellRight
118
+ })
119
+ }, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), /*#__PURE__*/React.createElement("td", {
120
+ className: classnames('pivot-cell pivot-table-total', {
121
+ 'pivot-empty-cell': !isValidSummaryDisplayValue,
122
+ 'selected-pivot-cell': isSelectTotal
123
+ })
124
+ // onClick={() => this.onClickTotals(pivotColumnCells, {rowIdx: pivot_rows.length, cellIdx: 0})}
125
+ ,
126
+ title: isValidSummaryDisplayValue ? summaryDisplayValue : ''
127
+ }, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
128
+ className: classnames({
129
+ 'selected-pivot-cell-border': isSelectTotal
130
+ })
131
+ }))));
132
+ };
133
+ }
134
+ render() {
135
+ const {
136
+ groupbyColumn
137
+ } = this.props;
138
+ if (!groupbyColumn) return '';
139
+ return /*#__PURE__*/React.createElement("table", {
140
+ className: "sea-chart-pivot-table"
141
+ }, this.renderHeader(), this.renderRows());
142
+ }
143
+ }
144
+ export default OneDimensionTableNoNumericColumns;