sea-chart 0.0.51 → 0.0.52
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/dist/utils/chart-utils/base-utils.js +19 -22
- package/dist/utils/column-utils.js +2 -2
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +2 -1
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +2 -1
- package/dist/view/wrapper/table/pivot-table-display-name.js +10 -1
- package/dist/view/wrapper/table/two-dimension-table.js +4 -2
- package/package.json +1 -1
|
@@ -10,27 +10,7 @@ import ObjectUtils from '../object-utils';
|
|
|
10
10
|
import intl from '../../intl';
|
|
11
11
|
import context from '../../context';
|
|
12
12
|
import { isValidCollaboratorEmail } from '../collaborator';
|
|
13
|
-
class BaseUtils {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.sortDataByKey = (data, key, sortType) => {
|
|
16
|
-
data.sort((curr, next) => {
|
|
17
|
-
const currentVal = curr[key];
|
|
18
|
-
const nextVal = next[key];
|
|
19
|
-
if (!currentVal && currentVal !== 0) {
|
|
20
|
-
return -1;
|
|
21
|
-
}
|
|
22
|
-
if (!nextVal && nextVal !== 0) {
|
|
23
|
-
return 1;
|
|
24
|
-
}
|
|
25
|
-
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
26
|
-
return currentVal > nextVal ? 1 : -1;
|
|
27
|
-
} else {
|
|
28
|
-
return currentVal > nextVal ? -1 : 1;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
13
|
+
class BaseUtils {}
|
|
34
14
|
_BaseUtils = BaseUtils;
|
|
35
15
|
BaseUtils.isCollaborator = column => {
|
|
36
16
|
return column.type === CellType.COLLABORATOR;
|
|
@@ -267,7 +247,7 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
|
|
|
267
247
|
let summaryMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'count';
|
|
268
248
|
if (!summaryColumn) return summaryValue;
|
|
269
249
|
if (!summaryValue && summaryValue !== 0) return summaryValue;
|
|
270
|
-
if (summaryMethod.toUpperCase() === 'DISTINCT_VALUES') return summaryValue;
|
|
250
|
+
if ((summaryMethod === null || summaryMethod === void 0 ? void 0 : summaryMethod.toUpperCase()) === 'DISTINCT_VALUES') return summaryValue;
|
|
271
251
|
const {
|
|
272
252
|
data
|
|
273
253
|
} = summaryColumn;
|
|
@@ -768,6 +748,23 @@ BaseUtils.sortByDate = (currentDate, nextDate) => {
|
|
|
768
748
|
if (currentDate.name < nextDate.name) return -1;
|
|
769
749
|
return 0;
|
|
770
750
|
};
|
|
751
|
+
BaseUtils.sortDataByKey = (data, key, sortType) => {
|
|
752
|
+
data.sort((curr, next) => {
|
|
753
|
+
const currentVal = curr[key];
|
|
754
|
+
const nextVal = next[key];
|
|
755
|
+
if (!currentVal && currentVal !== 0) {
|
|
756
|
+
return -1;
|
|
757
|
+
}
|
|
758
|
+
if (!nextVal && nextVal !== 0) {
|
|
759
|
+
return 1;
|
|
760
|
+
}
|
|
761
|
+
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
762
|
+
return currentVal > nextVal ? 1 : -1;
|
|
763
|
+
} else {
|
|
764
|
+
return currentVal > nextVal ? -1 : 1;
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
};
|
|
771
768
|
BaseUtils.moveNullDataToEnd = arr => {
|
|
772
769
|
let nullData;
|
|
773
770
|
const nullDataIndex = arr.findIndex(item => {
|
|
@@ -3,7 +3,7 @@ import { COLUMNS_ICON_CONFIG } from 'dtable-utils';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { MIRROR_COLUMN_LIST, CHART_SUMMARY_TYPE } from '../constants';
|
|
5
5
|
import { getClientFormulaDisplayString } from './cell-format-utils';
|
|
6
|
-
import {
|
|
6
|
+
import { BaseUtils } from './chart-utils';
|
|
7
7
|
|
|
8
8
|
// get dtable column options
|
|
9
9
|
export function getColumnOptions(columns) {
|
|
@@ -461,7 +461,7 @@ export const sortDataByGroupSum = (data, sortType) => {
|
|
|
461
461
|
});
|
|
462
462
|
|
|
463
463
|
// sort group
|
|
464
|
-
|
|
464
|
+
BaseUtils.sortDataByKey(nameSumMap, 'valueSum', sortType);
|
|
465
465
|
return nameSumMap.reduce((accumulator, currentItem) => accumulator.concat(currentItem.items), []);
|
|
466
466
|
};
|
|
467
467
|
export const formatNumericValue = function (value) {
|
|
@@ -105,7 +105,8 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
105
105
|
})
|
|
106
106
|
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
107
107
|
value: name,
|
|
108
|
-
column: groupbyColumn
|
|
108
|
+
column: groupbyColumn,
|
|
109
|
+
rowData: rowItem
|
|
109
110
|
})), display_total && /*#__PURE__*/React.createElement("td", {
|
|
110
111
|
className: classnames('pivot-cell', {
|
|
111
112
|
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
@@ -124,7 +124,8 @@ class OneDimensionTableWithNumericColumns extends PureComponent {
|
|
|
124
124
|
})
|
|
125
125
|
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
126
126
|
value: name,
|
|
127
|
-
column: groupbyColumn
|
|
127
|
+
column: groupbyColumn,
|
|
128
|
+
rowData: rowItem
|
|
128
129
|
})), Array.isArray(pivot_columns) && pivot_columns.map((columnMap, cellIdx) => {
|
|
129
130
|
const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
130
131
|
const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|
|
@@ -128,7 +128,16 @@ class PivotTableDisplayName extends React.Component {
|
|
|
128
128
|
}
|
|
129
129
|
case CellType.COLLABORATOR:
|
|
130
130
|
{
|
|
131
|
-
const
|
|
131
|
+
const {
|
|
132
|
+
rowData
|
|
133
|
+
} = this.props;
|
|
134
|
+
const {
|
|
135
|
+
original_name
|
|
136
|
+
} = rowData || {};
|
|
137
|
+
let validValue = Array.isArray(value) && value.length !== 0 ? value : [];
|
|
138
|
+
if (original_name) {
|
|
139
|
+
validValue = [original_name];
|
|
140
|
+
}
|
|
132
141
|
const unknowEmails = validValue.filter(email => !getCollaborator(collaborators, email));
|
|
133
142
|
|
|
134
143
|
// if need to query unknowEmails
|
|
@@ -78,7 +78,8 @@ class TwoDimensionTable extends PureComponent {
|
|
|
78
78
|
key: "pivot-column-".concat(index)
|
|
79
79
|
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
80
80
|
value: original_key,
|
|
81
|
-
column: columnGroupbyColumn || {}
|
|
81
|
+
column: columnGroupbyColumn || {},
|
|
82
|
+
rowData: item
|
|
82
83
|
}));
|
|
83
84
|
}), display_total && /*#__PURE__*/React.createElement("th", {
|
|
84
85
|
className: classnames('pivot-table-header', {
|
|
@@ -186,7 +187,8 @@ class TwoDimensionTable extends PureComponent {
|
|
|
186
187
|
})
|
|
187
188
|
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
188
189
|
value: name,
|
|
189
|
-
column: groupbyColumn
|
|
190
|
+
column: groupbyColumn,
|
|
191
|
+
rowData: rowItem
|
|
190
192
|
})), Array.isArray(cells) && cells.map((c, cellIdx) => {
|
|
191
193
|
const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
192
194
|
const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|