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.
- package/README.md +120 -0
- package/dist/assets/icons/area-chart.svg +10 -0
- package/dist/assets/icons/bar-chart.svg +12 -0
- package/dist/assets/icons/card.svg +22 -0
- package/dist/assets/icons/combination-chart.svg +17 -0
- package/dist/assets/icons/dtable-logo.svg +16 -0
- package/dist/assets/icons/facet-chart.svg +12 -0
- package/dist/assets/icons/gauge.svg +18 -0
- package/dist/assets/icons/heat-map.svg +14 -0
- package/dist/assets/icons/histogram.svg +12 -0
- package/dist/assets/icons/line-chart.svg +12 -0
- package/dist/assets/icons/map.svg +20 -0
- package/dist/assets/icons/pie-chart.svg +11 -0
- package/dist/assets/icons/rectangular-tree-diagram.svg +10 -0
- package/dist/assets/icons/scatter-chart.svg +15 -0
- package/dist/assets/icons/type-change.svg +17 -0
- package/dist/assets/img/area-chart.png +0 -0
- package/dist/assets/img/area-group-chart.png +0 -0
- package/dist/assets/img/bar-group.png +0 -0
- package/dist/assets/img/bar-stack.png +0 -0
- package/dist/assets/img/bar.png +0 -0
- package/dist/assets/img/combination-chart.png +0 -0
- package/dist/assets/img/compared-chart.png +0 -0
- package/dist/assets/img/completeness-chart.png +0 -0
- package/dist/assets/img/custom-bar.png +0 -0
- package/dist/assets/img/dashboard-chart.png +0 -0
- package/dist/assets/img/group-completeness-chart.png +0 -0
- package/dist/assets/img/group_line.png +0 -0
- package/dist/assets/img/heat-map.png +0 -0
- package/dist/assets/img/horizontal-bar.png +0 -0
- package/dist/assets/img/horizontal-group-bar.png +0 -0
- package/dist/assets/img/line.png +0 -0
- package/dist/assets/img/map-bubble.png +0 -0
- package/dist/assets/img/map.png +0 -0
- package/dist/assets/img/mirror.png +0 -0
- package/dist/assets/img/number-card.png +0 -0
- package/dist/assets/img/pie.png +0 -0
- package/dist/assets/img/pivot-table.png +0 -0
- package/dist/assets/img/ring.png +0 -0
- package/dist/assets/img/scatter.png +0 -0
- package/dist/assets/img/stacked-horizontal-bar.png +0 -0
- package/dist/assets/img/treemap.png +0 -0
- package/dist/assets/img/trend-chart.png +0 -0
- package/dist/assets/img/world-map-bubble.png +0 -0
- package/dist/assets/img/world-map.png +0 -0
- package/dist/components/collaborator/index.js +26 -0
- package/dist/components/icon/index.css +5 -0
- package/dist/components/icon/index.js +24 -0
- package/dist/components/index.js +8 -0
- package/dist/components/loading/index.css +54 -0
- package/dist/components/loading/index.js +12 -0
- package/dist/components/number-input/index.js +31 -0
- package/dist/components/pixel-editor/index.css +29 -0
- package/dist/components/pixel-editor/index.js +38 -0
- package/dist/components/select-group/index.css +67 -0
- package/dist/components/select-group/index.js +52 -0
- package/dist/components/types-dialog/index.css +97 -0
- package/dist/components/types-dialog/index.js +116 -0
- package/dist/constants/geolocation.js +11 -0
- package/dist/constants/index.js +184 -0
- package/dist/constants/model.js +187 -0
- package/dist/constants/style.js +15 -0
- package/dist/constants/type-image.js +59 -0
- package/dist/constants/type.js +124 -0
- package/dist/context.js +33 -0
- package/dist/editor/index.css +0 -0
- package/dist/editor/index.js +36 -0
- package/dist/index.js +6 -0
- package/dist/intl.js +37 -0
- package/dist/locale/index.js +18 -0
- package/dist/locale/lang/de.js +141 -0
- package/dist/locale/lang/en.js +143 -0
- package/dist/locale/lang/es.js +141 -0
- package/dist/locale/lang/fr.js +141 -0
- package/dist/locale/lang/pt.js +141 -0
- package/dist/locale/lang/ru.js +141 -0
- package/dist/locale/lang/zh_CN.js +143 -0
- package/dist/model/area-group.js +41 -0
- package/dist/model/area.js +32 -0
- package/dist/model/bar-group.js +44 -0
- package/dist/model/bar-stack.js +41 -0
- package/dist/model/bar.js +38 -0
- package/dist/model/base-model.js +9 -0
- package/dist/model/basic-number-card.js +22 -0
- package/dist/model/chart.js +23 -0
- package/dist/model/combination.js +38 -0
- package/dist/model/compare-bar.js +39 -0
- package/dist/model/completeness-group.js +24 -0
- package/dist/model/completeness.js +18 -0
- package/dist/model/dashboard.js +16 -0
- package/dist/model/generic-model.js +224 -0
- package/dist/model/heat-map.js +23 -0
- package/dist/model/horizontal-bar.js +38 -0
- package/dist/model/horizontal-group-bar.js +43 -0
- package/dist/model/index.js +63 -0
- package/dist/model/line-group.js +44 -0
- package/dist/model/line.js +38 -0
- package/dist/model/map-bubble.js +27 -0
- package/dist/model/map.js +27 -0
- package/dist/model/mirror.js +26 -0
- package/dist/model/pie.js +26 -0
- package/dist/model/ring.js +26 -0
- package/dist/model/scatter.js +19 -0
- package/dist/model/stacked-horizontal-bar.js +32 -0
- package/dist/model/table.js +23 -0
- package/dist/model/tree-map.js +20 -0
- package/dist/model/trend.js +24 -0
- package/dist/model/user.js +15 -0
- package/dist/model/world-map-bubble.js +26 -0
- package/dist/model/world-map.js +26 -0
- package/dist/settings/advance-bar-settings/data-settings.js +143 -0
- package/dist/settings/advance-bar-settings/index.js +3 -0
- package/dist/settings/advance-bar-settings/style-settings.js +161 -0
- package/dist/settings/bar-settings/data-settings.js +162 -0
- package/dist/settings/bar-settings/index.js +3 -0
- package/dist/settings/bar-settings/style-settings.js +179 -0
- package/dist/settings/basic-number-card/data-settings.js +126 -0
- package/dist/settings/basic-number-card/index.js +3 -0
- package/dist/settings/basic-number-card/style-settings.js +42 -0
- package/dist/settings/combination-settings/data-settings.js +279 -0
- package/dist/settings/combination-settings/index.js +3 -0
- package/dist/settings/combination-settings/style-settings.js +174 -0
- package/dist/settings/dashboard-settings/data-settings.js +179 -0
- package/dist/settings/dashboard-settings/index.js +2 -0
- package/dist/settings/data-settings.js +73 -0
- package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
- package/dist/settings/horizontal-bar-settings/index.js +3 -0
- package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
- package/dist/settings/index.css +85 -0
- package/dist/settings/index.js +76 -0
- package/dist/settings/pie-settings/data-settings.js +146 -0
- package/dist/settings/pie-settings/index.js +3 -0
- package/dist/settings/pie-settings/style-settings.js +141 -0
- package/dist/settings/style-settings.js +118 -0
- package/dist/settings/table-settings/data-settings.js +549 -0
- package/dist/settings/table-settings/index.js +2 -0
- package/dist/settings/time-comparison-settings/data-settings.js +172 -0
- package/dist/settings/time-comparison-settings/index.js +3 -0
- package/dist/settings/time-comparison-settings/style-settings.js +213 -0
- package/dist/settings/widgets/basic-summary/index.css +12 -0
- package/dist/settings/widgets/basic-summary/index.js +176 -0
- package/dist/settings/widgets/chart-type/index.css +31 -0
- package/dist/settings/widgets/chart-type/index.js +59 -0
- package/dist/settings/widgets/common-data-settings.js +48 -0
- package/dist/settings/widgets/data-filter/index.css +17 -0
- package/dist/settings/widgets/data-filter/index.js +89 -0
- package/dist/settings/widgets/data-sort.js +44 -0
- package/dist/settings/widgets/date-summary-item.js +111 -0
- package/dist/settings/widgets/display-values-settings/index.css +13 -0
- package/dist/settings/widgets/display-values-settings/index.js +42 -0
- package/dist/settings/widgets/divider/index.css +4 -0
- package/dist/settings/widgets/divider/index.js +12 -0
- package/dist/settings/widgets/font-settings/font-size-settings.js +33 -0
- package/dist/settings/widgets/font-settings/font-weight-settings.js +44 -0
- package/dist/settings/widgets/font-settings/index.js +3 -0
- package/dist/settings/widgets/group-by.js +160 -0
- package/dist/settings/widgets/label-color.js +30 -0
- package/dist/settings/widgets/min-max-setting.js +52 -0
- package/dist/settings/widgets/mininum-slice-percent.js +63 -0
- package/dist/settings/widgets/numeric-summary-item.js +90 -0
- package/dist/settings/widgets/select-table/index.css +0 -0
- package/dist/settings/widgets/select-table/index.js +38 -0
- package/dist/settings/widgets/stack.js +50 -0
- package/dist/settings/widgets/summary-method-setting.js +66 -0
- package/dist/settings/widgets/summary-settings.js +411 -0
- package/dist/settings/widgets/switch/index.css +37 -0
- package/dist/settings/widgets/switch/index.js +24 -0
- package/dist/settings/widgets/text-horizontal-settings.js +25 -0
- package/dist/settings/widgets/time-picker.js +173 -0
- package/dist/settings/widgets/title-settings/index.js +60 -0
- package/dist/settings/widgets/title-settings/title-text.js +25 -0
- package/dist/settings/widgets/x-axios.js +0 -0
- package/dist/settings/widgets/y-axis-group-settings.js +438 -0
- package/dist/utils/cell-format-utils.js +42 -0
- package/dist/utils/chart-data-sql.js +606 -0
- package/dist/utils/chart-utils.js +1800 -0
- package/dist/utils/chart.js +6 -0
- package/dist/utils/collaborator-utils.js +39 -0
- package/dist/utils/column-2-sql-column.js +551 -0
- package/dist/utils/column-utils.js +208 -0
- package/dist/utils/custom-g2.js +612 -0
- package/dist/utils/date-translate.js +66 -0
- package/dist/utils/index.js +48 -0
- package/dist/utils/key-generator.js +13 -0
- package/dist/utils/object-utils.js +45 -0
- package/dist/utils/options-utils.js +60 -0
- package/dist/view/index.css +53 -0
- package/dist/view/index.js +189 -0
- package/dist/view/title/index.css +3 -0
- package/dist/view/title/index.js +46 -0
- package/dist/view/wrapper/area.js +150 -0
- package/dist/view/wrapper/bar-group.js +148 -0
- package/dist/view/wrapper/bar.js +138 -0
- package/dist/view/wrapper/basic-number-card.js +127 -0
- package/dist/view/wrapper/chart-component.js +261 -0
- package/dist/view/wrapper/combination.js +399 -0
- package/dist/view/wrapper/dashboard.js +164 -0
- package/dist/view/wrapper/horizontal-bar-group.js +149 -0
- package/dist/view/wrapper/horizontal-bar.js +140 -0
- package/dist/view/wrapper/horizontal-component.js +78 -0
- package/dist/view/wrapper/index.js +200 -0
- package/dist/view/wrapper/line-group.js +145 -0
- package/dist/view/wrapper/line.js +157 -0
- package/dist/view/wrapper/pie.js +185 -0
- package/dist/view/wrapper/ring.js +264 -0
- package/dist/view/wrapper/table/index.css +103 -0
- package/dist/view/wrapper/table/index.js +31 -0
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
- package/dist/view/wrapper/table/pivot-table-display-name.js +247 -0
- package/dist/view/wrapper/table/two-dimension-table.js +249 -0
- package/dist/view/wrapper/treemap.js +186 -0
- package/package.json +151 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import PivotTableDisplayName from './pivot-table-display-name';
|
|
4
|
+
import { ChartUtils } from '../../../utils';
|
|
5
|
+
import intl from '../../../intl';
|
|
6
|
+
class OneDimensionTableWithNumericColumns extends PureComponent {
|
|
7
|
+
constructor(_props) {
|
|
8
|
+
super(_props);
|
|
9
|
+
this.init = props => {
|
|
10
|
+
const {
|
|
11
|
+
summaryColumns
|
|
12
|
+
} = props;
|
|
13
|
+
this.summaryColumnsMethodMap = {};
|
|
14
|
+
if (Array.isArray(summaryColumns) && summaryColumns.length > 0) {
|
|
15
|
+
summaryColumns.forEach(item => {
|
|
16
|
+
const {
|
|
17
|
+
column_key,
|
|
18
|
+
summary_method
|
|
19
|
+
} = item;
|
|
20
|
+
this.summaryColumnsMethodMap[column_key] = summary_method;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.renderHeader = () => {
|
|
25
|
+
const {
|
|
26
|
+
result,
|
|
27
|
+
groupbyColumn,
|
|
28
|
+
columnGroupbyColumn,
|
|
29
|
+
selectedCell,
|
|
30
|
+
chartTableColumns
|
|
31
|
+
} = this.props;
|
|
32
|
+
const {
|
|
33
|
+
name: groupName
|
|
34
|
+
} = groupbyColumn;
|
|
35
|
+
const {
|
|
36
|
+
name: rowGroupName
|
|
37
|
+
} = columnGroupbyColumn || {};
|
|
38
|
+
const {
|
|
39
|
+
pivot_columns
|
|
40
|
+
} = result;
|
|
41
|
+
const {
|
|
42
|
+
rowIdx: selectRowIdx,
|
|
43
|
+
cellIdx: selectedCellIdx
|
|
44
|
+
} = selectedCell || {};
|
|
45
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
46
|
+
className: "seatable-table-header-sm"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
48
|
+
className: "pivot-table-header"
|
|
49
|
+
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map((item, index) => {
|
|
50
|
+
const {
|
|
51
|
+
key
|
|
52
|
+
} = item;
|
|
53
|
+
const column = chartTableColumns.find(column => column.key === key);
|
|
54
|
+
const isSelectedHeaderBottom = selectRowIdx === 0 && selectedCellIdx === index;
|
|
55
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
56
|
+
className: classnames('pivot-table-header', {
|
|
57
|
+
'selected-pivot-cell-top': isSelectedHeaderBottom
|
|
58
|
+
}),
|
|
59
|
+
key: "pivot-column-".concat(index)
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", null, column.name));
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
63
|
+
this.toggleRecords = (cell, selectedCell) => {
|
|
64
|
+
if (window.isMobile) return;
|
|
65
|
+
const {
|
|
66
|
+
rowIdx: selectedRowIdx,
|
|
67
|
+
cellIdx: selectedCellIdx
|
|
68
|
+
} = this.props.selectedCell || {};
|
|
69
|
+
const {
|
|
70
|
+
rowIdx,
|
|
71
|
+
cellIdx
|
|
72
|
+
} = selectedCell;
|
|
73
|
+
if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
|
|
74
|
+
this.props.toggleRecords(cell, selectedCell);
|
|
75
|
+
};
|
|
76
|
+
this.onClickTotals = (recordsList, selectedCell) => {
|
|
77
|
+
if (window.isMobile) return;
|
|
78
|
+
const rows = recordsList.flat();
|
|
79
|
+
const total = rows.length;
|
|
80
|
+
this.toggleRecords({
|
|
81
|
+
rows,
|
|
82
|
+
total
|
|
83
|
+
}, selectedCell);
|
|
84
|
+
};
|
|
85
|
+
this.renderRows = () => {
|
|
86
|
+
const {
|
|
87
|
+
result,
|
|
88
|
+
groupbyColumn,
|
|
89
|
+
selectedCell,
|
|
90
|
+
chartTableColumns
|
|
91
|
+
} = this.props;
|
|
92
|
+
const {
|
|
93
|
+
pivot_rows,
|
|
94
|
+
pivot_columns,
|
|
95
|
+
pivot_columns_total
|
|
96
|
+
} = result;
|
|
97
|
+
const {
|
|
98
|
+
rowIdx: selectRowIdx,
|
|
99
|
+
cellIdx: selectedCellIdx
|
|
100
|
+
} = selectedCell || {};
|
|
101
|
+
const pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
|
|
102
|
+
let pivotColumnCells = [];
|
|
103
|
+
const isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
104
|
+
return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map((rowItem, rowIdx) => {
|
|
105
|
+
const {
|
|
106
|
+
name,
|
|
107
|
+
total,
|
|
108
|
+
rows
|
|
109
|
+
} = rowItem;
|
|
110
|
+
const isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
111
|
+
if (!Array.isArray(pivot_columns)) {
|
|
112
|
+
pivotColumnCells[rowIdx] = rowItem.rows || [];
|
|
113
|
+
}
|
|
114
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
115
|
+
key: 'table-row' + rowIdx
|
|
116
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
117
|
+
className: classnames('pivot-row-name', {
|
|
118
|
+
'selected-pivot-cell-left': isSelectedRowNameRight
|
|
119
|
+
})
|
|
120
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
121
|
+
value: name,
|
|
122
|
+
column: groupbyColumn
|
|
123
|
+
})), Array.isArray(pivot_columns) && pivot_columns.map((columnMap, cellIdx) => {
|
|
124
|
+
const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
125
|
+
const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|
|
126
|
+
const isSelectedCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cellIdx;
|
|
127
|
+
const {
|
|
128
|
+
key
|
|
129
|
+
} = columnMap;
|
|
130
|
+
const column = chartTableColumns.find(item => item.key === key);
|
|
131
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(column, total[key], this.summaryColumnsMethodMap[key]);
|
|
132
|
+
const isValidDisplayValue = ChartUtils.isValidValue(displayValue);
|
|
133
|
+
if (Array.isArray(rows) && rows.length > 0) {
|
|
134
|
+
if (pivotColumnCells[cellIdx]) {
|
|
135
|
+
pivotColumnCells[cellIdx].push(...rows);
|
|
136
|
+
} else {
|
|
137
|
+
pivotColumnCells[cellIdx] = [...rows];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
141
|
+
className: classnames('pivot-cell', {
|
|
142
|
+
'pivot-empty-cell': !isValidDisplayValue,
|
|
143
|
+
'selected-pivot-cell': isSelectedCell,
|
|
144
|
+
'selected-pivot-cell-top': isSelectedCellTop,
|
|
145
|
+
'selected-pivot-cell-left': isSelectedCellLeft
|
|
146
|
+
}),
|
|
147
|
+
key: "table-cell-".concat(cellIdx)
|
|
148
|
+
// onClick={() => this.toggleRecords({rows, total: total[key]}, {rowIdx, cellIdx})}
|
|
149
|
+
,
|
|
150
|
+
title: isValidDisplayValue ? displayValue : ''
|
|
151
|
+
}, isValidDisplayValue ? displayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
152
|
+
className: classnames({
|
|
153
|
+
'selected-pivot-cell-border': isSelectedCell
|
|
154
|
+
})
|
|
155
|
+
}));
|
|
156
|
+
}));
|
|
157
|
+
}), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
158
|
+
className: classnames('pivot-column-total', {
|
|
159
|
+
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
160
|
+
})
|
|
161
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), Array.isArray(pivot_columns) && pivot_columns.map((c, index) => {
|
|
162
|
+
// const pivotColumnCell = pivotColumnCells[index];
|
|
163
|
+
const pivotColumnTotal = pivot_columns_total[c.key];
|
|
164
|
+
const column = chartTableColumns.find(column => column.key === c.key);
|
|
165
|
+
const totalDisplayValue = ChartUtils.getSummaryValueDisplayString(column, pivotColumnTotal, this.summaryColumnsMethodMap[c.key]);
|
|
166
|
+
const isValidTotalDisplayValue = ChartUtils.isValidValue(totalDisplayValue);
|
|
167
|
+
const isSelectRowTotalCell = selectRowIdx === pivot_rows.length && selectedCellIdx === index;
|
|
168
|
+
const isSelectRowTotalCellLeft = selectRowIdx === pivot_rows.length && selectedCellIdx - 1 === index;
|
|
169
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
170
|
+
className: classnames('pivot-cell', {
|
|
171
|
+
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
172
|
+
'selected-pivot-cell': isSelectRowTotalCell,
|
|
173
|
+
'selected-pivot-cell-left': isSelectRowTotalCellLeft
|
|
174
|
+
}),
|
|
175
|
+
key: "total-cell-".concat(index)
|
|
176
|
+
// onClick={() => this.toggleRecords({ rows: pivotColumnCell, total: pivot_columns_total[c.key] }, {rowIdx: pivot_rows.length, cellIdx: index})}
|
|
177
|
+
,
|
|
178
|
+
title: totalDisplayValue
|
|
179
|
+
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
180
|
+
className: classnames({
|
|
181
|
+
'selected-pivot-cell-border': isSelectRowTotalCell
|
|
182
|
+
})
|
|
183
|
+
}));
|
|
184
|
+
})));
|
|
185
|
+
};
|
|
186
|
+
this.init(_props);
|
|
187
|
+
}
|
|
188
|
+
render() {
|
|
189
|
+
const {
|
|
190
|
+
groupbyColumn
|
|
191
|
+
} = this.props;
|
|
192
|
+
if (!groupbyColumn) return '';
|
|
193
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
194
|
+
className: "sea-chart-pivot-table"
|
|
195
|
+
}, this.renderHeader(), this.renderRows());
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export default OneDimensionTableWithNumericColumns;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import shallowEqual from 'shallowequal';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE, getOption, getCollaborator, getNumberDisplayString, isNumber } from 'dtable-utils';
|
|
5
|
+
import { getClientFormulaDisplayString, getKnownCollaboratorByEmail, getColumnOptions, getDateColumnFormat, generateDefaultUser } from '../../../utils';
|
|
6
|
+
import { Collaborator } from '../../../components';
|
|
7
|
+
import intl from '../../../intl';
|
|
8
|
+
class PivotTableDisplayName extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.updateCreator = email => {
|
|
12
|
+
let creator = getKnownCollaboratorByEmail(email);
|
|
13
|
+
if (creator) {
|
|
14
|
+
this.setState({
|
|
15
|
+
creator
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (creator && creator.loaded) {
|
|
20
|
+
this.setState({
|
|
21
|
+
creator
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!creator) {
|
|
26
|
+
const valueTemplate = {
|
|
27
|
+
loaded: false,
|
|
28
|
+
email: email,
|
|
29
|
+
name: email
|
|
30
|
+
};
|
|
31
|
+
window.seaChart.context.updateCollaboratorsCache(email, valueTemplate);
|
|
32
|
+
window.seaChart.queryUsers([email], emailUserMap => {
|
|
33
|
+
creator = emailUserMap && emailUserMap[email] || generateDefaultUser(email);
|
|
34
|
+
const loadedCreator = {
|
|
35
|
+
...creator,
|
|
36
|
+
loaded: true
|
|
37
|
+
};
|
|
38
|
+
window.seaChart.context.updateCollaboratorsCache(email, loadedCreator);
|
|
39
|
+
this.setState({
|
|
40
|
+
creator
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.renderSelectOption = option => {
|
|
46
|
+
if (!option) return null;
|
|
47
|
+
const {
|
|
48
|
+
name: optionName,
|
|
49
|
+
color,
|
|
50
|
+
textColor
|
|
51
|
+
} = option;
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
style: {
|
|
54
|
+
color: textColor,
|
|
55
|
+
backgroundColor: color
|
|
56
|
+
},
|
|
57
|
+
className: "multiple-select-option d-inline-block align-middle mw-100",
|
|
58
|
+
title: optionName,
|
|
59
|
+
"aria-label": optionName
|
|
60
|
+
}, optionName);
|
|
61
|
+
};
|
|
62
|
+
this.renderCollaborator = collaborator => {
|
|
63
|
+
if (!collaborator) return null;
|
|
64
|
+
const {
|
|
65
|
+
avatar_url,
|
|
66
|
+
name
|
|
67
|
+
} = collaborator;
|
|
68
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: "collaborators-formatter"
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "collaborator"
|
|
72
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
73
|
+
className: "collaborator-avatar-container"
|
|
74
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
75
|
+
src: avatar_url,
|
|
76
|
+
alt: '',
|
|
77
|
+
className: "collaborator-avatar"
|
|
78
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
79
|
+
className: "collaborator-name",
|
|
80
|
+
title: name,
|
|
81
|
+
"aria-label": name
|
|
82
|
+
}, name)));
|
|
83
|
+
};
|
|
84
|
+
this.getDisplayName = (value, column) => {
|
|
85
|
+
let {
|
|
86
|
+
type,
|
|
87
|
+
data
|
|
88
|
+
} = column;
|
|
89
|
+
const collaborators = window.seaChart.context.getCollaboratorsFromCache();
|
|
90
|
+
let displayName;
|
|
91
|
+
switch (type) {
|
|
92
|
+
case CellType.SINGLE_SELECT:
|
|
93
|
+
{
|
|
94
|
+
const options = getColumnOptions(column);
|
|
95
|
+
const option = getOption(options, value) || {};
|
|
96
|
+
displayName = /*#__PURE__*/React.createElement(React.Fragment, null, this.renderSelectOption(option));
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case CellType.MULTIPLE_SELECT:
|
|
100
|
+
{
|
|
101
|
+
const options = getColumnOptions(column);
|
|
102
|
+
const validValue = Array.isArray(value) && value.length !== 0 ? value : [];
|
|
103
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: "pivot-table-display-name-row"
|
|
105
|
+
}, validValue.map(item => {
|
|
106
|
+
const option = getOption(options, item);
|
|
107
|
+
if (!item) return null;
|
|
108
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
109
|
+
key: item
|
|
110
|
+
}, this.renderSelectOption(option));
|
|
111
|
+
}));
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case CellType.COLLABORATOR:
|
|
115
|
+
{
|
|
116
|
+
const validValue = Array.isArray(value) && value.length !== 0 ? value : [];
|
|
117
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: "pivot-table-display-name-row"
|
|
119
|
+
}, validValue.map(item => {
|
|
120
|
+
const collaborator = getCollaborator(collaborators, item);
|
|
121
|
+
if (!item) return null;
|
|
122
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
123
|
+
key: item
|
|
124
|
+
}, this.renderCollaborator(collaborator));
|
|
125
|
+
}));
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case CellType.CREATOR:
|
|
129
|
+
case CellType.LAST_MODIFIER:
|
|
130
|
+
{
|
|
131
|
+
let {
|
|
132
|
+
creator
|
|
133
|
+
} = this.state;
|
|
134
|
+
displayName = /*#__PURE__*/React.createElement(Collaborator, {
|
|
135
|
+
collaborator: creator
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
case CellType.NUMBER:
|
|
140
|
+
{
|
|
141
|
+
let valueNumber = parseFloat(value);
|
|
142
|
+
let displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
143
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
144
|
+
title: displayValue,
|
|
145
|
+
"aria-label": displayValue
|
|
146
|
+
}, displayValue);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case CellType.DATE:
|
|
150
|
+
{
|
|
151
|
+
let displayValue = value + '';
|
|
152
|
+
if (displayValue && displayValue.split('-').length === 3) {
|
|
153
|
+
let format = getDateColumnFormat(column);
|
|
154
|
+
let spaceIndex = format.indexOf(' ');
|
|
155
|
+
if (spaceIndex > -1) {
|
|
156
|
+
format = format.slice(0, spaceIndex);
|
|
157
|
+
}
|
|
158
|
+
displayValue = dayjs(displayValue).format(format);
|
|
159
|
+
}
|
|
160
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
title: displayValue,
|
|
162
|
+
"aria-label": displayValue
|
|
163
|
+
}, displayValue);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case CellType.LINK:
|
|
167
|
+
{
|
|
168
|
+
const displayValue = getClientFormulaDisplayString([value], data, {
|
|
169
|
+
collaborators
|
|
170
|
+
}) || null;
|
|
171
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
title: displayValue,
|
|
173
|
+
"aria-label": displayValue
|
|
174
|
+
}, displayValue);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case CellType.FORMULA:
|
|
178
|
+
case CellType.LINK_FORMULA:
|
|
179
|
+
{
|
|
180
|
+
let displayValue = value;
|
|
181
|
+
let {
|
|
182
|
+
result_type,
|
|
183
|
+
array_type
|
|
184
|
+
} = data || {};
|
|
185
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
186
|
+
let valueNumber = parseFloat(value);
|
|
187
|
+
displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
188
|
+
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
189
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(value)) {
|
|
190
|
+
displayValue = value.map(email => {
|
|
191
|
+
let user = array_type === CellType.COLLABORATOR ? getCollaborator(collaborators, email) : getKnownCollaboratorByEmail(email);
|
|
192
|
+
return (user || {}).name;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
title: displayValue,
|
|
198
|
+
"aria-label": displayValue
|
|
199
|
+
}, displayValue);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
{
|
|
204
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
205
|
+
title: String(value),
|
|
206
|
+
"aria-label": String(value)
|
|
207
|
+
}, value);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return displayName;
|
|
212
|
+
};
|
|
213
|
+
this.state = {
|
|
214
|
+
creator: {}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
componentDidMount() {
|
|
218
|
+
let {
|
|
219
|
+
column,
|
|
220
|
+
value
|
|
221
|
+
} = this.props;
|
|
222
|
+
if (column.type !== CellType.CREATOR && column.type !== CellType.LAST_MODIFIER) return;
|
|
223
|
+
this.updateCreator(value);
|
|
224
|
+
}
|
|
225
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
226
|
+
let {
|
|
227
|
+
column,
|
|
228
|
+
value
|
|
229
|
+
} = nextProps;
|
|
230
|
+
let {
|
|
231
|
+
type
|
|
232
|
+
} = column;
|
|
233
|
+
if (type !== CellType.CREATOR && type !== CellType.LAST_MODIFIER) return;
|
|
234
|
+
if (value !== this.props.value || shallowEqual(nextProps.column, this.props.column)) {
|
|
235
|
+
this.updateCreator(value);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
render() {
|
|
239
|
+
let {
|
|
240
|
+
value,
|
|
241
|
+
column
|
|
242
|
+
} = this.props;
|
|
243
|
+
let displayName = value ? this.getDisplayName(value, column) : /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get('Empty'), ")"));
|
|
244
|
+
return /*#__PURE__*/React.createElement(Fragment, null, displayName);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
export default PivotTableDisplayName;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import PivotTableDisplayName from './pivot-table-display-name';
|
|
4
|
+
import { ChartUtils } from '../../../utils';
|
|
5
|
+
import intl from '../../../intl';
|
|
6
|
+
class TwoDimensionTable extends PureComponent {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.getCells = row => {
|
|
10
|
+
const {
|
|
11
|
+
result,
|
|
12
|
+
summaryColumn
|
|
13
|
+
} = this.props;
|
|
14
|
+
const {
|
|
15
|
+
pivot_columns
|
|
16
|
+
} = result;
|
|
17
|
+
const {
|
|
18
|
+
cells
|
|
19
|
+
} = row;
|
|
20
|
+
if (!Array.isArray(pivot_columns)) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return pivot_columns.map(item => {
|
|
24
|
+
return {
|
|
25
|
+
...cells[item.key],
|
|
26
|
+
column: summaryColumn
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
this.renderHeader = () => {
|
|
31
|
+
const {
|
|
32
|
+
result,
|
|
33
|
+
groupbyColumn,
|
|
34
|
+
columnGroupbyColumn,
|
|
35
|
+
selectedCell
|
|
36
|
+
} = this.props;
|
|
37
|
+
const {
|
|
38
|
+
name: groupName
|
|
39
|
+
} = groupbyColumn;
|
|
40
|
+
const {
|
|
41
|
+
name: rowGroupName
|
|
42
|
+
} = columnGroupbyColumn || {};
|
|
43
|
+
const {
|
|
44
|
+
pivot_columns
|
|
45
|
+
} = result;
|
|
46
|
+
const {
|
|
47
|
+
rowIdx: selectRowIdx,
|
|
48
|
+
cellIdx: selectedCellIdx
|
|
49
|
+
} = selectedCell || {};
|
|
50
|
+
const isSelectedTotalCellBottom = selectRowIdx === 0 && selectedCellIdx === (Array.isArray(pivot_columns) ? pivot_columns.length : 0);
|
|
51
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
52
|
+
className: "seatable-table-header-sm"
|
|
53
|
+
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
54
|
+
className: "pivot-table-header"
|
|
55
|
+
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map((item, index) => {
|
|
56
|
+
let {
|
|
57
|
+
key
|
|
58
|
+
} = item;
|
|
59
|
+
let isSelectedHeaderBottom = selectRowIdx === 0 && selectedCellIdx === index;
|
|
60
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
61
|
+
className: classnames('pivot-table-header', {
|
|
62
|
+
'selected-pivot-cell-top': isSelectedHeaderBottom
|
|
63
|
+
}),
|
|
64
|
+
key: "pivot-column-".concat(index)
|
|
65
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
66
|
+
value: key,
|
|
67
|
+
column: columnGroupbyColumn || {}
|
|
68
|
+
}));
|
|
69
|
+
}), /*#__PURE__*/React.createElement("th", {
|
|
70
|
+
className: classnames('pivot-table-header', {
|
|
71
|
+
'selected-pivot-cell-top': isSelectedTotalCellBottom
|
|
72
|
+
})
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
|
|
74
|
+
};
|
|
75
|
+
this.toggleRecords = (cell, selectedCell) => {
|
|
76
|
+
if (window.isMobile) return;
|
|
77
|
+
const {
|
|
78
|
+
rowIdx: selectedRowIdx,
|
|
79
|
+
cellIdx: selectedCellIdx
|
|
80
|
+
} = this.props.selectedCell || {};
|
|
81
|
+
const {
|
|
82
|
+
rowIdx,
|
|
83
|
+
cellIdx
|
|
84
|
+
} = selectedCell;
|
|
85
|
+
if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
|
|
86
|
+
this.props.toggleRecords(cell, selectedCell);
|
|
87
|
+
};
|
|
88
|
+
this.onClickTotals = (recordsList, selectedCell) => {
|
|
89
|
+
if (window.isMobile) return;
|
|
90
|
+
const rows = recordsList.flat();
|
|
91
|
+
const total = rows.length;
|
|
92
|
+
this.toggleRecords({
|
|
93
|
+
rows,
|
|
94
|
+
total
|
|
95
|
+
}, selectedCell);
|
|
96
|
+
};
|
|
97
|
+
this.renderRows = () => {
|
|
98
|
+
const {
|
|
99
|
+
result,
|
|
100
|
+
groupbyColumn,
|
|
101
|
+
selectedCell,
|
|
102
|
+
summaryColumn,
|
|
103
|
+
summaryMethod
|
|
104
|
+
} = this.props;
|
|
105
|
+
const {
|
|
106
|
+
pivot_rows,
|
|
107
|
+
pivot_columns,
|
|
108
|
+
pivot_columns_total,
|
|
109
|
+
pivot_table_total
|
|
110
|
+
} = result;
|
|
111
|
+
const {
|
|
112
|
+
rowIdx: selectRowIdx,
|
|
113
|
+
cellIdx: selectedCellIdx
|
|
114
|
+
} = selectedCell || {};
|
|
115
|
+
const pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
|
|
116
|
+
let pivotColumnCells = [];
|
|
117
|
+
const isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
118
|
+
const isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === (Array.isArray(pivot_columns) ? pivot_columns.length : 0);
|
|
119
|
+
const tableTotalDisplayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, pivot_table_total, summaryMethod);
|
|
120
|
+
const isValidTableTotalDisplayValue = ChartUtils.isValidValue(tableTotalDisplayValue);
|
|
121
|
+
return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map((rowItem, rowIdx) => {
|
|
122
|
+
const {
|
|
123
|
+
name,
|
|
124
|
+
total
|
|
125
|
+
} = rowItem;
|
|
126
|
+
const cells = this.getCells(rowItem);
|
|
127
|
+
const isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
128
|
+
let pivotRowCells = [];
|
|
129
|
+
const isSelectedTotalCell = selectRowIdx === rowIdx && selectedCellIdx === cells.length;
|
|
130
|
+
const isSelectedTotalCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cells.length;
|
|
131
|
+
const isSelectedTotalCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cells.length - 1;
|
|
132
|
+
if (!Array.isArray(pivot_columns)) {
|
|
133
|
+
pivotColumnCells[rowIdx] = rowItem.rows || [];
|
|
134
|
+
}
|
|
135
|
+
const summaryDisplayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, total, summaryMethod);
|
|
136
|
+
const isValidSummaryDisplayValue = ChartUtils.isValidValue(summaryDisplayValue);
|
|
137
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
138
|
+
key: 'table-row' + rowIdx
|
|
139
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
140
|
+
className: classnames('pivot-row-name', {
|
|
141
|
+
'selected-pivot-cell-left': isSelectedRowNameRight
|
|
142
|
+
})
|
|
143
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
144
|
+
value: name,
|
|
145
|
+
column: groupbyColumn
|
|
146
|
+
})), Array.isArray(cells) && cells.map((c, cellIdx) => {
|
|
147
|
+
const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
148
|
+
const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|
|
149
|
+
const isSelectedCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cellIdx;
|
|
150
|
+
const {
|
|
151
|
+
column,
|
|
152
|
+
total
|
|
153
|
+
} = c;
|
|
154
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(column, total, summaryMethod);
|
|
155
|
+
const isValidDisplayValue = ChartUtils.isValidValue(displayValue);
|
|
156
|
+
if (c && Array.isArray(c.rows) && c.rows.length > 0) {
|
|
157
|
+
pivotRowCells.push(...c.rows);
|
|
158
|
+
if (pivotColumnCells[cellIdx]) {
|
|
159
|
+
pivotColumnCells[cellIdx].push(...c.rows);
|
|
160
|
+
} else {
|
|
161
|
+
pivotColumnCells[cellIdx] = [...c.rows];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
165
|
+
className: classnames('pivot-cell', {
|
|
166
|
+
'pivot-empty-cell': !isValidDisplayValue,
|
|
167
|
+
'selected-pivot-cell': isSelectedCell,
|
|
168
|
+
'selected-pivot-cell-top': isSelectedCellTop,
|
|
169
|
+
'selected-pivot-cell-left': isSelectedCellLeft
|
|
170
|
+
}),
|
|
171
|
+
key: "table-cell-".concat(cellIdx)
|
|
172
|
+
// onClick={() => this.toggleRecords(c, {rowIdx, cellIdx})}
|
|
173
|
+
,
|
|
174
|
+
title: displayValue
|
|
175
|
+
}, isValidDisplayValue ? displayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
176
|
+
className: classnames({
|
|
177
|
+
'selected-pivot-cell-border': isSelectedCell
|
|
178
|
+
})
|
|
179
|
+
}));
|
|
180
|
+
}), /*#__PURE__*/React.createElement("td", {
|
|
181
|
+
className: classnames('pivot-cell', {
|
|
182
|
+
'pivot-empty-cell': !isValidSummaryDisplayValue,
|
|
183
|
+
'selected-pivot-cell': isSelectedTotalCell,
|
|
184
|
+
'selected-pivot-cell-top': isSelectedTotalCellTop,
|
|
185
|
+
'selected-pivot-cell-left': isSelectedTotalCellLeft
|
|
186
|
+
})
|
|
187
|
+
// onClick={() => this.toggleRecords({ rows: Array.isArray(cells) && cells.length > 0 ? pivotRowCells : rowItem.rows, total: total }, { rowIdx, cellIdx: cells.length })}
|
|
188
|
+
,
|
|
189
|
+
title: summaryDisplayValue
|
|
190
|
+
}, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
191
|
+
className: classnames({
|
|
192
|
+
'selected-pivot-cell-border': isSelectedTotalCell
|
|
193
|
+
})
|
|
194
|
+
})));
|
|
195
|
+
}), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
196
|
+
className: classnames('pivot-column-total', {
|
|
197
|
+
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
198
|
+
})
|
|
199
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), Array.isArray(pivot_columns) && pivot_columns.map((c, index) => {
|
|
200
|
+
// const pivotColumnCell = pivotColumnCells[index];
|
|
201
|
+
const isSelectRowTotalCell = selectRowIdx === pivot_rows.length && selectedCellIdx === index;
|
|
202
|
+
const isSelectRowTotalCellLeft = selectRowIdx === pivot_rows.length && selectedCellIdx - 1 === index;
|
|
203
|
+
const pivotColumnTotal = pivot_columns_total[c.key];
|
|
204
|
+
const totalDisplayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, pivotColumnTotal, summaryMethod);
|
|
205
|
+
const isValidTotalDisplayValue = ChartUtils.isValidValue(totalDisplayValue);
|
|
206
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
207
|
+
className: classnames('pivot-cell', {
|
|
208
|
+
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
209
|
+
'selected-pivot-cell': isSelectRowTotalCell,
|
|
210
|
+
'selected-pivot-cell-left': isSelectRowTotalCellLeft
|
|
211
|
+
}),
|
|
212
|
+
key: "total-cell-".concat(index)
|
|
213
|
+
// onClick={() => this.toggleRecords({ rows: pivotColumnCell, total: pivot_columns_total[c.key] }, { rowIdx: pivot_rows.length, cellIdx: index })}
|
|
214
|
+
,
|
|
215
|
+
title: totalDisplayValue
|
|
216
|
+
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
217
|
+
className: classnames({
|
|
218
|
+
'selected-pivot-cell-border': isSelectRowTotalCell
|
|
219
|
+
})
|
|
220
|
+
}));
|
|
221
|
+
}), /*#__PURE__*/React.createElement("td", {
|
|
222
|
+
className: classnames('pivot-cell pivot-table-total', {
|
|
223
|
+
'pivot-empty-cell': !isValidTableTotalDisplayValue,
|
|
224
|
+
'selected-pivot-cell': isSelectTotal
|
|
225
|
+
})
|
|
226
|
+
// onClick={() => this.onClickTotals(pivotColumnCells, {rowIdx: pivot_rows.length, cellIdx: Array.isArray(pivot_columns) ? pivot_columns.length : 0})}
|
|
227
|
+
}, isValidTableTotalDisplayValue ? tableTotalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
228
|
+
className: classnames({
|
|
229
|
+
'selected-pivot-cell-border': isSelectTotal
|
|
230
|
+
})
|
|
231
|
+
}))));
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
render() {
|
|
235
|
+
const {
|
|
236
|
+
groupbyColumn,
|
|
237
|
+
columnGroupbyColumn
|
|
238
|
+
} = this.props;
|
|
239
|
+
if (!groupbyColumn) return '';
|
|
240
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
241
|
+
className: "sea-chart-pivot-table"
|
|
242
|
+
}, /*#__PURE__*/React.createElement("caption", {
|
|
243
|
+
className: "column-title"
|
|
244
|
+
}, columnGroupbyColumn.name), /*#__PURE__*/React.createElement("caption", {
|
|
245
|
+
className: "row-title"
|
|
246
|
+
}, groupbyColumn.name), this.renderHeader(), this.renderRows());
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
export default TwoDimensionTable;
|