dtable-statistic 5.3.32 → 5.3.33-alpha.1
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/es/stat-list/index.js +2 -1
- package/es/utils/export-table-utils.js +27 -34
- package/package.json +3 -2
package/es/stat-list/index.js
CHANGED
|
@@ -75,7 +75,8 @@ class StatList extends _react.Component {
|
|
|
75
75
|
columns,
|
|
76
76
|
rows
|
|
77
77
|
} = (0, _exportTableUtils.exportStatisticToTable)({
|
|
78
|
-
statisticalResult: this.statisticalResult4Export
|
|
78
|
+
statisticalResult: this.statisticalResult4Export,
|
|
79
|
+
chart
|
|
79
80
|
});
|
|
80
81
|
if (window.app && window.app.onExportStatisticToTable) {
|
|
81
82
|
window.app.onExportStatisticToTable({
|
|
@@ -10,7 +10,6 @@ var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal")
|
|
|
10
10
|
var _dtableUtils = require("dtable-utils");
|
|
11
11
|
var _cellValue = require("./cell-value");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
-
var _pivotTable = require("./pivot-table");
|
|
14
13
|
const isEmptyName = title => {
|
|
15
14
|
return title === null || title === '';
|
|
16
15
|
};
|
|
@@ -403,14 +402,11 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
403
402
|
const {
|
|
404
403
|
pivot_rows,
|
|
405
404
|
pivot_columns,
|
|
406
|
-
|
|
407
|
-
formulaRows,
|
|
408
|
-
isSqlQuery
|
|
405
|
+
summary_columns
|
|
409
406
|
} = pivotResult;
|
|
410
|
-
|
|
411
|
-
if (!groupbyColumn || summaryColumns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
|
|
407
|
+
if (!groupbyColumn || summary_columns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
|
|
412
408
|
const groupbyColumnName = groupbyColumn.name;
|
|
413
|
-
const firstSummaryColumn =
|
|
409
|
+
const firstSummaryColumn = summary_columns[0];
|
|
414
410
|
let columns = [{
|
|
415
411
|
// name column
|
|
416
412
|
key: '0000',
|
|
@@ -425,16 +421,12 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
425
421
|
original_key
|
|
426
422
|
} = pivotColumn;
|
|
427
423
|
const pivotColumnColumnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : pivotColumnKey;
|
|
428
|
-
|
|
424
|
+
summary_columns.forEach(summaryColumn => {
|
|
429
425
|
const {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
sqlKey,
|
|
433
|
-
column_name,
|
|
434
|
-
data,
|
|
435
|
-
method
|
|
426
|
+
name,
|
|
427
|
+
data
|
|
436
428
|
} = summaryColumn;
|
|
437
|
-
const newColumnName = `${
|
|
429
|
+
const newColumnName = `${name}(${pivotColumnColumnName})`;
|
|
438
430
|
columns.push({
|
|
439
431
|
// just support number column
|
|
440
432
|
type: _dtableUtils.CellType.NUMBER,
|
|
@@ -443,11 +435,8 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
443
435
|
});
|
|
444
436
|
tmpColumns.push({
|
|
445
437
|
name: newColumnName,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
type,
|
|
449
|
-
sqlKey,
|
|
450
|
-
method
|
|
438
|
+
summaryName: name,
|
|
439
|
+
pivotColumnKey
|
|
451
440
|
});
|
|
452
441
|
});
|
|
453
442
|
});
|
|
@@ -472,22 +461,25 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
|
|
|
472
461
|
let total = 0;
|
|
473
462
|
tmpColumns.forEach(tmpColumn => {
|
|
474
463
|
const {
|
|
475
|
-
name,
|
|
476
464
|
pivotColumnKey,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
sqlKey,
|
|
480
|
-
method
|
|
465
|
+
name: columnName,
|
|
466
|
+
summaryName
|
|
481
467
|
} = tmpColumn;
|
|
482
468
|
const cell = cells && cells[pivotColumnKey];
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
469
|
+
if (!cell) return;
|
|
470
|
+
const cellTotal = cell && cell.total;
|
|
471
|
+
|
|
472
|
+
// cellTotal: [[summaryName, value], ...]
|
|
473
|
+
let value = '';
|
|
474
|
+
if (Array.isArray(cellTotal)) {
|
|
475
|
+
const pair = cellTotal.find(item => Array.isArray(item) && item[0] === summaryName);
|
|
476
|
+
value = pair ? pair[1] : '';
|
|
486
477
|
} else {
|
|
487
|
-
|
|
488
|
-
newRow[name] = cellValue;
|
|
489
|
-
total += cellValue;
|
|
478
|
+
value = '';
|
|
490
479
|
}
|
|
480
|
+
newRow[columnName] = value;
|
|
481
|
+
const num = Number(value);
|
|
482
|
+
if (!isNaN(num)) total += num;
|
|
491
483
|
});
|
|
492
484
|
newRow[_reactIntlUniversal.default.get('Total')] = total;
|
|
493
485
|
rows.push(newRow);
|
|
@@ -912,7 +904,8 @@ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
|
|
|
912
904
|
*/
|
|
913
905
|
const exportStatisticToTable = _ref8 => {
|
|
914
906
|
let {
|
|
915
|
-
statisticalResult
|
|
907
|
+
statisticalResult,
|
|
908
|
+
chart
|
|
916
909
|
} = _ref8;
|
|
917
910
|
const {
|
|
918
911
|
pivotResult,
|
|
@@ -921,13 +914,13 @@ const exportStatisticToTable = _ref8 => {
|
|
|
921
914
|
} = statisticalResult;
|
|
922
915
|
const {
|
|
923
916
|
pivot_columns,
|
|
924
|
-
|
|
917
|
+
summary_columns
|
|
925
918
|
} = pivotResult;
|
|
926
919
|
if (!groupbyColumn) return {};
|
|
927
920
|
|
|
928
921
|
// two dimension table
|
|
929
922
|
if (columnGroupbyColumn) {
|
|
930
|
-
if (Array.isArray(
|
|
923
|
+
if (Array.isArray(summary_columns) && summary_columns.length > 0) {
|
|
931
924
|
return exportTwoDimensionWithSummaryColumnsToTable({
|
|
932
925
|
statisticalResult
|
|
933
926
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.33-alpha.1",
|
|
4
4
|
"description": "statistics",
|
|
5
5
|
"main": "dist/dtable-statistic.js",
|
|
6
6
|
"author": "seafile",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@seafile/seafile-calendar": "0.0.24",
|
|
11
11
|
"comlink": "^4.4.1",
|
|
12
12
|
"dayjs": "1.10.7",
|
|
13
|
+
"dtable-web-api": "^5.2.6",
|
|
13
14
|
"html2canvas": "^1.4.1",
|
|
14
15
|
"rc-slider": "^9.7.4",
|
|
15
16
|
"react": "^18.3.1",
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"react-grid-layout": "^1.2.5",
|
|
19
20
|
"react-intl-universal": "^2.4.8",
|
|
20
21
|
"reactstrap": "9.2.3",
|
|
21
|
-
"sea-chart": "^1.1.
|
|
22
|
+
"sea-chart": "^1.1.105"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"dtable-ui-component": "~6.0.*",
|