sea-chart 0.0.84 → 0.0.85-alpha.0
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 +10 -0
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +1 -0
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +48 -67
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +14 -10
- package/dist/utils/chart-utils/sql-statistics-utils.js +22 -4
- package/dist/utils/row-record-utils.js +2 -3
- package/dist/utils/sql/chart-data-sql.js +0 -4
- package/dist/utils/trend-utils.js +1 -1
- package/dist/view/wrapper/area.js +1 -1
- package/dist/view/wrapper/bar-group.js +0 -3
- package/dist/view/wrapper/basic-number-card.js +1 -2
- package/dist/view/wrapper/combination.js +0 -6
- package/dist/view/wrapper/horizontal-bar-group.js +1 -4
- package/dist/view/wrapper/index.js +3 -2
- package/dist/view/wrapper/line-group.js +1 -1
- package/dist/view/wrapper/line.js +1 -1
- package/dist/view/wrapper/table/index.css +8 -4
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +53 -4
- package/dist/view/wrapper/table/two-dimension-table.js +2 -2
- package/dist/view/wrapper/trend.js +3 -15
- package/package.json +2 -2
|
@@ -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: '',
|
|
@@ -165,9 +165,11 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
165
165
|
case CHART_TYPE.LINE:
|
|
166
166
|
case CHART_TYPE.LINE_GROUP:
|
|
167
167
|
case CHART_TYPE.AREA:
|
|
168
|
+
case CHART_TYPE.AREA_GROUP:
|
|
168
169
|
case CHART_TYPE.HORIZONTAL_BAR:
|
|
169
170
|
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
170
171
|
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
172
|
+
case CHART_TYPE.BAR_STACK:
|
|
171
173
|
{
|
|
172
174
|
return getTableColumnByKey(table, y_axis_summary_column_key);
|
|
173
175
|
}
|
|
@@ -308,6 +310,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue) => {
|
|
|
308
310
|
if (currentValue === null && nextValue === null) return null;
|
|
309
311
|
if (currentValue === null) return nextValue;
|
|
310
312
|
if (nextValue === null) return currentValue;
|
|
313
|
+
if (currentValue && nextValue) {
|
|
314
|
+
if (summaryMethod === 'MAX') {
|
|
315
|
+
return Math.max(currentValue, nextValue);
|
|
316
|
+
}
|
|
317
|
+
if (summaryMethod === 'MIN') {
|
|
318
|
+
return Math.min(currentValue, nextValue);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
311
321
|
}
|
|
312
322
|
return (currentValue - 0 || 0) + (nextValue - 0 || 0);
|
|
313
323
|
};
|
|
@@ -253,6 +253,7 @@ async function calculator(chart, value, _ref) {
|
|
|
253
253
|
results.push({
|
|
254
254
|
name: key,
|
|
255
255
|
value_left: value,
|
|
256
|
+
group_name: summaryColumn.column_name,
|
|
256
257
|
color: leftSummaryColumn[columnKey].color,
|
|
257
258
|
value_right: value2,
|
|
258
259
|
formatted_value_left: formattedValueLeft,
|
|
@@ -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 {
|
|
@@ -329,9 +306,10 @@ async function calculateTwoDimensionTable(chart, value, _ref2) {
|
|
|
329
306
|
pivot_columns,
|
|
330
307
|
pivot_columns_total: new_pivot_columns_total,
|
|
331
308
|
pivot_table_total,
|
|
332
|
-
pivot_summary_multiple_columns,
|
|
333
309
|
formulaRows,
|
|
334
|
-
dimensions: TABLE_DIMENSIONS.TWO
|
|
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'
|
|
335
313
|
};
|
|
336
314
|
}
|
|
337
315
|
function updateTwoDimensionColumns(value, pivot_columns, column, row, formulaRow, isIncludeEmpty, dateGranularity, geolocationGranularity, isRowGroupbyColumnDataAsAnArray) {
|
|
@@ -434,7 +412,7 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
434
412
|
const nextValue = row[current === null || current === void 0 ? void 0 : current.column.key];
|
|
435
413
|
const currentValue = Object.values(cells[key].total).find(item => item[2] === columnKey)[1];
|
|
436
414
|
const computedValue = BaseUtils.getSummaryValue({
|
|
437
|
-
summaryMethod: current.summary_method,
|
|
415
|
+
summaryMethod: current.summary_method.toUpperCase(),
|
|
438
416
|
summaryColumn: current.column
|
|
439
417
|
}, currentValue, nextValue);
|
|
440
418
|
const columnName = current.column.name;
|
|
@@ -528,21 +506,6 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
|
|
|
528
506
|
total
|
|
529
507
|
});
|
|
530
508
|
}
|
|
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
509
|
function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formula_rows) {
|
|
547
510
|
let pivot_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
548
511
|
let pivot_columns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
|
|
@@ -619,6 +582,23 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
|
|
|
619
582
|
pivot_table_total
|
|
620
583
|
};
|
|
621
584
|
}
|
|
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
|
+
}
|
|
622
602
|
function getTotal(summary_column, summary_type, summary_method) {
|
|
623
603
|
let rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
624
604
|
let formula_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
@@ -654,6 +634,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
654
634
|
total++;
|
|
655
635
|
}
|
|
656
636
|
});
|
|
637
|
+
total = getTotalByType(oldTotal, total);
|
|
657
638
|
return total;
|
|
658
639
|
}
|
|
659
640
|
if (summary_column && isDateColumn(summary_column)) {
|
|
@@ -711,22 +692,10 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
711
692
|
}
|
|
712
693
|
});
|
|
713
694
|
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
|
-
}
|
|
695
|
+
total = getTotalByType(oldTotal, Number.parseFloat(sum.toFixed(8)));
|
|
721
696
|
} 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
|
-
}
|
|
697
|
+
const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
698
|
+
total = getTotalByType(oldTotal, val);
|
|
730
699
|
}
|
|
731
700
|
break;
|
|
732
701
|
}
|
|
@@ -759,15 +728,15 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
759
728
|
let formulaRow = formula_rows[result._id];
|
|
760
729
|
if (formulaRow) {
|
|
761
730
|
if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
|
|
762
|
-
total = formulaRow[summary_column_key][0];
|
|
731
|
+
total = getTotalByType(oldTotal, formulaRow[summary_column_key][0]);
|
|
763
732
|
} else {
|
|
764
|
-
|
|
733
|
+
getTotalByType(oldTotal, formulaRow[summary_column_key]);
|
|
765
734
|
}
|
|
766
735
|
} else {
|
|
767
|
-
total = null;
|
|
736
|
+
total = getTotalByType(oldTotal, null);
|
|
768
737
|
}
|
|
769
738
|
} else {
|
|
770
|
-
total = result[summary_column_key];
|
|
739
|
+
total = getTotalByType(oldTotal, result[summary_column_key]);
|
|
771
740
|
}
|
|
772
741
|
}
|
|
773
742
|
break;
|
|
@@ -781,7 +750,7 @@ function getTotal(summary_column, summary_type, summary_method) {
|
|
|
781
750
|
}
|
|
782
751
|
// formula_rows result can be '#VALUE!'
|
|
783
752
|
if (total === '#VALUE!') {
|
|
784
|
-
total = 0;
|
|
753
|
+
total = getTotalByType(oldTotal, 0);
|
|
785
754
|
}
|
|
786
755
|
return total || 0;
|
|
787
756
|
}
|
|
@@ -831,6 +800,18 @@ function getDateMaxOrMinTotal(dateArr, type) {
|
|
|
831
800
|
dateIndex = list.indexOf(dateValue);
|
|
832
801
|
return dateArr[dateIndex];
|
|
833
802
|
}
|
|
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
|
|
834
815
|
function calculator(chart, value, _ref3) {
|
|
835
816
|
let {
|
|
836
817
|
getViewRows,
|
|
@@ -78,23 +78,27 @@ async function calculator(chart, value, _ref) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
// normal case
|
|
83
|
+
const res = Math.abs(currentValues - previousValues) / previousValues;
|
|
84
|
+
let result = Number.parseFloat(res * 100).toFixed(2) + '%';
|
|
85
|
+
|
|
86
|
+
// set result to 0 when currentValues is 0
|
|
81
87
|
if (!currentValues) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
previous: previousValues || null
|
|
85
|
-
};
|
|
88
|
+
result = '--';
|
|
89
|
+
currentValues = 0;
|
|
86
90
|
}
|
|
91
|
+
|
|
92
|
+
// set result to -- when previousValues is 0
|
|
87
93
|
if (!previousValues) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
previous: null
|
|
91
|
-
};
|
|
94
|
+
result = '--';
|
|
95
|
+
previousValues = 0;
|
|
92
96
|
}
|
|
93
97
|
return {
|
|
94
98
|
latest: currentValues,
|
|
95
99
|
previous: previousValues,
|
|
96
|
-
result
|
|
97
|
-
type: currentValues
|
|
100
|
+
result,
|
|
101
|
+
type: currentValues >= previousValues ? 'up' : 'down'
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
export default calculator;
|
|
@@ -1425,11 +1425,27 @@ SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
|
+
|
|
1429
|
+
// normal case
|
|
1430
|
+
const res = Math.abs(compareValue - comparedValue) / comparedValue;
|
|
1431
|
+
let result = Number.parseFloat(res * 100).toFixed(2) + '%';
|
|
1432
|
+
|
|
1433
|
+
// set result to 0 when compareValue is 0
|
|
1434
|
+
if (!compareValue) {
|
|
1435
|
+
result = '--';
|
|
1436
|
+
compareValue = 0;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// set result to -- when comparedValue is 0
|
|
1440
|
+
if (!comparedValue) {
|
|
1441
|
+
result = '--';
|
|
1442
|
+
comparedValue = 0;
|
|
1443
|
+
}
|
|
1428
1444
|
return {
|
|
1429
1445
|
latest: compareValue,
|
|
1430
1446
|
previous: comparedValue,
|
|
1431
|
-
result
|
|
1432
|
-
type: compareValue
|
|
1447
|
+
result,
|
|
1448
|
+
type: compareValue >= comparedValue ? 'up' : 'down'
|
|
1433
1449
|
};
|
|
1434
1450
|
};
|
|
1435
1451
|
SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables, params) => {
|
|
@@ -1818,7 +1834,8 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1818
1834
|
groupbyColumn,
|
|
1819
1835
|
columnGroupbyColumn,
|
|
1820
1836
|
summaryColumn,
|
|
1821
|
-
chartTableColumns
|
|
1837
|
+
chartTableColumns,
|
|
1838
|
+
summaryColumnsWithMethod
|
|
1822
1839
|
});
|
|
1823
1840
|
return;
|
|
1824
1841
|
}
|
|
@@ -1841,7 +1858,8 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
|
1841
1858
|
groupbyColumn,
|
|
1842
1859
|
columnGroupbyColumn,
|
|
1843
1860
|
summaryColumn,
|
|
1844
|
-
chartTableColumns
|
|
1861
|
+
chartTableColumns,
|
|
1862
|
+
summaryColumnsWithMethod
|
|
1845
1863
|
});
|
|
1846
1864
|
};
|
|
1847
1865
|
SQLStatisticsUtils.calculateStaticChart = (chart, value, statisticalResult, callback) => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
|
|
2
2
|
import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn } from 'dtable-utils';
|
|
5
|
-
import { LinksUtils } from 'dtable-store';
|
|
4
|
+
import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn, isValidLink } from 'dtable-utils';
|
|
6
5
|
import dayjs from 'dayjs';
|
|
7
6
|
import cellFormatterFactory from '../components/cell-factory/cell-formatter-factory';
|
|
8
7
|
import SimpleCellFormatter from '../components/cell-factory/SimpleCellFormatter';
|
|
@@ -200,7 +199,7 @@ export const getFormattedCell = function (column, row) {
|
|
|
200
199
|
const {
|
|
201
200
|
data
|
|
202
201
|
} = column;
|
|
203
|
-
if (!
|
|
202
|
+
if (!isValidLink(data)) break;
|
|
204
203
|
|
|
205
204
|
// is default view: row data can get from formula row
|
|
206
205
|
// is archive view: row data can get form rowdata
|
|
@@ -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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
3
|
-
import { BaseUtils } from './chart-utils';
|
|
4
3
|
import { CHART_SUMMARY_TYPE } from '../constants';
|
|
4
|
+
import { BaseUtils } from './chart-utils';
|
|
5
5
|
dayjs.extend(quarterOfYear);
|
|
6
6
|
export function getCompareDate(dateGranularity) {
|
|
7
7
|
const currentDate = dayjs();
|
|
@@ -156,9 +156,6 @@ class BarGroup extends ChartComponent {
|
|
|
156
156
|
easing: 'easeLinear'
|
|
157
157
|
}
|
|
158
158
|
}).label(y_axis_show_value ? 'value' : false, {
|
|
159
|
-
content: data => {
|
|
160
|
-
return data.value;
|
|
161
|
-
},
|
|
162
159
|
style: {
|
|
163
160
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
164
161
|
fill: theme.labelColor,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { isNumber } from 'dtable-utils';
|
|
3
|
-
|
|
4
|
-
import { BaseUtils, isFunction } from '../../utils';
|
|
3
|
+
import { BaseUtils } from '../../utils';
|
|
5
4
|
import intl from '../../intl';
|
|
6
5
|
import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
|
|
7
6
|
class BasicNumericCard extends Component {
|
|
@@ -268,12 +268,6 @@ class Combination extends ChartComponent {
|
|
|
268
268
|
stroke: 0,
|
|
269
269
|
fillOpacity: 1
|
|
270
270
|
}).label(display_data ? 'value_right' : false, {
|
|
271
|
-
content: data => {
|
|
272
|
-
if (this.currentName) {
|
|
273
|
-
return data.name === this.currentName ? data.value_right : '';
|
|
274
|
-
}
|
|
275
|
-
return data.value_right;
|
|
276
|
-
},
|
|
277
271
|
style: {
|
|
278
272
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
279
273
|
fill: theme.labelColor,
|
|
@@ -25,7 +25,7 @@ class HorizontalBarGroup extends HorizontalComponent {
|
|
|
25
25
|
display_data
|
|
26
26
|
} = chart.config;
|
|
27
27
|
this.chartTopPadding = display_data ? 17 : 0;
|
|
28
|
-
const appendPadding = [this.chartTopPadding,
|
|
28
|
+
const appendPadding = [this.chartTopPadding, 30, 0, 0];
|
|
29
29
|
this.initChart(this.container, {
|
|
30
30
|
appendPadding
|
|
31
31
|
});
|
|
@@ -108,9 +108,6 @@ class HorizontalBarGroup extends HorizontalComponent {
|
|
|
108
108
|
easing: 'easeLinear'
|
|
109
109
|
}
|
|
110
110
|
}).label(display_data ? 'value' : false, {
|
|
111
|
-
content: data => {
|
|
112
|
-
return data.value;
|
|
113
|
-
},
|
|
114
111
|
style: {
|
|
115
112
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
116
113
|
fill: theme.labelColor,
|
|
@@ -58,6 +58,7 @@ const Wrapper = _ref => {
|
|
|
58
58
|
groupbyColumn,
|
|
59
59
|
columnGroupbyColumn,
|
|
60
60
|
summaryColumn,
|
|
61
|
+
summaryColumnsWithMethod,
|
|
61
62
|
chartTableColumns
|
|
62
63
|
} = data;
|
|
63
64
|
const {
|
|
@@ -73,6 +74,7 @@ const Wrapper = _ref => {
|
|
|
73
74
|
groupbyColumn,
|
|
74
75
|
columnGroupbyColumn,
|
|
75
76
|
summaryColumn,
|
|
77
|
+
summaryColumnsWithMethod,
|
|
76
78
|
globalTheme,
|
|
77
79
|
chartColorTheme,
|
|
78
80
|
toggleRecords: toggleStatisticRecordsDialog
|
|
@@ -85,8 +87,7 @@ const Wrapper = _ref => {
|
|
|
85
87
|
summaryColumns: summary_columns,
|
|
86
88
|
columnGroupbyColumn: columnGroupbyColumn,
|
|
87
89
|
summaryMethod: summary_method,
|
|
88
|
-
chartTableColumns: chartTableColumns
|
|
89
|
-
isCalculateByView: isCalculateByView
|
|
90
|
+
chartTableColumns: chartTableColumns
|
|
90
91
|
}));
|
|
91
92
|
}
|
|
92
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,
|
|
@@ -161,9 +163,11 @@
|
|
|
161
163
|
|
|
162
164
|
.sea-chart-pivot-table .pivot-table-header-summary-columns-container > div,
|
|
163
165
|
.sea-chart-pivot-table .pivot-cells-container > div {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
height: 100%;
|
|
167
|
+
width: 100%;
|
|
168
|
+
display: flex;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
align-items: center;
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
.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
|
|
@@ -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
|
})
|
|
@@ -81,19 +81,7 @@ class Trend extends Component {
|
|
|
81
81
|
color = '#34aa95';
|
|
82
82
|
icon = '\u2191';
|
|
83
83
|
}
|
|
84
|
-
let resultText = "".concat(Number.parseFloat(result * 100).toFixed(2), "%•").concat(conjunctions).concat(previous);
|
|
85
|
-
if (!previous) {
|
|
86
|
-
resultText = intl.get('Can_not_compare_with_{var}').replace('{var}', intl.get(conjunctions));
|
|
87
|
-
}
|
|
88
|
-
if (!previous) {
|
|
89
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
90
|
-
style: {
|
|
91
|
-
fontSize: "".concat(labelFontSize, "px")
|
|
92
|
-
}
|
|
93
|
-
}, resultText);
|
|
94
|
-
}
|
|
95
84
|
if (labelFontSize <= 12) {
|
|
96
|
-
if (!result && result !== 0) return '';
|
|
97
85
|
return /*#__PURE__*/React.createElement("span", {
|
|
98
86
|
style: {
|
|
99
87
|
fontSize: "".concat(labelFontSize, "px"),
|
|
@@ -116,7 +104,7 @@ class Trend extends Component {
|
|
|
116
104
|
style: {
|
|
117
105
|
color: "".concat(color)
|
|
118
106
|
}
|
|
119
|
-
}, result
|
|
107
|
+
}, result));
|
|
120
108
|
}
|
|
121
109
|
const resultContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
122
110
|
style: {
|
|
@@ -131,7 +119,7 @@ class Trend extends Component {
|
|
|
131
119
|
whiteSpace: 'nowrap',
|
|
132
120
|
marginRight: '16px'
|
|
133
121
|
}
|
|
134
|
-
},
|
|
122
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
135
123
|
style: {
|
|
136
124
|
flexShrink: '0',
|
|
137
125
|
flexBasis: 'auto',
|
|
@@ -151,7 +139,7 @@ class Trend extends Component {
|
|
|
151
139
|
color: color,
|
|
152
140
|
marginRight: '0px'
|
|
153
141
|
}
|
|
154
|
-
}, result
|
|
142
|
+
}, result)), /*#__PURE__*/React.createElement("span", {
|
|
155
143
|
style: {
|
|
156
144
|
color: labelFontColor,
|
|
157
145
|
fontWeight: labelFontWeight,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85-alpha.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"@seafile/seafile-calendar": "^0.0.24",
|
|
9
9
|
"classnames": "^2.3.2",
|
|
10
10
|
"dayjs": "1.10.7",
|
|
11
|
-
"dtable-store": "^4.3.18",
|
|
12
11
|
"is-hotkey": "0.2.0",
|
|
13
12
|
"lodash-es": "^4.17.21",
|
|
14
13
|
"rc-slider": "^10.5.0",
|
|
@@ -100,6 +99,7 @@
|
|
|
100
99
|
"css-minimizer-webpack-plugin": "5.0.1",
|
|
101
100
|
"dotenv": "6.2.0",
|
|
102
101
|
"dotenv-expand": "5.1.0",
|
|
102
|
+
"dtable-store": "~4.3.18",
|
|
103
103
|
"ejs": "3.1.8",
|
|
104
104
|
"eslint": "^6.8.0",
|
|
105
105
|
"eslint-config-react-app": "^5.0.2",
|