sea-chart 0.0.30 → 0.0.31-beta
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/context.js +41 -14
- package/dist/utils/chart-utils/base-utils.js +23 -23
- package/dist/utils/chart-utils/index.js +2 -10
- package/dist/utils/chart-utils/original-data-utils/index.js +4 -4
- package/dist/utils/chart-utils/sql-statistics-utils.js +101 -87
- package/dist/utils/map.js +1 -1
- package/dist/utils/sql/chart-data-sql.js +146 -193
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _SQLStatisticsUtils;
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
4
|
-
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS, DTABLE_DB_SUMMARY_METHOD } from '../../constants';
|
|
4
|
+
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS, DTABLE_DB_SUMMARY_METHOD, Y_AXIS_TYPE_PREFIX } from '../../constants';
|
|
5
5
|
import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
|
|
6
6
|
import { getClientLinkDisplayString } from '../cell-format-utils';
|
|
7
7
|
import context from '../../context';
|
|
@@ -11,7 +11,7 @@ import { getCompareDate } from '../trend-utils';
|
|
|
11
11
|
import intl from '../../intl';
|
|
12
12
|
import BaseUtils from './base-utils';
|
|
13
13
|
class SQLStatisticsUtils {}
|
|
14
|
-
|
|
14
|
+
_SQLStatisticsUtils = SQLStatisticsUtils;
|
|
15
15
|
SQLStatisticsUtils.dataSources = 'sql_statistics';
|
|
16
16
|
SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables) => {
|
|
17
17
|
const collaborators = context.getCollaboratorsFromCache();
|
|
@@ -230,7 +230,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
230
230
|
const isCount = summary_type === CHART_SUMMARY_TYPE.COUNT;
|
|
231
231
|
let newSqlRows = sqlRows;
|
|
232
232
|
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
233
|
-
newSqlRows =
|
|
233
|
+
newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
234
234
|
}
|
|
235
235
|
if (isCount) {
|
|
236
236
|
let allTotal = 0;
|
|
@@ -238,7 +238,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
238
238
|
const total = row[sqlSummaryColumnKey] || 0;
|
|
239
239
|
allTotal += total;
|
|
240
240
|
pivot_rows.push({
|
|
241
|
-
name:
|
|
241
|
+
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
242
242
|
rows: [],
|
|
243
243
|
total: {
|
|
244
244
|
total
|
|
@@ -291,7 +291,7 @@ SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
293
|
pivot_rows.push({
|
|
294
|
-
name:
|
|
294
|
+
name: _SQLStatisticsUtils.getGroupLabelFromDB(row[sqlGroupbyColumnKey], groupbyColumn, tables),
|
|
295
295
|
rows: [row],
|
|
296
296
|
total: rowTotal
|
|
297
297
|
});
|
|
@@ -465,11 +465,11 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
465
465
|
sqlColumnGroupbyColumnKey,
|
|
466
466
|
sqlSummaryColumnKey
|
|
467
467
|
} = chartSQLMap;
|
|
468
|
-
if (!sqlColumnGroupbyColumnKey) return
|
|
468
|
+
if (!sqlColumnGroupbyColumnKey) return _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
469
469
|
const summaryMethod = (summary_method || 'sum').toUpperCase();
|
|
470
470
|
let newSqlRows = sqlRows;
|
|
471
471
|
if (groupbyColumn.type === CellType.COLLABORATOR) {
|
|
472
|
-
newSqlRows =
|
|
472
|
+
newSqlRows = _SQLStatisticsUtils.formatedTableSqlRows(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
473
473
|
}
|
|
474
474
|
let pivot_columns = [];
|
|
475
475
|
let pivot_rows = [];
|
|
@@ -477,12 +477,12 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
477
477
|
const isRowGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
478
478
|
newSqlRows.forEach(row => {
|
|
479
479
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
480
|
-
const groupbyColumnCellValueKey =
|
|
480
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
481
481
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
482
|
-
const columnGroupbyColumnCellValueKey =
|
|
482
|
+
const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
483
483
|
const count = !row[sqlSummaryColumnKey] && row[sqlSummaryColumnKey] !== 0 ? null : row[sqlSummaryColumnKey];
|
|
484
484
|
if (BaseUtils.isValidCellValue(columnGroupbyColumnCellValue, groupby_include_empty_cells)) {
|
|
485
|
-
|
|
485
|
+
_SQLStatisticsUtils.updateTwoDimensionColumns(pivot_columns, columnGroupbyColumnCellValueKey, {
|
|
486
486
|
isIncludeEmpty: groupby_include_empty_cells,
|
|
487
487
|
isCellValueAsAnArray: isRowGroupbyColumnDataAsAnArray
|
|
488
488
|
});
|
|
@@ -491,14 +491,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
491
491
|
if (MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn]) {
|
|
492
492
|
if ((!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) && groupby_include_empty_cells) {
|
|
493
493
|
let pivotRowIndex = pivot_rows.findIndex(r => !r.name);
|
|
494
|
-
|
|
494
|
+
_SQLStatisticsUtils.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, null, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
495
495
|
summaryMethod,
|
|
496
496
|
summaryColumn
|
|
497
497
|
});
|
|
498
498
|
} else {
|
|
499
499
|
groupbyColumnCellValueKey.forEach(n => {
|
|
500
500
|
let pivotRowIndex = pivot_rows.findIndex(r => n === r.name);
|
|
501
|
-
|
|
501
|
+
_SQLStatisticsUtils.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, n, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
502
502
|
summaryMethod,
|
|
503
503
|
summaryColumn
|
|
504
504
|
});
|
|
@@ -509,14 +509,14 @@ SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript = (chart, sqlRows, char
|
|
|
509
509
|
let resName = r.name;
|
|
510
510
|
return resName === null && groupbyColumnCellValueKey === null || resName === undefined && groupbyColumnCellValueKey === undefined || resName === 0 && groupbyColumnCellValueKey === 0 || resName === groupbyColumnCellValueKey;
|
|
511
511
|
});
|
|
512
|
-
|
|
512
|
+
_SQLStatisticsUtils.updateTwoDimensionRows(pivot_rows, pivot_columns, pivotRowIndex, groupbyColumnCellValueKey, count, row, isRowGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey, {
|
|
513
513
|
summaryMethod,
|
|
514
514
|
summaryColumn
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
});
|
|
519
|
-
let pivot_table_total =
|
|
519
|
+
let pivot_table_total = _SQLStatisticsUtils.getAndUpdateTwoDimensionTotal(pivot_columns_total, pivot_columns, pivot_rows, {
|
|
520
520
|
summaryMethod,
|
|
521
521
|
summaryColumn
|
|
522
522
|
});
|
|
@@ -558,7 +558,7 @@ SQLStatisticsUtils.basicChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap
|
|
|
558
558
|
formatted_value = getFormattedValue(cellValue, y_axis_summary_column_key, y_axis_summary_method);
|
|
559
559
|
}
|
|
560
560
|
if (BaseUtils.isValidCellValue(cellValue)) {
|
|
561
|
-
const key =
|
|
561
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
562
562
|
if (isGroupbyColumnDataAsAnArray) {
|
|
563
563
|
if (!Array.isArray(key) || key.length === 0) {
|
|
564
564
|
let itemIdx = result.findIndex(v => v.name === null);
|
|
@@ -630,23 +630,39 @@ SQLStatisticsUtils.basicNumberCardSQLResult2JavaScript = (chart, sqlRows, chartS
|
|
|
630
630
|
}
|
|
631
631
|
return 0;
|
|
632
632
|
};
|
|
633
|
-
SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables,
|
|
633
|
+
SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables, _ref4) => {
|
|
634
|
+
let {
|
|
635
|
+
index
|
|
636
|
+
} = _ref4;
|
|
634
637
|
const {
|
|
635
638
|
table_id,
|
|
636
|
-
x_axis_column_key,
|
|
637
639
|
x_axis_date_granularity,
|
|
638
640
|
x_axis_geolocation_granularity,
|
|
639
|
-
x_axis_include_empty
|
|
641
|
+
x_axis_include_empty,
|
|
642
|
+
y_axises
|
|
640
643
|
} = chart.config;
|
|
641
644
|
const {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
numericColumns,
|
|
645
|
-
groupColumnNames,
|
|
646
|
-
yAxisType
|
|
647
|
-
} = params;
|
|
645
|
+
groupbyColumn
|
|
646
|
+
} = columnMap;
|
|
648
647
|
const table = getTableById(tables, table_id);
|
|
649
|
-
const
|
|
648
|
+
const stack = y_axises[index];
|
|
649
|
+
if (!stack) return [];
|
|
650
|
+
const {
|
|
651
|
+
column_groupby_numeric_columns
|
|
652
|
+
} = stack;
|
|
653
|
+
const y_axis_type = "".concat(Y_AXIS_TYPE_PREFIX).concat(index);
|
|
654
|
+
let summaryMethods = [];
|
|
655
|
+
let originalMethods = [];
|
|
656
|
+
let groupColumnNames = [];
|
|
657
|
+
let numericColumns = [];
|
|
658
|
+
column_groupby_numeric_columns.forEach(item => {
|
|
659
|
+
const numericColumn = getTableColumnByKey(table, item.column_key);
|
|
660
|
+
const groupColumnName = numericColumn.name;
|
|
661
|
+
numericColumns.push(numericColumn);
|
|
662
|
+
groupColumnNames.push(groupColumnName);
|
|
663
|
+
summaryMethods.push(summaryMethodColumn2SqlColumn(item.summary_method.toUpperCase(), numericColumn).key);
|
|
664
|
+
originalMethods.push(item.summary_method);
|
|
665
|
+
});
|
|
650
666
|
const {
|
|
651
667
|
key: sqlGroupbyColumnKey
|
|
652
668
|
} = column2SqlColumn(groupbyColumn, {
|
|
@@ -656,24 +672,22 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
|
|
|
656
672
|
let result = [];
|
|
657
673
|
sqlRows.forEach(row => {
|
|
658
674
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
659
|
-
const label =
|
|
675
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
660
676
|
const isEmpty = !label;
|
|
661
677
|
const groupItems = [];
|
|
662
|
-
|
|
663
|
-
if (!x_axis_include_empty && isEmpty)
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
let value = row[groupMethods[index]] || 0;
|
|
678
|
+
summaryMethods.forEach((summaryMethod, index) => {
|
|
679
|
+
if (!x_axis_include_empty && isEmpty) return;
|
|
680
|
+
let value = row[summaryMethod] || 0;
|
|
667
681
|
let formatted_value = value;
|
|
668
682
|
value = formatNumericValue(value, numericColumns[index]);
|
|
669
|
-
formatted_value = getFormattedValue(value, numericColumns, originalMethods[index]);
|
|
683
|
+
formatted_value = getFormattedValue(value, numericColumns[index], originalMethods[index]);
|
|
670
684
|
groupItems.push({
|
|
671
685
|
name: label,
|
|
672
686
|
value,
|
|
673
687
|
formatted_value,
|
|
674
688
|
group_name: groupColumnNames[index],
|
|
675
689
|
original_name: row[groupbyColumn.key],
|
|
676
|
-
y_axis_type:
|
|
690
|
+
y_axis_type: y_axis_type
|
|
677
691
|
});
|
|
678
692
|
});
|
|
679
693
|
result = result.concat(groupItems);
|
|
@@ -719,7 +733,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
719
733
|
const valueKey = isAdvanced ? "".concat(method, "(").concat(summaryColumnName, ")") : "".concat(method, "(").concat(selectedColumn.name, ")");
|
|
720
734
|
sqlRows.forEach(item => {
|
|
721
735
|
const name = item[groupName];
|
|
722
|
-
const label =
|
|
736
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, selectedColumn, tables);
|
|
723
737
|
const value = item[valueKey];
|
|
724
738
|
if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
|
|
725
739
|
const currentValue = dateRangeResult.get(label);
|
|
@@ -843,7 +857,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
843
857
|
sqlRows.forEach(row => {
|
|
844
858
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
845
859
|
const summaryValue = row[sqlSummaryColumnKey];
|
|
846
|
-
const key =
|
|
860
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
847
861
|
let valueLeft = row[sqlLeftSummaryColumnKey] || 0;
|
|
848
862
|
let valueRight = row[sqlRightSummaryColumnKey] || 0;
|
|
849
863
|
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
@@ -930,7 +944,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
930
944
|
});
|
|
931
945
|
sqlRows.forEach((item, index) => {
|
|
932
946
|
const cellValue = item[sqlGroupbyColumnKey];
|
|
933
|
-
const key =
|
|
947
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
934
948
|
let valueRight = item[sqlRightSummaryColumnKey] || 0;
|
|
935
949
|
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
936
950
|
valueRight = BaseUtils.getPrecisionNumber(valueRight, rightSummaryColumn.data);
|
|
@@ -1003,15 +1017,15 @@ SQLStatisticsUtils.updateGroupingChartRow = (results, name, groupName, row, coun
|
|
|
1003
1017
|
SQLStatisticsUtils.updateGroupingChartRows = (results, name, row, count, isColumnGroupbyColumnDataAsAnArray, groupName) => {
|
|
1004
1018
|
if (isColumnGroupbyColumnDataAsAnArray) {
|
|
1005
1019
|
if (!Array.isArray(groupName) || groupName.length === 0) {
|
|
1006
|
-
|
|
1020
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, null, row, count);
|
|
1007
1021
|
return;
|
|
1008
1022
|
}
|
|
1009
1023
|
groupName.forEach(v => {
|
|
1010
|
-
|
|
1024
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, v, row, count);
|
|
1011
1025
|
});
|
|
1012
1026
|
return;
|
|
1013
1027
|
}
|
|
1014
|
-
|
|
1028
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, groupName, row, count);
|
|
1015
1029
|
};
|
|
1016
1030
|
SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1017
1031
|
const {
|
|
@@ -1031,21 +1045,21 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
|
|
|
1031
1045
|
const isColumnGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
1032
1046
|
sqlRows.forEach(row => {
|
|
1033
1047
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1034
|
-
const groupbyColumnCellValueKey =
|
|
1048
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1035
1049
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1036
1050
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
1037
|
-
const columnGroupbyColumnCellValueKey =
|
|
1051
|
+
const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
1038
1052
|
const count = row[sqlSummaryColumnKey];
|
|
1039
1053
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1040
1054
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1041
|
-
|
|
1055
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, null, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1042
1056
|
} else {
|
|
1043
1057
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1044
|
-
|
|
1058
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, n, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1045
1059
|
});
|
|
1046
1060
|
}
|
|
1047
1061
|
} else {
|
|
1048
|
-
|
|
1062
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1049
1063
|
}
|
|
1050
1064
|
}
|
|
1051
1065
|
});
|
|
@@ -1062,15 +1076,15 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1062
1076
|
x_axis_include_empty_cells: includeEmpty
|
|
1063
1077
|
} = chart.config;
|
|
1064
1078
|
if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
|
|
1065
|
-
return
|
|
1079
|
+
return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1066
1080
|
}
|
|
1067
1081
|
const {
|
|
1068
1082
|
groupbyColumn,
|
|
1069
1083
|
columnGroupbyColumn
|
|
1070
1084
|
} = columnMap;
|
|
1071
1085
|
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1072
|
-
if (!columnGroupbyColumn) return
|
|
1073
|
-
return
|
|
1086
|
+
if (!columnGroupbyColumn) return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1087
|
+
return _SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1074
1088
|
}
|
|
1075
1089
|
const {
|
|
1076
1090
|
sqlGroupbyColumnKey
|
|
@@ -1083,7 +1097,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1083
1097
|
const isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type];
|
|
1084
1098
|
sqlRows.forEach(row => {
|
|
1085
1099
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1086
|
-
const groupbyColumnCellValueKey =
|
|
1100
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1087
1101
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1088
1102
|
Object.keys(summaryColumns).forEach(sqlSummaryColumnName => {
|
|
1089
1103
|
const {
|
|
@@ -1093,14 +1107,14 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1093
1107
|
const numberColumnCellValue = row[sqlSummaryColumnKey];
|
|
1094
1108
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1095
1109
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1096
|
-
|
|
1110
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, null, row, numberColumnCellValue, false, columnName);
|
|
1097
1111
|
} else {
|
|
1098
1112
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1099
|
-
|
|
1113
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, n, row, numberColumnCellValue, false, columnName);
|
|
1100
1114
|
});
|
|
1101
1115
|
}
|
|
1102
1116
|
} else {
|
|
1103
|
-
|
|
1117
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, numberColumnCellValue, false, columnName);
|
|
1104
1118
|
}
|
|
1105
1119
|
});
|
|
1106
1120
|
}
|
|
@@ -1110,9 +1124,9 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1110
1124
|
return result;
|
|
1111
1125
|
}
|
|
1112
1126
|
if (!columnGroupbyColumn) {
|
|
1113
|
-
return
|
|
1127
|
+
return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1114
1128
|
}
|
|
1115
|
-
return
|
|
1129
|
+
return _SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1116
1130
|
};
|
|
1117
1131
|
SQLStatisticsUtils.heatMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1118
1132
|
const {
|
|
@@ -1195,12 +1209,12 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQ
|
|
|
1195
1209
|
} = chartSQLMap;
|
|
1196
1210
|
const isAdvanced = summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
1197
1211
|
const newResult = [];
|
|
1198
|
-
const groupData =
|
|
1212
|
+
const groupData = _SQLStatisticsUtils.getGroupData(sqlRows, columnGroupbyColumn);
|
|
1199
1213
|
if (groupData.length > 0) {
|
|
1200
1214
|
const groupData0 = groupData[0] || {};
|
|
1201
1215
|
const groupData1 = groupData[1] || {};
|
|
1202
1216
|
sqlRows.forEach(item => {
|
|
1203
|
-
const label =
|
|
1217
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn, tables);
|
|
1204
1218
|
const groupValue = item[group_column_key];
|
|
1205
1219
|
const equal2GroupData0 = groupData0.id === groupValue;
|
|
1206
1220
|
const equal2GroupData1 = groupData1.id === groupValue;
|
|
@@ -1295,11 +1309,11 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1295
1309
|
} = chart.config;
|
|
1296
1310
|
if (!column_groupby_column_key) {
|
|
1297
1311
|
return {
|
|
1298
|
-
result:
|
|
1312
|
+
result: _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1299
1313
|
};
|
|
1300
1314
|
}
|
|
1301
1315
|
return {
|
|
1302
|
-
result:
|
|
1316
|
+
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1303
1317
|
};
|
|
1304
1318
|
}
|
|
1305
1319
|
case CHART_TYPE.PIE:
|
|
@@ -1307,19 +1321,19 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1307
1321
|
case CHART_TYPE.TREE_MAP:
|
|
1308
1322
|
{
|
|
1309
1323
|
return {
|
|
1310
|
-
result:
|
|
1324
|
+
result: _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1311
1325
|
};
|
|
1312
1326
|
}
|
|
1313
1327
|
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
1314
1328
|
{
|
|
1315
1329
|
return {
|
|
1316
|
-
result:
|
|
1330
|
+
result: _SQLStatisticsUtils.basicNumberCardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1317
1331
|
};
|
|
1318
1332
|
}
|
|
1319
1333
|
case CHART_TYPE.DASHBOARD:
|
|
1320
1334
|
{
|
|
1321
1335
|
return {
|
|
1322
|
-
result:
|
|
1336
|
+
result: _SQLStatisticsUtils.dashboardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1323
1337
|
};
|
|
1324
1338
|
}
|
|
1325
1339
|
case CHART_TYPE.BAR:
|
|
@@ -1328,13 +1342,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1328
1342
|
case CHART_TYPE.AREA:
|
|
1329
1343
|
{
|
|
1330
1344
|
return {
|
|
1331
|
-
result:
|
|
1345
|
+
result: _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1332
1346
|
};
|
|
1333
1347
|
}
|
|
1334
1348
|
case CHART_TYPE.COMPLETENESS:
|
|
1335
1349
|
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
1336
1350
|
{
|
|
1337
|
-
const result =
|
|
1351
|
+
const result = _SQLStatisticsUtils.completenessSQlResult(chart, sqlRows, chartSQLMap, tables);
|
|
1338
1352
|
return {
|
|
1339
1353
|
result
|
|
1340
1354
|
};
|
|
@@ -1342,13 +1356,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1342
1356
|
case CHART_TYPE.COMBINATION:
|
|
1343
1357
|
{
|
|
1344
1358
|
return {
|
|
1345
|
-
result:
|
|
1359
|
+
result: _SQLStatisticsUtils.combinationSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1346
1360
|
};
|
|
1347
1361
|
}
|
|
1348
1362
|
case CHART_TYPE.COMPARE_BAR:
|
|
1349
1363
|
{
|
|
1350
1364
|
return {
|
|
1351
|
-
result:
|
|
1365
|
+
result: _SQLStatisticsUtils.compareSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1352
1366
|
};
|
|
1353
1367
|
}
|
|
1354
1368
|
case CHART_TYPE.BAR_GROUP:
|
|
@@ -1359,51 +1373,51 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1359
1373
|
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1360
1374
|
{
|
|
1361
1375
|
return {
|
|
1362
|
-
result:
|
|
1376
|
+
result: _SQLStatisticsUtils.groupingChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1363
1377
|
};
|
|
1364
1378
|
}
|
|
1365
1379
|
case CHART_TYPE.SCATTER:
|
|
1366
1380
|
{
|
|
1367
1381
|
return {
|
|
1368
|
-
result:
|
|
1382
|
+
result: _SQLStatisticsUtils.scatterSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1369
1383
|
};
|
|
1370
1384
|
}
|
|
1371
1385
|
case CHART_TYPE.BAR_CUSTOM:
|
|
1372
1386
|
{
|
|
1373
1387
|
return {
|
|
1374
|
-
result:
|
|
1388
|
+
result: _SQLStatisticsUtils.customChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables, params)
|
|
1375
1389
|
};
|
|
1376
1390
|
}
|
|
1377
1391
|
case CHART_TYPE.MAP:
|
|
1378
1392
|
case CHART_TYPE.MAP_BUBBLE:
|
|
1379
1393
|
{
|
|
1380
1394
|
return {
|
|
1381
|
-
result:
|
|
1395
|
+
result: _SQLStatisticsUtils.mapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1382
1396
|
};
|
|
1383
1397
|
}
|
|
1384
1398
|
case CHART_TYPE.WORLD_MAP:
|
|
1385
1399
|
case CHART_TYPE.WORLD_MAP_BUBBLE:
|
|
1386
1400
|
{
|
|
1387
1401
|
return {
|
|
1388
|
-
result:
|
|
1402
|
+
result: _SQLStatisticsUtils.worldMapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1389
1403
|
};
|
|
1390
1404
|
}
|
|
1391
1405
|
case CHART_TYPE.HEAT_MAP:
|
|
1392
1406
|
{
|
|
1393
1407
|
return {
|
|
1394
|
-
result:
|
|
1408
|
+
result: _SQLStatisticsUtils.heatMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1395
1409
|
};
|
|
1396
1410
|
}
|
|
1397
1411
|
case CHART_TYPE.MIRROR:
|
|
1398
1412
|
{
|
|
1399
1413
|
return {
|
|
1400
|
-
result:
|
|
1414
|
+
result: _SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1401
1415
|
};
|
|
1402
1416
|
}
|
|
1403
1417
|
case CHART_TYPE.TREND:
|
|
1404
1418
|
{
|
|
1405
1419
|
return {
|
|
1406
|
-
result:
|
|
1420
|
+
result: _SQLStatisticsUtils.trendMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1407
1421
|
};
|
|
1408
1422
|
}
|
|
1409
1423
|
default:
|
|
@@ -1607,7 +1621,7 @@ SQLStatisticsUtils.worldMapSQLResult2JavaScript = (chart, sqlRows, chartSQLMap,
|
|
|
1607
1621
|
});
|
|
1608
1622
|
return result;
|
|
1609
1623
|
};
|
|
1610
|
-
SQLStatisticsUtils.calculateChart = (chart, value, callback,
|
|
1624
|
+
SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
1611
1625
|
const {
|
|
1612
1626
|
tables
|
|
1613
1627
|
} = value;
|
|
@@ -1650,14 +1664,15 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1650
1664
|
const tipMessage = 'There_are_no_statistic_results_yet';
|
|
1651
1665
|
|
|
1652
1666
|
// Custom Bar
|
|
1653
|
-
if (
|
|
1667
|
+
if (chartType === CHART_TYPE.BAR_CUSTOM) {
|
|
1654
1668
|
const result = [];
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1669
|
+
sqlRows.forEach((item, index) => {
|
|
1670
|
+
if (item.length !== 0) {
|
|
1671
|
+
const chartResult = _SQLStatisticsUtils.sqlResult2JavaScript(newChart, item, chartSQLMap, columnMap, tables, {
|
|
1672
|
+
index
|
|
1673
|
+
});
|
|
1674
|
+
result.push(...chartResult.result);
|
|
1675
|
+
}
|
|
1661
1676
|
});
|
|
1662
1677
|
if (result.length === 0) {
|
|
1663
1678
|
callback && callback('', tipMessage, null);
|
|
@@ -1665,7 +1680,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1665
1680
|
}
|
|
1666
1681
|
callback && callback('', '', {
|
|
1667
1682
|
result,
|
|
1668
|
-
data_sources:
|
|
1683
|
+
data_sources: _SQLStatisticsUtils.dataSources,
|
|
1669
1684
|
groupbyColumn,
|
|
1670
1685
|
columnGroupbyColumn,
|
|
1671
1686
|
summaryColumn,
|
|
@@ -1673,15 +1688,14 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1673
1688
|
});
|
|
1674
1689
|
return;
|
|
1675
1690
|
}
|
|
1676
|
-
|
|
1677
|
-
results: sqlRows
|
|
1678
|
-
} = res.data;
|
|
1691
|
+
|
|
1679
1692
|
// map is special, still need to show map even data is empty
|
|
1680
1693
|
if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !chartType.includes('map')) {
|
|
1681
1694
|
callback && callback('', tipMessage, null);
|
|
1682
1695
|
return;
|
|
1683
1696
|
}
|
|
1684
|
-
const chartResult =
|
|
1697
|
+
const chartResult = _SQLStatisticsUtils.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1698
|
+
|
|
1685
1699
|
// map is special
|
|
1686
1700
|
if (BaseUtils.imEmptyChartResult(chartResult) && !chartType.includes('map')) {
|
|
1687
1701
|
callback && callback('', tipMessage, null);
|
|
@@ -1689,7 +1703,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1689
1703
|
}
|
|
1690
1704
|
callback && callback('', '', {
|
|
1691
1705
|
...chartResult,
|
|
1692
|
-
data_sources:
|
|
1706
|
+
data_sources: _SQLStatisticsUtils.dataSources,
|
|
1693
1707
|
groupbyColumn,
|
|
1694
1708
|
columnGroupbyColumn,
|
|
1695
1709
|
summaryColumn,
|
package/dist/utils/map.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GEOLOCATION_GRANULARITY,
|
|
1
|
+
import { GEOLOCATION_GRANULARITY, MAP_LEVEL, MUNICIPALITIES, regions } from '../constants';
|
|
2
2
|
const COUNTY_SCALE_WIDTH = 5.95;
|
|
3
3
|
const COUNTY_SCALE_HEIGHT = 4.37;
|
|
4
4
|
export const getGeoGranularityByLevel = mapLevel => {
|