sea-chart 0.0.68-alpha.9 → 0.0.69
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/advance-bar-settings/data-settings.js +1 -2
- package/dist/settings/bar-settings/data-settings.js +1 -2
- package/dist/settings/table-settings/data-settings.js +6 -0
- package/dist/settings/widgets/group-by.js +1 -2
- package/dist/utils/chart-utils/base-utils.js +3 -26
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +4 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +127 -131
- package/dist/utils/column-utils.js +111 -126
- package/dist/view/index.css +1 -1
- package/dist/view/wrapper/index.js +2 -1
- package/dist/view/wrapper/table/index.css +9 -2
- package/dist/view/wrapper/table/two-dimension-table.js +24 -7
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@ import CommonDataSettings from '../widgets/common-data-settings';
|
|
|
5
5
|
import Divider from '../widgets/divider';
|
|
6
6
|
import GroupBy from '../widgets/group-by';
|
|
7
7
|
import YAxisGroupSettings from '../widgets/y-axis-group-settings';
|
|
8
|
-
import { islinkDateFormula } from '../../utils/column-utils';
|
|
9
8
|
import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
|
|
10
9
|
import intl from '../../intl';
|
|
11
10
|
const DataSettings = _ref => {
|
|
@@ -37,7 +36,7 @@ const DataSettings = _ref => {
|
|
|
37
36
|
update['x_axis_date_granularity'] = null;
|
|
38
37
|
update['x_axis_geolocation_granularity'] = null;
|
|
39
38
|
} else {
|
|
40
|
-
if (DATE_COLUMN_OPTIONS.includes(type)
|
|
39
|
+
if (DATE_COLUMN_OPTIONS.includes(type)) {
|
|
41
40
|
update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
|
|
42
41
|
update['x_axis_geolocation_granularity'] = null;
|
|
43
42
|
} else if (type === CellType.GEOLOCATION) {
|
|
@@ -7,7 +7,6 @@ import Divider from '../widgets/divider';
|
|
|
7
7
|
import GroupBy from '../widgets/group-by';
|
|
8
8
|
import BasicSummary from '../widgets/basic-summary';
|
|
9
9
|
import DataSort from '../widgets/data-sort';
|
|
10
|
-
import { islinkDateFormula } from '../../utils/column-utils';
|
|
11
10
|
import { CHART_SUMMARY_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, CHART_SUMMARY_TYPES, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_TYPE } from '../../constants';
|
|
12
11
|
const DataSettings = _ref => {
|
|
13
12
|
let {
|
|
@@ -38,7 +37,7 @@ const DataSettings = _ref => {
|
|
|
38
37
|
update['x_axis_date_granularity'] = null;
|
|
39
38
|
update['x_axis_geolocation_granularity'] = null;
|
|
40
39
|
} else {
|
|
41
|
-
if (DATE_COLUMN_OPTIONS.includes(type)
|
|
40
|
+
if (DATE_COLUMN_OPTIONS.includes(type)) {
|
|
42
41
|
update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
|
|
43
42
|
update['x_axis_geolocation_granularity'] = null;
|
|
44
43
|
} else if (type === CellType.GEOLOCATION) {
|
|
@@ -254,6 +254,12 @@ const DataSettings = _ref => {
|
|
|
254
254
|
summary_type = CHART_SUMMARY_TYPE.ADVANCED;
|
|
255
255
|
column_groupby_multiple_numeric_column = true;
|
|
256
256
|
summary_columns = [];
|
|
257
|
+
if (numericColumns && numericColumns[0]) {
|
|
258
|
+
summary_columns.push({
|
|
259
|
+
column_key: numericColumns[0].key,
|
|
260
|
+
summary_method: BaseUtils.isDateSummaryColumn(numericColumns[0]) ? CHART_DATE_SUMMARY_CALCULATION_METHOD[0] : CHART_SUMMARY_CALCULATION_METHOD[0]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
257
263
|
// column_groupby_column_key = null;
|
|
258
264
|
// column_groupby_date_granularity = null;
|
|
259
265
|
// column_groupby_geolocation_granularity = null;
|
|
@@ -4,7 +4,6 @@ import React, { Component } from 'react';
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { Label, FormGroup } from 'reactstrap';
|
|
6
6
|
import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
7
|
-
import { islinkDateFormula } from '../../utils/column-utils';
|
|
8
7
|
import { CHART_SUPPORT_COLUMNS, DATE_GRANULATES, GEOLOCATION_GRANULATES, CHART_SUMMARY_SHOW, GEOLOCATION_FORMAT_MAP, CHART_TYPE, TIME_COLUMN_LIST, COMPLETENESS_GROUPBY_SUPPORTED_COLUMN_TYPE, NUMBERIC_COLUMN_TYPE, MIRROR_COLUMN_LIST } from '../../constants';
|
|
9
8
|
import intl from '../../intl';
|
|
10
9
|
class GroupBy extends Component {
|
|
@@ -177,7 +176,7 @@ class GroupBy extends Component {
|
|
|
177
176
|
const {
|
|
178
177
|
type: groupbyColumnType
|
|
179
178
|
} = groupbyColumn;
|
|
180
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
179
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && this.geolocationGranulatesOptions.length > 0 && this.renderGroupbyGeolocationGranulates());
|
|
181
180
|
};
|
|
182
181
|
this.dateGranulatesOptions = this.generatorGranulatesOptions(DATE_GRANULATES);
|
|
183
182
|
this.initOptions(_props);
|
|
@@ -1052,16 +1052,9 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1052
1052
|
if (!formulaRow) return '';
|
|
1053
1053
|
let formulaCellValue = formulaRow[key];
|
|
1054
1054
|
let {
|
|
1055
|
-
result_type
|
|
1056
|
-
array_type
|
|
1055
|
+
result_type
|
|
1057
1056
|
} = data || {};
|
|
1058
1057
|
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1059
|
-
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1060
|
-
const dateCellValue = formulaCellValue[0];
|
|
1061
|
-
if (!dateGranularity) return getDateDisplayString(dateCellValue);
|
|
1062
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR');
|
|
1063
|
-
return DateUtils.getDateByGranularity(dateCellValue, dateGranularity);
|
|
1064
|
-
}
|
|
1065
1058
|
return getFormulaDisplayString(formulaCellValue, data, {
|
|
1066
1059
|
tables: value.tables
|
|
1067
1060
|
}) || null;
|
|
@@ -1379,26 +1372,10 @@ BaseUtils.mergePivotTableSameCollaborator = pivot_rows => {
|
|
|
1379
1372
|
new_pivot_rows.push({
|
|
1380
1373
|
...item
|
|
1381
1374
|
});
|
|
1375
|
+
} else {
|
|
1376
|
+
new_pivot_rows.push(item);
|
|
1382
1377
|
}
|
|
1383
1378
|
});
|
|
1384
1379
|
return new_pivot_rows;
|
|
1385
1380
|
};
|
|
1386
|
-
BaseUtils.getDateGranularityByType = chart => {
|
|
1387
|
-
const {
|
|
1388
|
-
type
|
|
1389
|
-
} = chart;
|
|
1390
|
-
if ([CHART_TYPE.AREA_GROUP, CHART_TYPE.AREA, CHART_TYPE.BAR, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.COMBINATION, CHART_TYPE.LINE_GROUP, CHART_TYPE.LINE].includes(type)) {
|
|
1391
|
-
return chart['x_axis_date_granularity'];
|
|
1392
|
-
}
|
|
1393
|
-
if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
|
|
1394
|
-
return chart['date_granularity'];
|
|
1395
|
-
}
|
|
1396
|
-
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1397
|
-
return chart['vertical_axis_date_granularity'];
|
|
1398
|
-
}
|
|
1399
|
-
if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1400
|
-
return chart['groupby_date_granularity'];
|
|
1401
|
-
}
|
|
1402
|
-
return null;
|
|
1403
|
-
};
|
|
1404
1381
|
export default BaseUtils;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { CellType, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
3
3
|
import { CHART_SUMMARY_TYPE, CHART_TYPE, Y_AXIS_TYPE_PREFIX } from '../../../constants';
|
|
4
|
-
import { getColorFromSingleSelectColumn
|
|
4
|
+
import { getColorFromSingleSelectColumn } from '../../column-utils';
|
|
5
5
|
import { isArrayCellValue } from '../../cell-value-utils';
|
|
6
6
|
import { getFormattedLabel, isValidRow } from '../../row-utils';
|
|
7
7
|
import { fixGeoGranularity } from '../../map';
|
|
@@ -67,7 +67,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
67
67
|
const {
|
|
68
68
|
type: groupby_column_type
|
|
69
69
|
} = groupbyColumn;
|
|
70
|
-
if (
|
|
70
|
+
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
71
71
|
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
72
72
|
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
73
73
|
groupby_date_granularity = CHART_SUMMARY_TYPE.DAY;
|
|
@@ -161,7 +161,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
161
161
|
const {
|
|
162
162
|
type: groupby_column_type
|
|
163
163
|
} = groupbyColumn;
|
|
164
|
-
if (
|
|
164
|
+
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
165
165
|
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
166
166
|
}
|
|
167
167
|
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
@@ -461,7 +461,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
461
461
|
} = groupbyColumn;
|
|
462
462
|
let groupbyDateGranularity = x_axis_date_granularity;
|
|
463
463
|
let groupbyGeolocationGranularity = x_axis_geolocation_granularity;
|
|
464
|
-
if (
|
|
464
|
+
if (DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && !groupbyDateGranularity) {
|
|
465
465
|
groupbyDateGranularity = CHART_SUMMARY_TYPE.MONTH;
|
|
466
466
|
}
|
|
467
467
|
if (groupbyColumnType === CellType.GEOLOCATION && !groupbyGeolocationGranularity) {
|
|
@@ -14,8 +14,7 @@ import BaseUtils from './base-utils';
|
|
|
14
14
|
class SQLStatisticsUtils {}
|
|
15
15
|
_SQLStatisticsUtils = SQLStatisticsUtils;
|
|
16
16
|
SQLStatisticsUtils.dataSources = 'sql_statistics';
|
|
17
|
-
SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column,
|
|
18
|
-
const dateGranularity = BaseUtils.getDateGranularityByType(chart);
|
|
17
|
+
SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables, dateGranularity) => {
|
|
19
18
|
const collaborators = context.getCollaboratorsFromCache();
|
|
20
19
|
const {
|
|
21
20
|
type,
|
|
@@ -74,15 +73,9 @@ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, chart) => {
|
|
|
74
73
|
case CellType.FORMULA:
|
|
75
74
|
case CellType.LINK_FORMULA:
|
|
76
75
|
{
|
|
77
|
-
const validValue = getFormulaDisplayString(cellValue, data
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} = data || {};
|
|
81
|
-
if (array_type === 'date' && (cellValue === null || cellValue === void 0 ? void 0 : cellValue.length) === 1) {
|
|
82
|
-
if (!dateGranularity) return validValue;
|
|
83
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(validValue, 'QUARTAR');
|
|
84
|
-
return DateUtils.getDateByGranularity(validValue, dateGranularity);
|
|
85
|
-
}
|
|
76
|
+
const validValue = getFormulaDisplayString(cellValue, data, {
|
|
77
|
+
tables
|
|
78
|
+
});
|
|
86
79
|
if (!validValue && validValue !== 0) return null;
|
|
87
80
|
return validValue;
|
|
88
81
|
}
|
|
@@ -235,6 +228,112 @@ SQLStatisticsUtils.getGroupData = (result, groupColumn) => {
|
|
|
235
228
|
}
|
|
236
229
|
return groupList;
|
|
237
230
|
};
|
|
231
|
+
SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
232
|
+
const {
|
|
233
|
+
groupbyColumn
|
|
234
|
+
} = columnMap;
|
|
235
|
+
const {
|
|
236
|
+
summary_type
|
|
237
|
+
} = chart.config;
|
|
238
|
+
const {
|
|
239
|
+
sqlGroupbyColumnKey,
|
|
240
|
+
sqlSummaryColumnKey
|
|
241
|
+
} = chartSQLMap;
|
|
242
|
+
let pivot_columns = [];
|
|
243
|
+
let pivot_rows = [];
|
|
244
|
+
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
245
|
+
let newSqlRows = sqlRows;
|
|
246
|
+
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
247
|
+
newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
248
|
+
}
|
|
249
|
+
if (isCount) {
|
|
250
|
+
let allTotal = 0;
|
|
251
|
+
newSqlRows.forEach(row => {
|
|
252
|
+
const total = row[sqlSummaryColumnKey] || 0;
|
|
253
|
+
allTotal += total;
|
|
254
|
+
pivot_rows.push({
|
|
255
|
+
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
256
|
+
rows: [],
|
|
257
|
+
total: {
|
|
258
|
+
total
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
pivot_columns,
|
|
264
|
+
pivot_rows: pivot_rows,
|
|
265
|
+
pivot_columns_total: {
|
|
266
|
+
total: allTotal
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
const {
|
|
271
|
+
summarySQLColumnName2ColumnKey,
|
|
272
|
+
summaryTableColumnKey2Column,
|
|
273
|
+
summaryTableColumnKey2Method
|
|
274
|
+
} = chartSQLMap;
|
|
275
|
+
const summaryColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
|
|
276
|
+
const sqlSummaryColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
277
|
+
let totalTemplate = {};
|
|
278
|
+
Object.values(summaryColumnKeys).forEach(key => {
|
|
279
|
+
const summaryMethod = summaryTableColumnKey2Method[key];
|
|
280
|
+
totalTemplate[key] = BaseUtils.initTotal(summaryMethod);
|
|
281
|
+
pivot_columns.push({
|
|
282
|
+
key
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
let allTotal = {
|
|
286
|
+
...totalTemplate
|
|
287
|
+
};
|
|
288
|
+
newSqlRows.forEach(row => {
|
|
289
|
+
let rowTotal = {
|
|
290
|
+
...totalTemplate
|
|
291
|
+
};
|
|
292
|
+
sqlSummaryColumnKeys.forEach(key => {
|
|
293
|
+
let columnKey = summarySQLColumnName2ColumnKey[key];
|
|
294
|
+
let summaryColumn = summaryTableColumnKey2Column[columnKey];
|
|
295
|
+
const summaryMethod = summaryTableColumnKey2Method[columnKey];
|
|
296
|
+
let value = row[key] || BaseUtils.initTotal(summaryMethod);
|
|
297
|
+
allTotal[columnKey] = BaseUtils.getSummaryValue({
|
|
298
|
+
summaryColumn,
|
|
299
|
+
summaryMethod
|
|
300
|
+
}, allTotal[columnKey], value);
|
|
301
|
+
if (BaseUtils.isDateSummaryColumn(summaryColumn)) {
|
|
302
|
+
rowTotal[columnKey] = value;
|
|
303
|
+
} else if (BaseUtils.isNumericSummaryColumn(summaryColumn)) {
|
|
304
|
+
rowTotal[columnKey] = rowTotal[columnKey] + value;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
pivot_rows.push({
|
|
308
|
+
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
309
|
+
rows: [row],
|
|
310
|
+
total: rowTotal
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
if (pivot_columns.length < 2) {
|
|
314
|
+
const pivot_column = pivot_columns[0];
|
|
315
|
+
const {
|
|
316
|
+
key
|
|
317
|
+
} = pivot_column;
|
|
318
|
+
pivot_rows.forEach(row => {
|
|
319
|
+
row.total = {
|
|
320
|
+
...row.total,
|
|
321
|
+
total: row.total[key]
|
|
322
|
+
};
|
|
323
|
+
});
|
|
324
|
+
allTotal = {
|
|
325
|
+
...allTotal,
|
|
326
|
+
total: allTotal[key]
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
330
|
+
return {
|
|
331
|
+
pivot_columns,
|
|
332
|
+
pivot_rows,
|
|
333
|
+
pivot_columns_total: allTotal,
|
|
334
|
+
dimensions: TABLE_DIMENSIONS.ONE
|
|
335
|
+
};
|
|
336
|
+
};
|
|
238
337
|
SQLStatisticsUtils.updateTwoDimensionColumns = (pivot_columns, key, _ref) => {
|
|
239
338
|
let {
|
|
240
339
|
isIncludeEmpty,
|
|
@@ -450,112 +549,6 @@ pivot_table_total, chart) => {
|
|
|
450
549
|
});
|
|
451
550
|
return [pivot_columns_total, pivot_table_total];
|
|
452
551
|
};
|
|
453
|
-
SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
454
|
-
const {
|
|
455
|
-
groupbyColumn
|
|
456
|
-
} = columnMap;
|
|
457
|
-
const {
|
|
458
|
-
summary_type
|
|
459
|
-
} = chart.config;
|
|
460
|
-
const {
|
|
461
|
-
sqlGroupbyColumnKey,
|
|
462
|
-
sqlSummaryColumnKey
|
|
463
|
-
} = chartSQLMap;
|
|
464
|
-
let pivot_columns = [];
|
|
465
|
-
let pivot_rows = [];
|
|
466
|
-
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
467
|
-
let newSqlRows = sqlRows;
|
|
468
|
-
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
469
|
-
newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
470
|
-
}
|
|
471
|
-
if (isCount) {
|
|
472
|
-
let allTotal = 0;
|
|
473
|
-
newSqlRows.forEach(row => {
|
|
474
|
-
const total = row[sqlSummaryColumnKey] || 0;
|
|
475
|
-
allTotal += total;
|
|
476
|
-
pivot_rows.push({
|
|
477
|
-
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, chart.config),
|
|
478
|
-
rows: [],
|
|
479
|
-
total: {
|
|
480
|
-
total
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
return {
|
|
485
|
-
pivot_columns,
|
|
486
|
-
pivot_rows: pivot_rows,
|
|
487
|
-
pivot_columns_total: {
|
|
488
|
-
total: allTotal
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
const {
|
|
493
|
-
summarySQLColumnName2ColumnKey,
|
|
494
|
-
summaryTableColumnKey2Column,
|
|
495
|
-
summaryTableColumnKey2Method
|
|
496
|
-
} = chartSQLMap;
|
|
497
|
-
const summaryColumnKeys = Object.values(summarySQLColumnName2ColumnKey);
|
|
498
|
-
const sqlSummaryColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
499
|
-
let totalTemplate = {};
|
|
500
|
-
Object.values(summaryColumnKeys).forEach(key => {
|
|
501
|
-
const summaryMethod = summaryTableColumnKey2Method[key];
|
|
502
|
-
totalTemplate[key] = BaseUtils.initTotal(summaryMethod);
|
|
503
|
-
pivot_columns.push({
|
|
504
|
-
key
|
|
505
|
-
});
|
|
506
|
-
});
|
|
507
|
-
let allTotal = {
|
|
508
|
-
...totalTemplate
|
|
509
|
-
};
|
|
510
|
-
newSqlRows.forEach(row => {
|
|
511
|
-
let rowTotal = {
|
|
512
|
-
...totalTemplate
|
|
513
|
-
};
|
|
514
|
-
sqlSummaryColumnKeys.forEach(key => {
|
|
515
|
-
let columnKey = summarySQLColumnName2ColumnKey[key];
|
|
516
|
-
let summaryColumn = summaryTableColumnKey2Column[columnKey];
|
|
517
|
-
const summaryMethod = summaryTableColumnKey2Method[columnKey];
|
|
518
|
-
let value = row[key] || BaseUtils.initTotal(summaryMethod);
|
|
519
|
-
allTotal[columnKey] = BaseUtils.getSummaryValue({
|
|
520
|
-
summaryColumn,
|
|
521
|
-
summaryMethod
|
|
522
|
-
}, allTotal[columnKey], value);
|
|
523
|
-
if (BaseUtils.isDateSummaryColumn(summaryColumn)) {
|
|
524
|
-
rowTotal[columnKey] = value;
|
|
525
|
-
} else if (BaseUtils.isNumericSummaryColumn(summaryColumn)) {
|
|
526
|
-
rowTotal[columnKey] = rowTotal[columnKey] + value;
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
pivot_rows.push({
|
|
530
|
-
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, chart.config),
|
|
531
|
-
rows: [row],
|
|
532
|
-
total: rowTotal
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
if (pivot_columns.length < 2) {
|
|
536
|
-
const pivot_column = pivot_columns[0];
|
|
537
|
-
const {
|
|
538
|
-
key
|
|
539
|
-
} = pivot_column;
|
|
540
|
-
pivot_rows.forEach(row => {
|
|
541
|
-
row.total = {
|
|
542
|
-
...row.total,
|
|
543
|
-
total: row.total[key]
|
|
544
|
-
};
|
|
545
|
-
});
|
|
546
|
-
allTotal = {
|
|
547
|
-
...allTotal,
|
|
548
|
-
total: allTotal[key]
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
552
|
-
return {
|
|
553
|
-
pivot_columns,
|
|
554
|
-
pivot_rows,
|
|
555
|
-
pivot_columns_total: allTotal,
|
|
556
|
-
dimensions: TABLE_DIMENSIONS.ONE
|
|
557
|
-
};
|
|
558
|
-
};
|
|
559
552
|
SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
560
553
|
const {
|
|
561
554
|
groupbyColumn,
|
|
@@ -596,14 +589,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
596
589
|
if (BaseUtils.isCollaborator(groupbyColumn)) {
|
|
597
590
|
groupbyColumnCellValueKey = groupbyColumnCellValue || [];
|
|
598
591
|
} else {
|
|
599
|
-
groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn,
|
|
592
|
+
groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
600
593
|
}
|
|
601
594
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
602
595
|
let columnGroupbyColumnCellValueKey;
|
|
603
596
|
if (BaseUtils.isCollaborator(columnGroupbyColumn)) {
|
|
604
597
|
columnGroupbyColumnCellValueKey = columnGroupbyColumnCellValue || [];
|
|
605
598
|
} else {
|
|
606
|
-
columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn,
|
|
599
|
+
columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
607
600
|
}
|
|
608
601
|
if (BaseUtils.isValidCellValue(columnGroupbyColumnCellValue, groupby_include_empty_cells)) {
|
|
609
602
|
_SQLStatisticsUtils.updateTwoDimensionColumns(pivot_columns, columnGroupbyColumnCellValueKey, {
|
|
@@ -653,7 +646,9 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
653
646
|
pivot_table_total, chart);
|
|
654
647
|
BaseUtils.sortCharts(pivot_rows, groupbyColumn, 'name');
|
|
655
648
|
BaseUtils.sortCharts(pivot_columns, columnGroupbyColumn, 'key');
|
|
656
|
-
|
|
649
|
+
if ((groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.COLLABORATOR) {
|
|
650
|
+
pivot_rows = BaseUtils.mergePivotTableSameCollaborator(pivot_rows);
|
|
651
|
+
}
|
|
657
652
|
const summary_columns = [summaryColumn, ...summaryColumnsWithMethod.map(item => item.column)];
|
|
658
653
|
return {
|
|
659
654
|
summary_columns,
|
|
@@ -665,7 +660,7 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
665
660
|
isSingleNumericColumn
|
|
666
661
|
};
|
|
667
662
|
};
|
|
668
|
-
SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap) => {
|
|
663
|
+
SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
669
664
|
const {
|
|
670
665
|
config
|
|
671
666
|
} = chart;
|
|
@@ -693,7 +688,7 @@ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap
|
|
|
693
688
|
formatted_value = getFormattedValue(cellValue, y_axis_summary_column_key, y_axis_summary_method);
|
|
694
689
|
}
|
|
695
690
|
if (BaseUtils.isValidCellValue(cellValue)) {
|
|
696
|
-
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn,
|
|
691
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
697
692
|
if (isGroupbyColumnDataAsAnArray) {
|
|
698
693
|
if (!Array.isArray(key) || key.length === 0) {
|
|
699
694
|
let itemIdx = result.findIndex(v => v.name === null);
|
|
@@ -807,7 +802,7 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
|
|
|
807
802
|
let result = [];
|
|
808
803
|
sqlRows.forEach(row => {
|
|
809
804
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
810
|
-
const label = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn,
|
|
805
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
811
806
|
const isEmpty = !label;
|
|
812
807
|
const groupItems = [];
|
|
813
808
|
summaryMethods.forEach((summaryMethod, index) => {
|
|
@@ -848,7 +843,8 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
848
843
|
x_axis_compared_date_range_end,
|
|
849
844
|
y_axis_summary_type,
|
|
850
845
|
y_axis_summary_method,
|
|
851
|
-
display_increase
|
|
846
|
+
display_increase,
|
|
847
|
+
x_axis_date_granularity
|
|
852
848
|
} = config;
|
|
853
849
|
const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
|
|
854
850
|
const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
|
|
@@ -857,7 +853,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
857
853
|
const isAdvanced = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
858
854
|
sqlRows.forEach(item => {
|
|
859
855
|
const name = item[sqlGroupbyColumnKey];
|
|
860
|
-
const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn,
|
|
856
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, tables, x_axis_date_granularity);
|
|
861
857
|
const value = item[sqlSummaryColumnKey];
|
|
862
858
|
if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
|
|
863
859
|
const currentValue = dateRangeResult.get(label);
|
|
@@ -981,7 +977,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
981
977
|
sqlRows.forEach(row => {
|
|
982
978
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
983
979
|
const summaryValue = row[sqlSummaryColumnKey];
|
|
984
|
-
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn,
|
|
980
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
985
981
|
let valueLeft = row[sqlLeftSummaryColumnKey] || 0;
|
|
986
982
|
let valueRight = row[sqlRightSummaryColumnKey] || 0;
|
|
987
983
|
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
@@ -1084,7 +1080,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
1084
1080
|
});
|
|
1085
1081
|
sqlRows.forEach((item, index) => {
|
|
1086
1082
|
const cellValue = item[sqlGroupbyColumnKey];
|
|
1087
|
-
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn,
|
|
1083
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
1088
1084
|
let valueRight = item[sqlRightSummaryColumnKey] || 0;
|
|
1089
1085
|
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1090
1086
|
valueRight = BaseUtils.getPrecisionNumber(valueRight, rightSummaryColumn.data);
|
|
@@ -1189,10 +1185,10 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
|
|
|
1189
1185
|
const isColumnGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
1190
1186
|
sqlRows.forEach(row => {
|
|
1191
1187
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1192
|
-
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn,
|
|
1188
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1193
1189
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1194
1190
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
1195
|
-
const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn,
|
|
1191
|
+
const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
1196
1192
|
const count = row[sqlSummaryColumnKey];
|
|
1197
1193
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1198
1194
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
@@ -1241,7 +1237,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1241
1237
|
const isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type];
|
|
1242
1238
|
sqlRows.forEach(row => {
|
|
1243
1239
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1244
|
-
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn,
|
|
1240
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1245
1241
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1246
1242
|
Object.keys(summaryColumns).forEach(sqlSummaryColumnName => {
|
|
1247
1243
|
const {
|
|
@@ -1347,7 +1343,7 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQ
|
|
|
1347
1343
|
const groupData0 = groupData[0] || {};
|
|
1348
1344
|
const groupData1 = groupData[1] || {};
|
|
1349
1345
|
sqlRows.forEach(item => {
|
|
1350
|
-
const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn,
|
|
1346
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn, tables);
|
|
1351
1347
|
const groupValue = item[group_column_key];
|
|
1352
1348
|
const equal2GroupData0 = groupData0.id === groupValue;
|
|
1353
1349
|
const equal2GroupData1 = groupData1.id === groupValue;
|
|
@@ -5,7 +5,21 @@ import { MIRROR_COLUMN_LIST, CHART_SUMMARY_TYPE } from '../constants';
|
|
|
5
5
|
import { getClientFormulaDisplayString } from './cell-format-utils';
|
|
6
6
|
import { BaseUtils } from './chart-utils';
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// get dtable column options
|
|
9
|
+
export function getColumnOptions(columns) {
|
|
10
|
+
return columns.map(column => {
|
|
11
|
+
return {
|
|
12
|
+
value: column,
|
|
13
|
+
label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
14
|
+
className: "sea-chart-column-icon"
|
|
15
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
16
|
+
className: COLUMNS_ICON_CONFIG[column.type]
|
|
17
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
18
|
+
className: 'select-module select-module-name ml-0'
|
|
19
|
+
}, column.name))
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
9
23
|
export const isMapColumn = column => {
|
|
10
24
|
if (!column) return false;
|
|
11
25
|
const {
|
|
@@ -76,6 +90,11 @@ export const isWorldMapColumn = column => {
|
|
|
76
90
|
}
|
|
77
91
|
return false;
|
|
78
92
|
};
|
|
93
|
+
export const getDateColumnFormat = column => {
|
|
94
|
+
const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
|
|
95
|
+
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
96
|
+
return format;
|
|
97
|
+
};
|
|
79
98
|
export const isCheckboxColumn = column => {
|
|
80
99
|
let {
|
|
81
100
|
type,
|
|
@@ -93,6 +112,33 @@ export const isCheckboxColumn = column => {
|
|
|
93
112
|
}
|
|
94
113
|
return type === CellType.CHECKBOX;
|
|
95
114
|
};
|
|
115
|
+
export const getColumnByKey = (columnKey, columns) => {
|
|
116
|
+
if (!columnKey || !Array.isArray(columns)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return columns.find(column => column.key === columnKey);
|
|
120
|
+
};
|
|
121
|
+
export const getColumnByName = (columnName, columns) => {
|
|
122
|
+
if (!columnName || !Array.isArray(columns)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return columns.find(column => column.name === columnName);
|
|
126
|
+
};
|
|
127
|
+
export const getColumnByType = (columnType, columns) => {
|
|
128
|
+
if (!columnType || !Array.isArray(columns)) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return columns.find(column => column.type === columnType);
|
|
132
|
+
};
|
|
133
|
+
export const getColumnByIndex = (index, columns) => {
|
|
134
|
+
if (Array.isArray(columns)) {
|
|
135
|
+
return columns[index];
|
|
136
|
+
}
|
|
137
|
+
if (typeof Immutable !== 'undefined') {
|
|
138
|
+
return columns.get(index);
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
96
142
|
export const isNameColumn = column => {
|
|
97
143
|
return column.key === '0000';
|
|
98
144
|
};
|
|
@@ -113,10 +159,69 @@ export const isUrlColumn = column => {
|
|
|
113
159
|
}
|
|
114
160
|
return type === CellType.URL;
|
|
115
161
|
};
|
|
162
|
+
export const getLinkColumns = columns => {
|
|
163
|
+
if (!columns) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
return columns.filter(column => column.type === CellType.LINK && column.data);
|
|
167
|
+
};
|
|
168
|
+
export const calculateFormulaRows = (rows, columns) => {
|
|
169
|
+
const COMPUTED_COLUMN_TYPES = [CellType.FORMULA, CellType.LINK_FORMULA, CellType.LINK];
|
|
170
|
+
const formulaColumns = columns.filter(column => COMPUTED_COLUMN_TYPES.includes(column.type));
|
|
171
|
+
let formula_rows = {};
|
|
172
|
+
if (formulaColumns.length > 0) {
|
|
173
|
+
rows.forEach(row => {
|
|
174
|
+
let formulaRow = {};
|
|
175
|
+
formulaColumns.forEach(column => formulaRow[column.key] = row[column.key]);
|
|
176
|
+
formula_rows[row._id] = formulaRow;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return formula_rows;
|
|
180
|
+
};
|
|
181
|
+
export const handleCascadeColumn = function (optionValue, columnKey, columns, row) {
|
|
182
|
+
let updated = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
183
|
+
let processedColumns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new Set();
|
|
184
|
+
// This column has already been processed, avoid circular dependency.
|
|
185
|
+
if (!Array.isArray(columns) || processedColumns.has(columnKey)) {
|
|
186
|
+
return updated;
|
|
187
|
+
}
|
|
188
|
+
processedColumns.add(columnKey);
|
|
189
|
+
const singleSelectColumns = columns.filter(column => column.type === CellType.SINGLE_SELECT);
|
|
190
|
+
for (let i = 0; i < singleSelectColumns.length; i++) {
|
|
191
|
+
const singleSelectColumn = singleSelectColumns[i];
|
|
192
|
+
const {
|
|
193
|
+
data: {
|
|
194
|
+
cascade_column_key,
|
|
195
|
+
cascade_settings
|
|
196
|
+
}
|
|
197
|
+
} = singleSelectColumn;
|
|
198
|
+
if (cascade_column_key === columnKey) {
|
|
199
|
+
const {
|
|
200
|
+
key: childColumnKey
|
|
201
|
+
} = singleSelectColumn;
|
|
202
|
+
const childColumnOptions = cascade_settings[optionValue];
|
|
203
|
+
const childColumnCellValue = row[childColumnKey];
|
|
204
|
+
const cellValueInOptions = childColumnOptions && childColumnOptions.includes(childColumnCellValue);
|
|
205
|
+
if (!cellValueInOptions) {
|
|
206
|
+
updated[childColumnKey] = '';
|
|
207
|
+
handleCascadeColumn('', childColumnKey, columns, row, updated, processedColumns);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return updated;
|
|
212
|
+
};
|
|
116
213
|
export const isFrozen = column => {
|
|
117
214
|
if (!column) return false;
|
|
118
215
|
return column.frozen === true;
|
|
119
216
|
};
|
|
217
|
+
export const findLastFrozenColumnIndex = columns => {
|
|
218
|
+
for (let i = 0; i < columns.length; i++) {
|
|
219
|
+
if (isFrozen(columns[i])) {
|
|
220
|
+
return i;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return -1;
|
|
224
|
+
};
|
|
120
225
|
export const isStatisticMapColumn = column => {
|
|
121
226
|
if (!column) return false;
|
|
122
227
|
const {
|
|
@@ -191,73 +296,6 @@ export const isStatisticMirrorColumn = column => {
|
|
|
191
296
|
if (!column) return false;
|
|
192
297
|
return MIRROR_COLUMN_LIST.includes(column.type);
|
|
193
298
|
};
|
|
194
|
-
export const islinkDateFormula = column => {
|
|
195
|
-
if (column) {
|
|
196
|
-
const {
|
|
197
|
-
type,
|
|
198
|
-
data
|
|
199
|
-
} = column;
|
|
200
|
-
const {
|
|
201
|
-
array_type
|
|
202
|
-
} = data || {};
|
|
203
|
-
if (type === 'link-formula' && array_type === 'date') return true;
|
|
204
|
-
}
|
|
205
|
-
return false;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// get
|
|
209
|
-
export function getColumnOptions(columns) {
|
|
210
|
-
return columns.map(column => {
|
|
211
|
-
return {
|
|
212
|
-
value: column,
|
|
213
|
-
label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
214
|
-
className: "sea-chart-column-icon"
|
|
215
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
216
|
-
className: COLUMNS_ICON_CONFIG[column.type]
|
|
217
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
218
|
-
className: 'select-module select-module-name ml-0'
|
|
219
|
-
}, column.name))
|
|
220
|
-
};
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
export const getDateColumnFormat = column => {
|
|
224
|
-
const format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
|
|
225
|
-
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
226
|
-
return format;
|
|
227
|
-
};
|
|
228
|
-
export const getColumnByKey = (columnKey, columns) => {
|
|
229
|
-
if (!columnKey || !Array.isArray(columns)) {
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
return columns.find(column => column.key === columnKey);
|
|
233
|
-
};
|
|
234
|
-
export const getColumnByName = (columnName, columns) => {
|
|
235
|
-
if (!columnName || !Array.isArray(columns)) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
return columns.find(column => column.name === columnName);
|
|
239
|
-
};
|
|
240
|
-
export const getColumnByType = (columnType, columns) => {
|
|
241
|
-
if (!columnType || !Array.isArray(columns)) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
return columns.find(column => column.type === columnType);
|
|
245
|
-
};
|
|
246
|
-
export const getColumnByIndex = (index, columns) => {
|
|
247
|
-
if (Array.isArray(columns)) {
|
|
248
|
-
return columns[index];
|
|
249
|
-
}
|
|
250
|
-
if (typeof Immutable !== 'undefined') {
|
|
251
|
-
return columns.get(index);
|
|
252
|
-
}
|
|
253
|
-
return null;
|
|
254
|
-
};
|
|
255
|
-
export const getLinkColumns = columns => {
|
|
256
|
-
if (!columns) {
|
|
257
|
-
return [];
|
|
258
|
-
}
|
|
259
|
-
return columns.filter(column => column.type === CellType.LINK && column.data);
|
|
260
|
-
};
|
|
261
299
|
export const getColorFromSingleSelectColumn = (column, target) => {
|
|
262
300
|
let {
|
|
263
301
|
type: columnType,
|
|
@@ -406,12 +444,6 @@ export const getSqlGroup = (column, groupBy) => {
|
|
|
406
444
|
}
|
|
407
445
|
return validColumnName;
|
|
408
446
|
};
|
|
409
|
-
export function getSelectColumnOptions(column) {
|
|
410
|
-
if (!column || !column.data || !Array.isArray(column.data.options)) {
|
|
411
|
-
return [];
|
|
412
|
-
}
|
|
413
|
-
return column.data.options;
|
|
414
|
-
}
|
|
415
447
|
|
|
416
448
|
// for stacked bar, stacked horizontal bar
|
|
417
449
|
export const sortDataByGroupSum = (data, sortType) => {
|
|
@@ -441,56 +473,9 @@ export const formatNumericValue = function (value) {
|
|
|
441
473
|
value = value || 0;
|
|
442
474
|
return parseFloat(value.toFixed(precision));
|
|
443
475
|
};
|
|
444
|
-
export
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
let formula_rows = {};
|
|
448
|
-
if (formulaColumns.length > 0) {
|
|
449
|
-
rows.forEach(row => {
|
|
450
|
-
let formulaRow = {};
|
|
451
|
-
formulaColumns.forEach(column => formulaRow[column.key] = row[column.key]);
|
|
452
|
-
formula_rows[row._id] = formulaRow;
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
return formula_rows;
|
|
456
|
-
};
|
|
457
|
-
export const handleCascadeColumn = function (optionValue, columnKey, columns, row) {
|
|
458
|
-
let updated = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
459
|
-
let processedColumns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new Set();
|
|
460
|
-
// This column has already been processed, avoid circular dependency.
|
|
461
|
-
if (!Array.isArray(columns) || processedColumns.has(columnKey)) {
|
|
462
|
-
return updated;
|
|
463
|
-
}
|
|
464
|
-
processedColumns.add(columnKey);
|
|
465
|
-
const singleSelectColumns = columns.filter(column => column.type === CellType.SINGLE_SELECT);
|
|
466
|
-
for (let i = 0; i < singleSelectColumns.length; i++) {
|
|
467
|
-
const singleSelectColumn = singleSelectColumns[i];
|
|
468
|
-
const {
|
|
469
|
-
data: {
|
|
470
|
-
cascade_column_key,
|
|
471
|
-
cascade_settings
|
|
472
|
-
}
|
|
473
|
-
} = singleSelectColumn;
|
|
474
|
-
if (cascade_column_key === columnKey) {
|
|
475
|
-
const {
|
|
476
|
-
key: childColumnKey
|
|
477
|
-
} = singleSelectColumn;
|
|
478
|
-
const childColumnOptions = cascade_settings[optionValue];
|
|
479
|
-
const childColumnCellValue = row[childColumnKey];
|
|
480
|
-
const cellValueInOptions = childColumnOptions && childColumnOptions.includes(childColumnCellValue);
|
|
481
|
-
if (!cellValueInOptions) {
|
|
482
|
-
updated[childColumnKey] = '';
|
|
483
|
-
handleCascadeColumn('', childColumnKey, columns, row, updated, processedColumns);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return updated;
|
|
488
|
-
};
|
|
489
|
-
export const findLastFrozenColumnIndex = columns => {
|
|
490
|
-
for (let i = 0; i < columns.length; i++) {
|
|
491
|
-
if (isFrozen(columns[i])) {
|
|
492
|
-
return i;
|
|
493
|
-
}
|
|
476
|
+
export function getSelectColumnOptions(column) {
|
|
477
|
+
if (!column || !column.data || !Array.isArray(column.data.options)) {
|
|
478
|
+
return [];
|
|
494
479
|
}
|
|
495
|
-
return
|
|
496
|
-
}
|
|
480
|
+
return column.data.options;
|
|
481
|
+
}
|
package/dist/view/index.css
CHANGED
|
@@ -84,7 +84,8 @@ const Wrapper = _ref => {
|
|
|
84
84
|
return /*#__PURE__*/React.createElement(Table, Object.assign({}, baseProps, {
|
|
85
85
|
summaryColumns: summary_columns,
|
|
86
86
|
summaryMethod: summary_method,
|
|
87
|
-
chartTableColumns: chartTableColumns
|
|
87
|
+
chartTableColumns: chartTableColumns,
|
|
88
|
+
isCalculateByView: isCalculateByView
|
|
88
89
|
}));
|
|
89
90
|
}
|
|
90
91
|
case CHART_TYPE.COMBINATION:
|
|
@@ -147,8 +147,7 @@
|
|
|
147
147
|
padding: 0;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.sea-chart-pivot-table .pivot-table-header-summary-columns-container
|
|
151
|
-
.sea-chart-pivot-table .pivot-cells-container {
|
|
150
|
+
.sea-chart-pivot-table .pivot-table-header-summary-columns-container {
|
|
152
151
|
height: 100%;
|
|
153
152
|
width: 100%;
|
|
154
153
|
overflow: hidden;
|
|
@@ -156,6 +155,14 @@
|
|
|
156
155
|
justify-content: space-between;
|
|
157
156
|
}
|
|
158
157
|
|
|
158
|
+
.sea-chart-pivot-table .pivot-cells-container {
|
|
159
|
+
height: 100%;
|
|
160
|
+
width: 100%;
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
display: flex;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
}
|
|
165
|
+
|
|
159
166
|
.sea-chart-pivot-table .pivot-table-header-summary-columns-container > div,
|
|
160
167
|
.sea-chart-pivot-table .pivot-cells-container > div {
|
|
161
168
|
flex:1;
|
|
@@ -126,6 +126,22 @@ class TwoDimensionTable extends PureComponent {
|
|
|
126
126
|
total
|
|
127
127
|
}, selectedCell);
|
|
128
128
|
};
|
|
129
|
+
this.renderByView = (total, display_empty, cellIdx, isSelectedCell, isSelectedCellTop, isSelectedCellLeft) => {
|
|
130
|
+
const isValidDisplayValue = BaseUtils.isValidValue(total, display_empty);
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
key: "table-cell-".concat(cellIdx),
|
|
133
|
+
className: classnames('pivot-cell', {
|
|
134
|
+
'pivot-empty-cell': !isValidDisplayValue,
|
|
135
|
+
'selected-pivot-cell': isSelectedCell,
|
|
136
|
+
'selected-pivot-cell-top': isSelectedCellTop,
|
|
137
|
+
'selected-pivot-cell-left': isSelectedCellLeft
|
|
138
|
+
})
|
|
139
|
+
}, isValidDisplayValue ? total : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
140
|
+
className: classnames({
|
|
141
|
+
'selected-pivot-cell-border': isSelectedCell
|
|
142
|
+
})
|
|
143
|
+
}));
|
|
144
|
+
};
|
|
129
145
|
this.renderRows = () => {
|
|
130
146
|
const {
|
|
131
147
|
result,
|
|
@@ -133,7 +149,8 @@ class TwoDimensionTable extends PureComponent {
|
|
|
133
149
|
selectedCell,
|
|
134
150
|
summaryColumn,
|
|
135
151
|
summaryMethod,
|
|
136
|
-
chart
|
|
152
|
+
chart,
|
|
153
|
+
isCalculateByView
|
|
137
154
|
} = this.props;
|
|
138
155
|
const {
|
|
139
156
|
display_total = true,
|
|
@@ -145,7 +162,7 @@ class TwoDimensionTable extends PureComponent {
|
|
|
145
162
|
pivot_columns,
|
|
146
163
|
pivot_columns_total,
|
|
147
164
|
pivot_table_total,
|
|
148
|
-
summary_columns
|
|
165
|
+
summary_columns: summaryColumns
|
|
149
166
|
} = result;
|
|
150
167
|
const {
|
|
151
168
|
rowIdx: selectRowIdx,
|
|
@@ -232,10 +249,10 @@ class TwoDimensionTable extends PureComponent {
|
|
|
232
249
|
className: classnames('pivot-cell'),
|
|
233
250
|
key: "table-cell-".concat(cellIdx)
|
|
234
251
|
}, /*#__PURE__*/React.createElement("div", {
|
|
235
|
-
className:
|
|
236
|
-
}, total && total.map && total.map((summaryCell, idx) => {
|
|
252
|
+
className: classnames('pivot-cells-container')
|
|
253
|
+
}, !isCalculateByView && total && total.map && total.map((summaryCell, idx) => {
|
|
237
254
|
const summaryCellColumnKey = summaryCell[2];
|
|
238
|
-
const summaryCellColumn =
|
|
255
|
+
const summaryCellColumn = summaryColumns.find(item => item.key === summaryCellColumnKey);
|
|
239
256
|
const displayValue = BaseUtils.getSummaryValueDisplayString(summaryCellColumn, summaryCell[1], summaryMethod);
|
|
240
257
|
const isValidDisplayValue = BaseUtils.isValidValue(displayValue, display_empty);
|
|
241
258
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -251,14 +268,14 @@ class TwoDimensionTable extends PureComponent {
|
|
|
251
268
|
'selected-pivot-cell-border': isSelectedCell
|
|
252
269
|
})
|
|
253
270
|
}));
|
|
254
|
-
}), !total && (
|
|
271
|
+
}), !isCalculateByView && !total && (summaryColumns === null || summaryColumns === void 0 ? void 0 : summaryColumns.map(() => {
|
|
255
272
|
return /*#__PURE__*/React.createElement("div", {
|
|
256
273
|
key: "table-cell-".concat(cellIdx),
|
|
257
274
|
className: classnames('pivot-cell', {
|
|
258
275
|
'pivot-empty-cell': true
|
|
259
276
|
})
|
|
260
277
|
}, /*#__PURE__*/React.createElement("i", null));
|
|
261
|
-
}))));
|
|
278
|
+
})), isCalculateByView && this.renderByView(total, display_empty, cellIdx, isSelectedCell, isSelectedCellTop, isSelectedCellLeft)));
|
|
262
279
|
}), display_total && /*#__PURE__*/React.createElement("td", {
|
|
263
280
|
className: classnames('pivot-cell', {
|
|
264
281
|
'pivot-empty-cell': !isValidSummaryDisplayValue,
|