sea-chart 0.0.85 → 0.0.87
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/settings/table-settings/data-settings.js +2 -0
- package/dist/settings/widgets/group-by.js +3 -3
- package/dist/utils/chart-utils/base-utils.js +14 -1
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +75 -77
- package/dist/utils/chart-utils/sql-statistics-utils.js +21 -11
- package/dist/utils/row-utils.js +7 -1
- package/dist/utils/sql/chart-data-sql.js +0 -4
- package/dist/view/wrapper/index.js +1 -2
- package/dist/view/wrapper/table/index.css +9 -4
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +53 -4
- package/dist/view/wrapper/table/pivot-table-display-name.js +3 -2
- package/dist/view/wrapper/table/two-dimension-table.js +2 -2
- package/dist/view/wrapper/trend.js +12 -8
- package/package.json +1 -1
|
@@ -506,6 +506,7 @@ const DataSettings = _ref => {
|
|
|
506
506
|
tables: tables,
|
|
507
507
|
className: "selected-x-axis",
|
|
508
508
|
label: intl.get('Row_grouping_field'),
|
|
509
|
+
isRenderNoUsed: false,
|
|
509
510
|
selectedTableId: table_id,
|
|
510
511
|
selectedColumnKey: groupby_column_key,
|
|
511
512
|
selectedDateGranularity: groupby_date_granularity,
|
|
@@ -524,6 +525,7 @@ const DataSettings = _ref => {
|
|
|
524
525
|
tables: tables,
|
|
525
526
|
className: "selected-x-axis",
|
|
526
527
|
label: intl.get('Column_grouping_field'),
|
|
528
|
+
isRenderNoUsed: true,
|
|
527
529
|
selectedTableId: table_id,
|
|
528
530
|
selectedColumnKey: column_groupby_column_key,
|
|
529
531
|
selectedDateGranularity: column_groupby_date_granularity,
|
|
@@ -84,8 +84,8 @@ class GroupBy extends Component {
|
|
|
84
84
|
};
|
|
85
85
|
this.getColumnOptions = columns => {
|
|
86
86
|
const {
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
type,
|
|
88
|
+
isRenderNoUsed
|
|
89
89
|
} = this.props;
|
|
90
90
|
let newColumns = columns.map(column => {
|
|
91
91
|
return {
|
|
@@ -104,7 +104,7 @@ class GroupBy extends Component {
|
|
|
104
104
|
} else if (type === CHART_TYPE.SCATTER) {
|
|
105
105
|
newColumns = newColumns.filter(column => NUMBERIC_COLUMN_TYPE.includes(column.value.type));
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
107
|
+
if (isRenderNoUsed) {
|
|
108
108
|
newColumns.unshift({
|
|
109
109
|
value: {
|
|
110
110
|
key: '',
|
|
@@ -233,6 +233,10 @@ BaseUtils.getChartGroups = charts => {
|
|
|
233
233
|
};
|
|
234
234
|
BaseUtils.isSameGroup = (isColumnDataAsAnArray, source, target) => {
|
|
235
235
|
if (isColumnDataAsAnArray) {
|
|
236
|
+
// column type is multiple-select
|
|
237
|
+
if (Array.isArray(source) && Array.isArray(target)) {
|
|
238
|
+
return JSON.stringify(source) === JSON.stringify(target);
|
|
239
|
+
}
|
|
236
240
|
return (!Array.isArray(source) || source.length === 0) && !target || source.includes(target);
|
|
237
241
|
}
|
|
238
242
|
return source === null && target === null || source === undefined && target === undefined || source === target;
|
|
@@ -310,6 +314,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue) => {
|
|
|
310
314
|
if (currentValue === null && nextValue === null) return null;
|
|
311
315
|
if (currentValue === null) return nextValue;
|
|
312
316
|
if (nextValue === null) return currentValue;
|
|
317
|
+
if (currentValue && nextValue) {
|
|
318
|
+
if (summaryMethod === 'MAX') {
|
|
319
|
+
return Math.max(currentValue, nextValue);
|
|
320
|
+
}
|
|
321
|
+
if (summaryMethod === 'MIN') {
|
|
322
|
+
return Math.min(currentValue, nextValue);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
313
325
|
}
|
|
314
326
|
return (currentValue - 0 || 0) + (nextValue - 0 || 0);
|
|
315
327
|
};
|
|
@@ -1012,7 +1024,8 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1012
1024
|
if (!Array.isArray(cellValue)) {
|
|
1013
1025
|
return [];
|
|
1014
1026
|
}
|
|
1015
|
-
|
|
1027
|
+
const newCellValue = cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
1028
|
+
return newCellValue.sort();
|
|
1016
1029
|
}
|
|
1017
1030
|
case CellType.COLLABORATOR:
|
|
1018
1031
|
{
|
|
@@ -5,6 +5,8 @@ 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
|
|
8
10
|
async function calculateOneDimensionTable(chart, value, _ref) {
|
|
9
11
|
let {
|
|
10
12
|
getViewRows,
|
|
@@ -56,7 +58,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
|
-
const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.
|
|
61
|
+
const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.column_key) : [];
|
|
60
62
|
const statisticColumnKeys = [summary_column_key, ...summary_columns_option_keys];
|
|
61
63
|
const validStatisticColumnKeys = statisticColumnKeys;
|
|
62
64
|
let statisticColumns = validStatisticColumnKeys.map(key => {
|
|
@@ -70,7 +72,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
70
72
|
}
|
|
71
73
|
Array.isArray(summary_columns) && summary_columns.forEach((option, index) => {
|
|
72
74
|
if (statisticColumns[index + 1]) {
|
|
73
|
-
statisticColumns[index + 1].method = option.
|
|
75
|
+
statisticColumns[index + 1].method = option.summary_method;
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
const {
|
|
@@ -205,6 +207,8 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
|
|
|
205
207
|
pivot_columns_total
|
|
206
208
|
};
|
|
207
209
|
}
|
|
210
|
+
|
|
211
|
+
// two
|
|
208
212
|
async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
209
213
|
let {
|
|
210
214
|
getViewRows,
|
|
@@ -239,34 +243,7 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
239
243
|
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
240
244
|
const statRows = await getViewRows(view, table);
|
|
241
245
|
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}, ...]
|
|
257
246
|
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
|
-
// ]
|
|
270
247
|
let pivot_rows = [];
|
|
271
248
|
statRows.forEach(row => {
|
|
272
249
|
const {
|
|
@@ -285,10 +262,16 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
285
262
|
let pivotRowIndex = pivot_rows.findIndex(r => !r.name);
|
|
286
263
|
updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, null, row, isRowGroupbyColumnDataAsAnArray, cellValueForColumn, chart, groupbyColumn, table);
|
|
287
264
|
} else {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
265
|
+
// groupbyColumn type is multiple-select use equal
|
|
266
|
+
if ((groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === 'multiple-select') {
|
|
267
|
+
pivotRowIndex = pivot_rows.findIndex(r => JSON.stringify(name) === JSON.stringify(r.name));
|
|
268
|
+
updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, name, row, isRowGroupbyColumnDataAsAnArray, cellValueForColumn, chart, groupbyColumn, table);
|
|
269
|
+
} else {
|
|
270
|
+
name.forEach(n => {
|
|
271
|
+
pivotRowIndex = pivot_rows.findIndex(r => n === r.name);
|
|
272
|
+
updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, n, row, isRowGroupbyColumnDataAsAnArray, cellValueForColumn, chart, groupbyColumn, table);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
292
275
|
}
|
|
293
276
|
} else {
|
|
294
277
|
pivotRowIndex = pivot_rows.findIndex(pivotRow => {
|
|
@@ -329,9 +312,10 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
329
312
|
pivot_columns,
|
|
330
313
|
pivot_columns_total: new_pivot_columns_total,
|
|
331
314
|
pivot_table_total,
|
|
332
|
-
pivot_summary_multiple_columns,
|
|
333
315
|
formulaRows,
|
|
334
|
-
dimensions: TABLE_DIMENSIONS.TWO
|
|
316
|
+
dimensions: TABLE_DIMENSIONS.TWO,
|
|
317
|
+
summary_columns: [summaryColumn, ...(summary_columns === null || summary_columns === void 0 ? void 0 : summary_columns.map(item => getTableColumnByKey(table, item.column_key)))],
|
|
318
|
+
isSingleNumericColumn: !summary_columns.length ? 'true' : 'false'
|
|
335
319
|
};
|
|
336
320
|
}
|
|
337
321
|
function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
|
|
@@ -347,15 +331,26 @@ function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow
|
|
|
347
331
|
});
|
|
348
332
|
}
|
|
349
333
|
} else {
|
|
350
|
-
|
|
351
|
-
|
|
334
|
+
// column is multiple-select use equal
|
|
335
|
+
if ((column === null || column === void 0 ? void 0 : column.type) === 'multiple-select') {
|
|
336
|
+
const pivotColumnIndex = pivot_columns.findIndex(r => JSON.stringify(r.key) === JSON.stringify(key));
|
|
352
337
|
if (pivotColumnIndex < 0) {
|
|
353
338
|
pivot_columns.push({
|
|
354
|
-
key:
|
|
355
|
-
original_key:
|
|
339
|
+
key: key,
|
|
340
|
+
original_key: key
|
|
356
341
|
});
|
|
357
342
|
}
|
|
358
|
-
}
|
|
343
|
+
} else {
|
|
344
|
+
key.forEach(k => {
|
|
345
|
+
pivotColumnIndex = pivot_columns.findIndex(r => r.key === k);
|
|
346
|
+
if (pivotColumnIndex < 0) {
|
|
347
|
+
pivot_columns.push({
|
|
348
|
+
key: k,
|
|
349
|
+
original_key: k
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
359
354
|
}
|
|
360
355
|
} else {
|
|
361
356
|
pivotColumnIndex = pivot_columns.findIndex(r => {
|
|
@@ -434,7 +429,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
434
429
|
const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
|
|
435
430
|
const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
|
|
436
431
|
const computedValue = BaseUtils.getSummaryValue({
|
|
437
|
-
summaryMethod: current.summary_method,
|
|
432
|
+
summaryMethod: current.summary_method.toUpperCase(),
|
|
438
433
|
summaryColumn: current.column
|
|
439
434
|
}, currentValue, nextValue);
|
|
440
435
|
const columnName = current.column.name;
|
|
@@ -528,21 +523,6 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
528
523
|
total
|
|
529
524
|
});
|
|
530
525
|
}
|
|
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
|
-
}
|
|
546
526
|
function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formula_rows) {
|
|
547
527
|
let pivot_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
548
528
|
let pivot_columns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
|
|
@@ -619,6 +599,23 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
619
599
|
pivot_table_total
|
|
620
600
|
};
|
|
621
601
|
}
|
|
602
|
+
|
|
603
|
+
// utils
|
|
604
|
+
function isSameName(prevName, currName) {
|
|
605
|
+
if (isNumber(prevName) && isNumber(currName)) {
|
|
606
|
+
return prevName === currName;
|
|
607
|
+
}
|
|
608
|
+
if (!prevName && !currName) {
|
|
609
|
+
return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
|
|
610
|
+
}
|
|
611
|
+
return prevName === currName;
|
|
612
|
+
}
|
|
613
|
+
function isSameGroup(isColumnDataAsAnArray, source, target) {
|
|
614
|
+
if (isColumnDataAsAnArray) {
|
|
615
|
+
return (!source || source.length === 0) && !target || source && source.includes(target);
|
|
616
|
+
}
|
|
617
|
+
return source === null && target === null || source === undefined && target === undefined || source === target;
|
|
618
|
+
}
|
|
622
619
|
function getTotal(summary_column, summary_type, summary_method) {
|
|
623
620
|
let rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
624
621
|
let formula_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
@@ -630,7 +627,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
630
627
|
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
631
628
|
total = rowsLength;
|
|
632
629
|
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
633
|
-
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values) {
|
|
630
|
+
if (summary_method === CHART_SUMMARY_TYPE.Distinct_values || summary_method === 'Distinct_values') {
|
|
634
631
|
total = 0;
|
|
635
632
|
let existMap = {};
|
|
636
633
|
rows.forEach(row => {
|
|
@@ -654,6 +651,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
654
651
|
total++;
|
|
655
652
|
}
|
|
656
653
|
});
|
|
654
|
+
total = getTotalByType(oldTotal, total);
|
|
657
655
|
return total;
|
|
658
656
|
}
|
|
659
657
|
if (summary_column && isDateColumn(summary_column)) {
|
|
@@ -711,22 +709,10 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
711
709
|
}
|
|
712
710
|
});
|
|
713
711
|
if (summary_method === 'Sum') {
|
|
714
|
-
|
|
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
|
-
}
|
|
712
|
+
total = getTotalByType(oldTotal, Number.parseFloat(sum.toFixed(8)));
|
|
721
713
|
} else if (summary_method === 'Mean') {
|
|
722
|
-
|
|
723
|
-
|
|
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
|
-
}
|
|
714
|
+
const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
715
|
+
total = getTotalByType(oldTotal, val);
|
|
730
716
|
}
|
|
731
717
|
break;
|
|
732
718
|
}
|
|
@@ -759,15 +745,15 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
759
745
|
let formulaRow = formula_rows[result._id];
|
|
760
746
|
if (formulaRow) {
|
|
761
747
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
762
|
-
total = formulaRow[summary_column_key][0];
|
|
748
|
+
total = getTotalByType(oldTotal, formulaRow[summary_column_key][0]);
|
|
763
749
|
} else {
|
|
764
|
-
|
|
750
|
+
getTotalByType(oldTotal, formulaRow[summary_column_key]);
|
|
765
751
|
}
|
|
766
752
|
} else {
|
|
767
|
-
total = null;
|
|
753
|
+
total = getTotalByType(oldTotal, null);
|
|
768
754
|
}
|
|
769
755
|
} else {
|
|
770
|
-
total = result[summary_column_key];
|
|
756
|
+
total = getTotalByType(oldTotal, result[summary_column_key]);
|
|
771
757
|
}
|
|
772
758
|
}
|
|
773
759
|
break;
|
|
@@ -781,7 +767,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
781
767
|
}
|
|
782
768
|
// formula_rows result can be '#VALUE!'
|
|
783
769
|
if (total === '#VALUE!') {
|
|
784
|
-
total = 0;
|
|
770
|
+
total = getTotalByType(oldTotal, 0);
|
|
785
771
|
}
|
|
786
772
|
return total || 0;
|
|
787
773
|
}
|
|
@@ -831,6 +817,18 @@ function getDateMaxOrMinTotal(dateArr, type) {
|
|
|
831
817
|
dateIndex = list.indexOf(dateValue);
|
|
832
818
|
return dateArr[dateIndex];
|
|
833
819
|
}
|
|
820
|
+
function getTotalByType(oldTotal, value) {
|
|
821
|
+
let newTotal = '';
|
|
822
|
+
if (Array.isArray(oldTotal)) {
|
|
823
|
+
newTotal = JSON.parse(JSON.stringify(oldTotal));
|
|
824
|
+
newTotal[0][1] = value;
|
|
825
|
+
} else {
|
|
826
|
+
newTotal = value;
|
|
827
|
+
}
|
|
828
|
+
return newTotal;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// index
|
|
834
832
|
function calculator(chart, value, _ref3) {
|
|
835
833
|
let {
|
|
836
834
|
getViewRows,
|
|
@@ -235,7 +235,7 @@ SQLStatisticsUtils.getGroupData = (result, groupColumn) => {
|
|
|
235
235
|
}
|
|
236
236
|
return groupList;
|
|
237
237
|
};
|
|
238
|
-
SQLStatisticsUtils.updateTwoDimensionColumns = (pivot_columns, key, _ref) => {
|
|
238
|
+
SQLStatisticsUtils.updateTwoDimensionColumns = (pivot_columns, key, _ref, columnGroupbyColumn) => {
|
|
239
239
|
let {
|
|
240
240
|
isIncludeEmpty,
|
|
241
241
|
isCellValueAsAnArray
|
|
@@ -251,6 +251,18 @@ SQLStatisticsUtils.updateTwoDimensionColumns = (pivot_columns, key, _ref) => {
|
|
|
251
251
|
}
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
// columnGroupbyColumn is multiple-select use equal
|
|
256
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === 'multiple-select') {
|
|
257
|
+
const pivotColumnIndex = pivot_columns.findIndex(r => JSON.stringify(r.key) === JSON.stringify(key));
|
|
258
|
+
if (pivotColumnIndex < 0) {
|
|
259
|
+
pivot_columns.push({
|
|
260
|
+
key: key,
|
|
261
|
+
original_key: key
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
254
266
|
key.forEach(k => {
|
|
255
267
|
const pivotColumnIndex = pivot_columns.findIndex(r => r.key === k);
|
|
256
268
|
if (pivotColumnIndex < 0) {
|
|
@@ -609,7 +621,7 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
609
621
|
_SQLStatisticsUtils.updateTwoDimensionColumns(pivot_columns, columnGroupbyColumnCellValueKey, {
|
|
610
622
|
isIncludeEmpty: groupby_include_empty_cells,
|
|
611
623
|
isCellValueAsAnArray: isRowGroupbyColumnDataAsAnArray
|
|
612
|
-
});
|
|
624
|
+
}, columnGroupbyColumn);
|
|
613
625
|
}
|
|
614
626
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValue, groupby_include_empty_cells)) {
|
|
615
627
|
if (MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type]) {
|
|
@@ -624,15 +636,13 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
624
636
|
multipleNumericColumnsWithMethod
|
|
625
637
|
}, chartSQLMap);
|
|
626
638
|
} else {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}, chartSQLMap);
|
|
635
|
-
});
|
|
639
|
+
let pivotRowIndex = pivot_rows.findIndex(r => JSON.stringify(groupbyColumnCellValueKey) === JSON.stringify(r.name));
|
|
640
|
+
_SQLStatisticsUtils.updateTwoDimensionRows(chart, pivot_rows, pivot_columns, pivotRowIndex, groupbyColumnCellValueKey,
|
|
641
|
+
// count,
|
|
642
|
+
row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
643
|
+
singleNumeriColumnWithMethod,
|
|
644
|
+
multipleNumericColumnsWithMethod
|
|
645
|
+
}, chartSQLMap);
|
|
636
646
|
}
|
|
637
647
|
} else {
|
|
638
648
|
let pivotRowIndex = pivot_rows.findIndex(r => {
|
package/dist/utils/row-utils.js
CHANGED
|
@@ -33,7 +33,7 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
33
33
|
type: columnType,
|
|
34
34
|
data: columnData
|
|
35
35
|
} = column || {};
|
|
36
|
-
if (columnType === CellType.SINGLE_SELECT
|
|
36
|
+
if (columnType === CellType.SINGLE_SELECT) {
|
|
37
37
|
let options = columnData ? columnData.options : [];
|
|
38
38
|
let selectedOption = options.find(o => {
|
|
39
39
|
let id = name;
|
|
@@ -48,6 +48,12 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
48
48
|
if (selectedOption) {
|
|
49
49
|
return optionName;
|
|
50
50
|
}
|
|
51
|
+
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
52
|
+
// Return the array directly and process it in the rendering, file directly: src/view/wrapper/table/pivot-table-display-name.js
|
|
53
|
+
if (Array.isArray(name)) {
|
|
54
|
+
return name;
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
51
57
|
} else if (columnType === CellType.COLLABORATOR) {
|
|
52
58
|
let collaborator = collaborators.find(item => {
|
|
53
59
|
let email = name;
|
|
@@ -502,10 +502,6 @@ class ChartDataSQL {
|
|
|
502
502
|
const groupby_include_empty_cells = this.chart['groupby_include_empty_cells'] || false;
|
|
503
503
|
let summary_method = this.chart['summary_method'] || '';
|
|
504
504
|
const summary_columns = this.chart['summary_columns'] || [];
|
|
505
|
-
if (!summary_method) {
|
|
506
|
-
this.error = 'Summary_method_is_not_valid';
|
|
507
|
-
return '';
|
|
508
|
-
}
|
|
509
505
|
const groupby_column = this._get_column_by_key(groupby_column_key);
|
|
510
506
|
if (!groupby_column) {
|
|
511
507
|
this.error = 'Group_by_column_not_found';
|
|
@@ -87,8 +87,7 @@ const Wrapper = _ref => {
|
|
|
87
87
|
summaryColumns: summary_columns,
|
|
88
88
|
columnGroupbyColumn: columnGroupbyColumn,
|
|
89
89
|
summaryMethod: summary_method,
|
|
90
|
-
chartTableColumns: chartTableColumns
|
|
91
|
-
isCalculateByView: isCalculateByView
|
|
90
|
+
chartTableColumns: chartTableColumns
|
|
92
91
|
}));
|
|
93
92
|
}
|
|
94
93
|
case CHART_TYPE.COMBINATION:
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
.sea-chart-pivot-table th,
|
|
20
20
|
.sea-chart-pivot-table td {
|
|
21
|
-
padding:
|
|
21
|
+
padding: 5px;
|
|
22
22
|
border-right: 1px solid #ccc;
|
|
23
23
|
border-left: 1px solid #ccc;
|
|
24
24
|
border-bottom: none;
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
text-overflow: ellipsis;
|
|
31
31
|
white-space: nowrap;
|
|
32
32
|
text-align: center;
|
|
33
|
+
height: 32px;
|
|
34
|
+
max-height: 32px;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
.sea-chart-pivot-table .column-title,
|
|
@@ -157,13 +159,16 @@
|
|
|
157
159
|
overflow: hidden;
|
|
158
160
|
display: flex;
|
|
159
161
|
justify-content: center;
|
|
162
|
+
align-items: center;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
.sea-chart-pivot-table .pivot-table-header-summary-columns-container > div,
|
|
163
166
|
.sea-chart-pivot-table .pivot-cells-container > div {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
height: 100%;
|
|
168
|
+
width: 100%;
|
|
169
|
+
display: flex;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
align-items: center;
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
.sea-chart-pivot-table .pivot-table-header-summary-columns-container > div:not(:first-child),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
+
import { getTableById } from 'dtable-utils';
|
|
3
4
|
import { BaseUtils, ObjectUtils } from '../../../utils';
|
|
4
5
|
import intl from '../../../intl';
|
|
5
|
-
import { CHART_THEME_COLOR } from '../../../constants';
|
|
6
|
+
import { CHART_THEME_COLOR, CHART_SUMMARY_TYPE } from '../../../constants';
|
|
6
7
|
import PivotTableDisplayName from './pivot-table-display-name';
|
|
7
8
|
class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
8
9
|
constructor() {
|
|
@@ -14,11 +15,15 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
14
15
|
chart
|
|
15
16
|
} = this.props;
|
|
16
17
|
const {
|
|
17
|
-
display_total = true
|
|
18
|
+
display_total = true,
|
|
19
|
+
table_id,
|
|
20
|
+
summary_type
|
|
18
21
|
} = chart.config;
|
|
19
22
|
const {
|
|
20
23
|
name: groupName
|
|
21
24
|
} = groupbyColumn;
|
|
25
|
+
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
26
|
+
const columnName = isCount ? intl.get('Amount') : this.getColumnName();
|
|
22
27
|
const {
|
|
23
28
|
rowIdx: selectRowIdx,
|
|
24
29
|
cellIdx: selectedCellIdx
|
|
@@ -28,12 +33,35 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
28
33
|
className: "seatable-table-header-sm"
|
|
29
34
|
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
30
35
|
className: "pivot-table-header"
|
|
31
|
-
}, groupName),
|
|
36
|
+
}, groupName), /*#__PURE__*/React.createElement("th", {
|
|
37
|
+
className: classnames('pivot-table-header', {
|
|
38
|
+
'selected-pivot-cell-top': isSelectedTotalCellBottom
|
|
39
|
+
})
|
|
40
|
+
}, /*#__PURE__*/React.createElement("div", null, columnName)), display_total && /*#__PURE__*/React.createElement("th", {
|
|
32
41
|
className: classnames('pivot-table-header', {
|
|
33
42
|
'selected-pivot-cell-top': isSelectedTotalCellBottom
|
|
34
43
|
})
|
|
35
44
|
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
|
|
36
45
|
};
|
|
46
|
+
this.getColumnName = () => {
|
|
47
|
+
const {
|
|
48
|
+
tables,
|
|
49
|
+
result,
|
|
50
|
+
chart
|
|
51
|
+
} = this.props;
|
|
52
|
+
const {
|
|
53
|
+
pivot_columns
|
|
54
|
+
} = result;
|
|
55
|
+
const {
|
|
56
|
+
table_id
|
|
57
|
+
} = chart.config;
|
|
58
|
+
if (Array.isArray(pivot_columns) && pivot_columns.length !== 0) {
|
|
59
|
+
const table = getTableById(tables, table_id);
|
|
60
|
+
const column = table === null || table === void 0 ? void 0 : table.columns.find(item => item.key === pivot_columns[0].key);
|
|
61
|
+
return (column === null || column === void 0 ? void 0 : column.name) || '';
|
|
62
|
+
}
|
|
63
|
+
return '';
|
|
64
|
+
};
|
|
37
65
|
this.toggleRecords = (cell, selectedCell) => {
|
|
38
66
|
if (window.isMobile) return;
|
|
39
67
|
const {
|
|
@@ -81,7 +109,6 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
81
109
|
let pivotColumnCells = [];
|
|
82
110
|
const isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
83
111
|
const isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
84
|
-
// eslint-disable-next-line
|
|
85
112
|
const total = ObjectUtils.hasOwnProperty(pivot_columns_total, 'total') ? pivot_columns_total['total'] : 0;
|
|
86
113
|
const summaryDisplayValue = BaseUtils.getSummaryValueDisplayString(summaryColumn, total);
|
|
87
114
|
const isValidSummaryDisplayValue = BaseUtils.isValidValue(summaryDisplayValue, display_empty);
|
|
@@ -108,6 +135,18 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
108
135
|
column: groupbyColumn,
|
|
109
136
|
rowData: rowItem,
|
|
110
137
|
globalTheme: globalTheme
|
|
138
|
+
})), /*#__PURE__*/React.createElement("td", {
|
|
139
|
+
className: classnames('pivot-cell', {
|
|
140
|
+
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
141
|
+
'selected-pivot-cell': isSelectedTotalCell,
|
|
142
|
+
'selected-pivot-cell-top': isSelectedTotalCellTop,
|
|
143
|
+
'selected-pivot-cell-left': isSelectedTotalCellLeft
|
|
144
|
+
}),
|
|
145
|
+
total: totalDisplayValue
|
|
146
|
+
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
147
|
+
className: classnames({
|
|
148
|
+
'selected-pivot-cell-border': isSelectedTotalCell
|
|
149
|
+
})
|
|
111
150
|
})), display_total && /*#__PURE__*/React.createElement("td", {
|
|
112
151
|
className: classnames('pivot-cell', {
|
|
113
152
|
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
@@ -134,6 +173,16 @@ class OneDimensionTableNoNumericColumns extends PureComponent {
|
|
|
134
173
|
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
135
174
|
})
|
|
136
175
|
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), /*#__PURE__*/React.createElement("td", {
|
|
176
|
+
className: classnames('pivot-cell pivot-table-total', {
|
|
177
|
+
'pivot-empty-cell': !isValidSummaryDisplayValue,
|
|
178
|
+
'selected-pivot-cell': isSelectTotal
|
|
179
|
+
}),
|
|
180
|
+
title: isValidSummaryDisplayValue ? summaryDisplayValue : ''
|
|
181
|
+
}, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
182
|
+
className: classnames({
|
|
183
|
+
'selected-pivot-cell-border': isSelectTotal
|
|
184
|
+
})
|
|
185
|
+
})), /*#__PURE__*/React.createElement("td", {
|
|
137
186
|
className: classnames('pivot-cell pivot-table-total', {
|
|
138
187
|
'pivot-empty-cell': !isValidSummaryDisplayValue,
|
|
139
188
|
'selected-pivot-cell': isSelectTotal
|
|
@@ -122,9 +122,10 @@ class PivotTableDisplayName extends React.Component {
|
|
|
122
122
|
} = this.props;
|
|
123
123
|
const {
|
|
124
124
|
original_name,
|
|
125
|
-
name
|
|
125
|
+
name,
|
|
126
|
+
original_key
|
|
126
127
|
} = rowData;
|
|
127
|
-
const newValue = original_name || name;
|
|
128
|
+
const newValue = original_name || name || original_key;
|
|
128
129
|
const options = getColumnOptions(column);
|
|
129
130
|
const validValue = Array.isArray(newValue) && newValue.length !== 0 ? newValue : [newValue];
|
|
130
131
|
displayName = /*#__PURE__*/React.createElement("div", {
|
|
@@ -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
|
|
135
|
+
return summaryColumns.map(item => {
|
|
136
136
|
return /*#__PURE__*/React.createElement("div", {
|
|
137
|
-
key: "table-cell-".concat(
|
|
137
|
+
key: "table-cell-".concat(item.key),
|
|
138
138
|
className: classnames('pivot-cell', {
|
|
139
139
|
'pivot-empty-cell': true
|
|
140
140
|
})
|
|
@@ -76,10 +76,10 @@ class Trend extends Component {
|
|
|
76
76
|
previous
|
|
77
77
|
} = data || {};
|
|
78
78
|
let color = '#fa5757',
|
|
79
|
-
icon = '
|
|
79
|
+
icon = 'dtable-icon-down1';
|
|
80
80
|
if (type === 'up') {
|
|
81
81
|
color = '#34aa95';
|
|
82
|
-
icon = '
|
|
82
|
+
icon = 'dtable-icon-up1';
|
|
83
83
|
}
|
|
84
84
|
if (labelFontSize <= 12) {
|
|
85
85
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -98,9 +98,11 @@ class Trend extends Component {
|
|
|
98
98
|
backgroundColor: "".concat(color, "26"),
|
|
99
99
|
textAlign: 'center',
|
|
100
100
|
marginRight: '8px',
|
|
101
|
-
fontWeight: 'bold'
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
fontWeight: 'bold',
|
|
102
|
+
fontSize: '10px'
|
|
103
|
+
},
|
|
104
|
+
className: "dtable-font ".concat(icon)
|
|
105
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
104
106
|
style: {
|
|
105
107
|
color: "".concat(color)
|
|
106
108
|
}
|
|
@@ -132,9 +134,11 @@ class Trend extends Component {
|
|
|
132
134
|
backgroundColor: "".concat(color, "26"),
|
|
133
135
|
textAlign: 'center',
|
|
134
136
|
marginRight: '8px',
|
|
135
|
-
fontWeight: 'bold'
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
fontWeight: 'bold',
|
|
138
|
+
fontSize: '11px'
|
|
139
|
+
},
|
|
140
|
+
className: "dtable-font ".concat(icon)
|
|
141
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
138
142
|
style: {
|
|
139
143
|
color: color,
|
|
140
144
|
marginRight: '0px'
|