sea-chart 0.0.51-alpha.3 → 0.0.51

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.
@@ -10,7 +10,27 @@ 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 {}
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
+ }
14
34
  _BaseUtils = BaseUtils;
15
35
  BaseUtils.isCollaborator = column => {
16
36
  return column.type === CellType.COLLABORATOR;
@@ -247,7 +267,7 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
247
267
  let summaryMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'count';
248
268
  if (!summaryColumn) return summaryValue;
249
269
  if (!summaryValue && summaryValue !== 0) return summaryValue;
250
- if ((summaryMethod === null || summaryMethod === void 0 ? void 0 : summaryMethod.toUpperCase()) === 'DISTINCT_VALUES') return summaryValue;
270
+ if (summaryMethod.toUpperCase() === 'DISTINCT_VALUES') return summaryValue;
251
271
  const {
252
272
  data
253
273
  } = summaryColumn;
@@ -748,23 +768,6 @@ BaseUtils.sortByDate = (currentDate, nextDate) => {
748
768
  if (currentDate.name < nextDate.name) return -1;
749
769
  return 0;
750
770
  };
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
- };
768
771
  BaseUtils.moveNullDataToEnd = arr => {
769
772
  let nullData;
770
773
  const nullDataIndex = arr.findIndex(item => {
@@ -111,7 +111,7 @@ SQLStatisticsUtils.formatedTableSqlRows = (chart, sqlRows, chartSQLMap, columnMa
111
111
  if (config.summary_type === CHART_SUMMARY_TYPE.COUNT) {
112
112
  sqlRows.forEach((item, index) => {
113
113
  const collaborators = item[sqlGroupbyColumnKey];
114
- // Multiple collaborators in the same cell
114
+ // Multiple collaborators
115
115
  if ((collaborators === null || collaborators === void 0 ? void 0 : collaborators.length) > 1) {
116
116
  newSqlRows.splice(index, 1);
117
117
  collaborators.forEach(item => {
@@ -152,7 +152,7 @@ SQLStatisticsUtils.formatedTableSqlRows = (chart, sqlRows, chartSQLMap, columnMa
152
152
  }
153
153
  sqlRows.forEach((item, index) => {
154
154
  const collaborators = item[sqlGroupbyColumnKey];
155
- // Multiple collaborators in the same cell
155
+ // Multiple collaborators
156
156
  if ((collaborators === null || collaborators === void 0 ? void 0 : collaborators.length) > 1) {
157
157
  newSqlRows.splice(index, 1);
158
158
  collaborators.forEach(collaborator => {
@@ -646,40 +646,6 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
646
646
  pivot_table_total, chart);
647
647
  BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
648
648
  BaseUtils.sortCharts(pivot_columns, columnGroupbyColumn, 'key');
649
- console.log('pivot_rows', pivot_rows);
650
- const mergeSameCollaborator = pivot_rows => {
651
- const new_pivot_rows = [];
652
- pivot_rows.forEach(item => {
653
- var _item$name;
654
- // Single Collaborator in cell
655
- if ((item === null || item === void 0 ? void 0 : (_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.length) === 1) {
656
- const curCollaborator = item.name[0];
657
- const length = new_pivot_rows.length;
658
- if (length > 1 && new_pivot_rows[length - 1]) {
659
- var _new_pivot_rows;
660
- const preCollaborator = (_new_pivot_rows = new_pivot_rows[length - 1]) === null || _new_pivot_rows === void 0 ? void 0 : _new_pivot_rows.name[0];
661
- if (curCollaborator === preCollaborator) {
662
- const newItem = {
663
- ...item,
664
- cells: {
665
- ...new_pivot_rows[length - 1].cells,
666
- ...item.cells
667
- },
668
- total: new_pivot_rows[length - 1].total + item.total
669
- };
670
- new_pivot_rows[length - 1] = newItem;
671
- return;
672
- }
673
- }
674
- new_pivot_rows.push({
675
- ...item
676
- });
677
- }
678
- });
679
- console.log('new_pivot_rows', new_pivot_rows);
680
- return new_pivot_rows;
681
- };
682
- pivot_rows = mergeSameCollaborator(pivot_rows);
683
649
  const summary_columns = [summaryColumn, ...summaryColumnsWithMethod.map(item => item.column)];
684
650
  return {
685
651
  summary_columns,
@@ -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 { BaseUtils } from './chart-utils';
6
+ import { ChartUtils } 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
- BaseUtils.sortDataByKey(nameSumMap, 'valueSum', sortType);
464
+ ChartUtils.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,8 +105,7 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
105
105
  })
106
106
  }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
107
107
  value: name,
108
- column: groupbyColumn,
109
- rowData: rowItem
108
+ column: groupbyColumn
110
109
  })), display_total && /*#__PURE__*/React.createElement("td", {
111
110
  className: classnames('pivot-cell', {
112
111
  'pivot-empty-cell': !isValidTotalDisplayValue,
@@ -124,8 +124,7 @@ class OneDimensionTableWithNumericColumns extends PureComponent {
124
124
  })
125
125
  }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
126
126
  value: name,
127
- column: groupbyColumn,
128
- rowData: rowItem
127
+ column: groupbyColumn
129
128
  })), Array.isArray(pivot_columns) && pivot_columns.map((columnMap, cellIdx) => {
130
129
  const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
131
130
  const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
@@ -128,16 +128,7 @@ class PivotTableDisplayName extends React.Component {
128
128
  }
129
129
  case CellType.COLLABORATOR:
130
130
  {
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
- }
131
+ const validValue = Array.isArray(value) && value.length !== 0 ? value : [];
141
132
  const unknowEmails = validValue.filter(email => !getCollaborator(collaborators, email));
142
133
 
143
134
  // if need to query unknowEmails
@@ -78,8 +78,7 @@ 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 || {},
82
- rowData: item
81
+ column: columnGroupbyColumn || {}
83
82
  }));
84
83
  }), display_total && /*#__PURE__*/React.createElement("th", {
85
84
  className: classnames('pivot-table-header', {
@@ -187,8 +186,7 @@ class TwoDimensionTable extends PureComponent {
187
186
  })
188
187
  }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
189
188
  value: name,
190
- column: groupbyColumn,
191
- rowData: rowItem
189
+ column: groupbyColumn
192
190
  })), Array.isArray(cells) && cells.map((c, cellIdx) => {
193
191
  const isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
194
192
  const isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.51-alpha.3",
3
+ "version": "0.0.51",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",