sea-chart 0.0.82-alpha.2 → 0.0.82
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.
|
@@ -308,14 +308,6 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue) => {
|
|
|
308
308
|
if (currentValue === null && nextValue === null) return null;
|
|
309
309
|
if (currentValue === null) return nextValue;
|
|
310
310
|
if (nextValue === null) return currentValue;
|
|
311
|
-
if (currentValue && nextValue) {
|
|
312
|
-
if (summaryMethod === 'MAX') {
|
|
313
|
-
return Math.max(currentValue, nextValue);
|
|
314
|
-
}
|
|
315
|
-
if (summaryMethod === 'MIN') {
|
|
316
|
-
return Math.min(currentValue, nextValue);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
311
|
}
|
|
320
312
|
return (currentValue - 0 || 0) + (nextValue - 0 || 0);
|
|
321
313
|
};
|
|
@@ -5,8 +5,6 @@ import { isArrayCellValue } from '../../cell-value-utils';
|
|
|
5
5
|
import { getFormattedLabel, isValidRow } from '../../row-utils';
|
|
6
6
|
import BaseUtils from '../base-utils';
|
|
7
7
|
import { summaryMethodColumn2SqlColumn } from '../../sql/column-2-sql-column';
|
|
8
|
-
|
|
9
|
-
// one
|
|
10
8
|
async function calculateOneDimensionTable(chart, value, _ref) {
|
|
11
9
|
let {
|
|
12
10
|
getViewRows,
|
|
@@ -58,7 +56,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
});
|
|
61
|
-
const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.
|
|
59
|
+
const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.key) : [];
|
|
62
60
|
const statisticColumnKeys = [summary_column_key, ...summary_columns_option_keys];
|
|
63
61
|
const validStatisticColumnKeys = statisticColumnKeys;
|
|
64
62
|
let statisticColumns = validStatisticColumnKeys.map(key => {
|
|
@@ -72,7 +70,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
72
70
|
}
|
|
73
71
|
Array.isArray(summary_columns) && summary_columns.forEach((option, index) => {
|
|
74
72
|
if (statisticColumns[index + 1]) {
|
|
75
|
-
statisticColumns[index + 1].method = option.
|
|
73
|
+
statisticColumns[index + 1].method = option.method;
|
|
76
74
|
}
|
|
77
75
|
});
|
|
78
76
|
const {
|
|
@@ -207,8 +205,6 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
207
205
|
pivot_columns_total
|
|
208
206
|
};
|
|
209
207
|
}
|
|
210
|
-
|
|
211
|
-
// two
|
|
212
208
|
async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
213
209
|
let {
|
|
214
210
|
getViewRows,
|
|
@@ -243,7 +239,34 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
243
239
|
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
244
240
|
const statRows = await getViewRows(view, table);
|
|
245
241
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
242
|
+
const pivot_summary_multiple_columns = [];
|
|
243
|
+
Array.isArray(summary_columns) && summary_columns.forEach(item => {
|
|
244
|
+
const column = getTableColumnByKey(table, item.column_key);
|
|
245
|
+
if (column && isNumericColumn(column)) {
|
|
246
|
+
pivot_summary_multiple_columns.push({
|
|
247
|
+
key: item.column_key,
|
|
248
|
+
type: column.type,
|
|
249
|
+
data: column.data,
|
|
250
|
+
method: item.summary_method,
|
|
251
|
+
column_name: column.name
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// [{key: null}, {key: cell_value}, {key: cell_value}, ...]
|
|
246
257
|
let pivot_columns = [];
|
|
258
|
+
|
|
259
|
+
// [
|
|
260
|
+
// {
|
|
261
|
+
// name: '',
|
|
262
|
+
// cells: {
|
|
263
|
+
// [key1]: {rows: [], total: ''},
|
|
264
|
+
// [key2]: {rows: [], total: ''},
|
|
265
|
+
// [key3]: {rows: [], total: ''},
|
|
266
|
+
// }
|
|
267
|
+
// },
|
|
268
|
+
// ...
|
|
269
|
+
// ]
|
|
247
270
|
let pivot_rows = [];
|
|
248
271
|
statRows.forEach(row => {
|
|
249
272
|
const {
|
|
@@ -306,10 +329,9 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
306
329
|
pivot_columns,
|
|
307
330
|
pivot_columns_total: new_pivot_columns_total,
|
|
308
331
|
pivot_table_total,
|
|
332
|
+
pivot_summary_multiple_columns,
|
|
309
333
|
formulaRows,
|
|
310
|
-
dimensions: TABLE_DIMENSIONS.TWO
|
|
311
|
-
summary_columns: [summaryColumn, ...(summary_columns === null || summary_columns === void 0 ? void 0 : summary_columns.map(item => getTableColumnByKey(table, item.column_key)))],
|
|
312
|
-
isSingleNumericColumn: !summary_columns.length ? 'true' : 'false'
|
|
334
|
+
dimensions: TABLE_DIMENSIONS.TWO
|
|
313
335
|
};
|
|
314
336
|
}
|
|
315
337
|
function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
|
|
@@ -412,7 +434,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
412
434
|
const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
|
|
413
435
|
const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
|
|
414
436
|
const computedValue = BaseUtils.getSummaryValue({
|
|
415
|
-
summaryMethod: current.summary_method
|
|
437
|
+
summaryMethod: current.summary_method,
|
|
416
438
|
summaryColumn: current.column
|
|
417
439
|
}, currentValue, nextValue);
|
|
418
440
|
const columnName = current.column.name;
|
|
@@ -506,6 +528,21 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
506
528
|
total
|
|
507
529
|
});
|
|
508
530
|
}
|
|
531
|
+
function isSameName(prevName, currName) {
|
|
532
|
+
if (isNumber(prevName) && isNumber(currName)) {
|
|
533
|
+
return prevName === currName;
|
|
534
|
+
}
|
|
535
|
+
if (!prevName && !currName) {
|
|
536
|
+
return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
|
|
537
|
+
}
|
|
538
|
+
return prevName === currName;
|
|
539
|
+
}
|
|
540
|
+
function isSameGroup(isColumnDataAsAnArray, source, target) {
|
|
541
|
+
if (isColumnDataAsAnArray) {
|
|
542
|
+
return (!source || source.length === 0) && !target || source && source.includes(target);
|
|
543
|
+
}
|
|
544
|
+
return source === null && target === null || source === undefined && target === undefined || source === target;
|
|
545
|
+
}
|
|
509
546
|
function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formula_rows) {
|
|
510
547
|
let pivot_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
511
548
|
let pivot_columns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
|
|
@@ -582,23 +619,6 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
582
619
|
pivot_table_total
|
|
583
620
|
};
|
|
584
621
|
}
|
|
585
|
-
|
|
586
|
-
// utils
|
|
587
|
-
function isSameName(prevName, currName) {
|
|
588
|
-
if (isNumber(prevName) && isNumber(currName)) {
|
|
589
|
-
return prevName === currName;
|
|
590
|
-
}
|
|
591
|
-
if (!prevName && !currName) {
|
|
592
|
-
return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
|
|
593
|
-
}
|
|
594
|
-
return prevName === currName;
|
|
595
|
-
}
|
|
596
|
-
function isSameGroup(isColumnDataAsAnArray, source, target) {
|
|
597
|
-
if (isColumnDataAsAnArray) {
|
|
598
|
-
return (!source || source.length === 0) && !target || source && source.includes(target);
|
|
599
|
-
}
|
|
600
|
-
return source === null && target === null || source === undefined && target === undefined || source === target;
|
|
601
|
-
}
|
|
602
622
|
function getTotal(summary_column, summary_type, summary_method) {
|
|
603
623
|
let rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
604
624
|
let formula_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
@@ -634,7 +654,6 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
634
654
|
total++;
|
|
635
655
|
}
|
|
636
656
|
});
|
|
637
|
-
total = getTotalByType(oldTotal, total);
|
|
638
657
|
return total;
|
|
639
658
|
}
|
|
640
659
|
if (summary_column && isDateColumn(summary_column)) {
|
|
@@ -692,10 +711,22 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
692
711
|
}
|
|
693
712
|
});
|
|
694
713
|
if (summary_method === 'Sum') {
|
|
695
|
-
|
|
714
|
+
if (Array.isArray(oldTotal)) {
|
|
715
|
+
const newTotal = JSON.parse(JSON.stringify(oldTotal));
|
|
716
|
+
newTotal[0][1] = Number.parseFloat(sum.toFixed(8));
|
|
717
|
+
total = newTotal;
|
|
718
|
+
} else {
|
|
719
|
+
total = Number.parseFloat(sum.toFixed(8));
|
|
720
|
+
}
|
|
696
721
|
} else if (summary_method === 'Mean') {
|
|
697
|
-
|
|
698
|
-
|
|
722
|
+
if (Array.isArray(oldTotal)) {
|
|
723
|
+
const newTotal = JSON.parse(JSON.stringify(oldTotal));
|
|
724
|
+
const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
725
|
+
newTotal[0][1] = val;
|
|
726
|
+
total = newTotal;
|
|
727
|
+
} else {
|
|
728
|
+
total = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
729
|
+
}
|
|
699
730
|
}
|
|
700
731
|
break;
|
|
701
732
|
}
|
|
@@ -728,15 +759,15 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
728
759
|
let formulaRow = formula_rows[result._id];
|
|
729
760
|
if (formulaRow) {
|
|
730
761
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
731
|
-
total =
|
|
762
|
+
total = formulaRow[summary_column_key][0];
|
|
732
763
|
} else {
|
|
733
|
-
|
|
764
|
+
total = formulaRow[summary_column_key];
|
|
734
765
|
}
|
|
735
766
|
} else {
|
|
736
|
-
total =
|
|
767
|
+
total = null;
|
|
737
768
|
}
|
|
738
769
|
} else {
|
|
739
|
-
total =
|
|
770
|
+
total = result[summary_column_key];
|
|
740
771
|
}
|
|
741
772
|
}
|
|
742
773
|
break;
|
|
@@ -750,7 +781,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
750
781
|
}
|
|
751
782
|
// formula_rows result can be '#VALUE!'
|
|
752
783
|
if (total === '#VALUE!') {
|
|
753
|
-
total =
|
|
784
|
+
total = 0;
|
|
754
785
|
}
|
|
755
786
|
return total || 0;
|
|
756
787
|
}
|
|
@@ -800,18 +831,6 @@ function getDateMaxOrMinTotal(dateArr, type) {
|
|
|
800
831
|
dateIndex = list.indexOf(dateValue);
|
|
801
832
|
return dateArr[dateIndex];
|
|
802
833
|
}
|
|
803
|
-
function getTotalByType(oldTotal, value) {
|
|
804
|
-
let newTotal = '';
|
|
805
|
-
if (Array.isArray(oldTotal)) {
|
|
806
|
-
newTotal = JSON.parse(JSON.stringify(oldTotal));
|
|
807
|
-
newTotal[0][1] = value;
|
|
808
|
-
} else {
|
|
809
|
-
newTotal = value;
|
|
810
|
-
}
|
|
811
|
-
return newTotal;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
// index
|
|
815
834
|
function calculator(chart, value, _ref3) {
|
|
816
835
|
let {
|
|
817
836
|
getViewRows,
|
|
@@ -132,9 +132,9 @@ class TwoDimensionTable extends PureComponent {
|
|
|
132
132
|
};
|
|
133
133
|
this.renderEmpty = (summaryColumns, cellIdx) => {
|
|
134
134
|
if (summaryColumns && (summaryColumns === null || summaryColumns === void 0 ? void 0 : summaryColumns.length) !== 0) {
|
|
135
|
-
return summaryColumns.map(
|
|
135
|
+
return summaryColumns.map(() => {
|
|
136
136
|
return /*#__PURE__*/React.createElement("div", {
|
|
137
|
-
key: "table-cell-".concat(
|
|
137
|
+
key: "table-cell-".concat(cellIdx),
|
|
138
138
|
className: classnames('pivot-cell', {
|
|
139
139
|
'pivot-empty-cell': true
|
|
140
140
|
})
|