sea-chart 0.0.31 → 0.0.33-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/settings/map-settings/map-data-settings.js +3 -2
- package/dist/settings/mirror-settings/data-settings.js +1 -1
- package/dist/settings/widgets/group-by.js +5 -3
- package/dist/utils/chart-utils/base-utils.js +33 -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 +148 -162
- package/dist/utils/index.js +0 -38
- package/dist/utils/map.js +1 -1
- package/dist/utils/sql/chart-data-sql.js +150 -195
- package/dist/utils/sql/column-2-sql-column.js +4 -1
- package/dist/view/wrapper/bar-group.js +0 -1
- package/dist/view/wrapper/heat-map.js +1 -1
- package/dist/view/wrapper/horizontal-component.js +1 -1
- package/dist/view/wrapper/line.js +0 -2
- package/dist/view/wrapper/map.js +3 -5
- package/dist/view/wrapper/scatter.js +1 -1
- package/dist/view/wrapper/treemap.js +1 -1
- package/dist/view/wrapper/world-map.js +3 -2
- package/package.json +2 -2
|
@@ -1,17 +1,17 @@
|
|
|
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,
|
|
4
|
+
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS, 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';
|
|
8
8
|
import { column2SqlColumn } from '../sql/column-2-sql-column';
|
|
9
|
-
import { formatNumericValue, getFormattedValue,
|
|
9
|
+
import { formatNumericValue, getFormattedValue, getSummaryResult } from '../column-utils';
|
|
10
10
|
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);
|
|
@@ -681,46 +695,35 @@ SQLStatisticsUtils.customChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMa
|
|
|
681
695
|
return result;
|
|
682
696
|
};
|
|
683
697
|
SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
698
|
+
const {
|
|
699
|
+
groupbyColumn,
|
|
700
|
+
summaryColumn
|
|
701
|
+
} = columnMap;
|
|
702
|
+
const {
|
|
703
|
+
sqlGroupbyColumnKey,
|
|
704
|
+
sqlSummaryColumnKey
|
|
705
|
+
} = chartSQLMap;
|
|
684
706
|
const {
|
|
685
707
|
config
|
|
686
708
|
} = chart;
|
|
687
709
|
const {
|
|
688
|
-
table_id,
|
|
689
710
|
x_axis_date_range_start,
|
|
690
711
|
x_axis_date_range_end,
|
|
691
712
|
x_axis_compared_date_range_start,
|
|
692
713
|
x_axis_compared_date_range_end,
|
|
693
714
|
y_axis_summary_type,
|
|
694
715
|
y_axis_summary_method,
|
|
695
|
-
x_axis_column_key,
|
|
696
|
-
y_axis_column_key,
|
|
697
|
-
x_axis_geolocation_granularity,
|
|
698
716
|
display_increase
|
|
699
717
|
} = config;
|
|
700
718
|
const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
|
|
701
719
|
const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
|
|
702
720
|
const dateRangeResult = new Map();
|
|
703
721
|
let dateComparedResult = new Map();
|
|
704
|
-
const selectedTable = getTableById(tables, table_id);
|
|
705
|
-
const selectedColumn = getColumnByKey(x_axis_column_key, selectedTable.columns);
|
|
706
|
-
const groupName = getSqlGroup(selectedColumn, {
|
|
707
|
-
'date_granularity': 'day',
|
|
708
|
-
'geolocation_granularity': x_axis_geolocation_granularity
|
|
709
|
-
});
|
|
710
|
-
let summaryColumnName = "".concat(selectedColumn.name);
|
|
711
|
-
let selectedSummaryColumn = {};
|
|
712
722
|
const isAdvanced = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
713
|
-
if (isAdvanced) {
|
|
714
|
-
selectedSummaryColumn = getColumnByKey(y_axis_column_key, selectedTable.columns);
|
|
715
|
-
if (!selectedSummaryColumn) return [];
|
|
716
|
-
summaryColumnName = "".concat(selectedSummaryColumn.name);
|
|
717
|
-
}
|
|
718
|
-
const method = isAdvanced ? DTABLE_DB_SUMMARY_METHOD[y_axis_summary_method] : DTABLE_DB_SUMMARY_METHOD.COUNT;
|
|
719
|
-
const valueKey = isAdvanced ? "".concat(method, "(").concat(summaryColumnName, ")") : "".concat(method, "(").concat(selectedColumn.name, ")");
|
|
720
723
|
sqlRows.forEach(item => {
|
|
721
|
-
const name = item[
|
|
722
|
-
const label =
|
|
723
|
-
const value = item[
|
|
724
|
+
const name = item[sqlGroupbyColumnKey];
|
|
725
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, tables);
|
|
726
|
+
const value = item[sqlSummaryColumnKey];
|
|
724
727
|
if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
|
|
725
728
|
const currentValue = dateRangeResult.get(label);
|
|
726
729
|
if (!currentValue) {
|
|
@@ -755,13 +758,13 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
755
758
|
});
|
|
756
759
|
let comparedResult = [];
|
|
757
760
|
let rangeResult = [];
|
|
758
|
-
const data =
|
|
761
|
+
const data = (summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.data) || {};
|
|
759
762
|
for (let item of dateRangeResult) {
|
|
760
763
|
let value = item[1];
|
|
761
764
|
let formatted_value = value;
|
|
762
765
|
if (isAdvanced) {
|
|
763
766
|
value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
|
|
764
|
-
formatted_value = getFormattedValue(value,
|
|
767
|
+
formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
765
768
|
}
|
|
766
769
|
rangeResult.push({
|
|
767
770
|
name: item[0],
|
|
@@ -781,7 +784,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
|
|
|
781
784
|
let formatted_value = value;
|
|
782
785
|
if (isAdvanced) {
|
|
783
786
|
value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
|
|
784
|
-
formatted_value = getFormattedValue(value,
|
|
787
|
+
formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
|
|
785
788
|
}
|
|
786
789
|
const newItem = {
|
|
787
790
|
name: dateRangeItem.name,
|
|
@@ -843,7 +846,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
843
846
|
sqlRows.forEach(row => {
|
|
844
847
|
const cellValue = row[sqlGroupbyColumnKey];
|
|
845
848
|
const summaryValue = row[sqlSummaryColumnKey];
|
|
846
|
-
const key =
|
|
849
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
847
850
|
let valueLeft = row[sqlLeftSummaryColumnKey] || 0;
|
|
848
851
|
let valueRight = row[sqlRightSummaryColumnKey] || 0;
|
|
849
852
|
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
@@ -930,7 +933,7 @@ SQLStatisticsUtils.combinationSQLResult2Javascript = (chart, sqlRows, chartSQLMa
|
|
|
930
933
|
});
|
|
931
934
|
sqlRows.forEach((item, index) => {
|
|
932
935
|
const cellValue = item[sqlGroupbyColumnKey];
|
|
933
|
-
const key =
|
|
936
|
+
const key = _SQLStatisticsUtils.getGroupLabelFromDB(cellValue, groupbyColumn, tables);
|
|
934
937
|
let valueRight = item[sqlRightSummaryColumnKey] || 0;
|
|
935
938
|
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
936
939
|
valueRight = BaseUtils.getPrecisionNumber(valueRight, rightSummaryColumn.data);
|
|
@@ -1003,15 +1006,15 @@ SQLStatisticsUtils.updateGroupingChartRow = (results, name, groupName, row, coun
|
|
|
1003
1006
|
SQLStatisticsUtils.updateGroupingChartRows = (results, name, row, count, isColumnGroupbyColumnDataAsAnArray, groupName) => {
|
|
1004
1007
|
if (isColumnGroupbyColumnDataAsAnArray) {
|
|
1005
1008
|
if (!Array.isArray(groupName) || groupName.length === 0) {
|
|
1006
|
-
|
|
1009
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, null, row, count);
|
|
1007
1010
|
return;
|
|
1008
1011
|
}
|
|
1009
1012
|
groupName.forEach(v => {
|
|
1010
|
-
|
|
1013
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, v, row, count);
|
|
1011
1014
|
});
|
|
1012
1015
|
return;
|
|
1013
1016
|
}
|
|
1014
|
-
|
|
1017
|
+
_SQLStatisticsUtils.updateGroupingChartRow(results, name, groupName, row, count);
|
|
1015
1018
|
};
|
|
1016
1019
|
SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1017
1020
|
const {
|
|
@@ -1031,21 +1034,21 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = (chart, sqlRo
|
|
|
1031
1034
|
const isColumnGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[columnGroupbyColumn.type];
|
|
1032
1035
|
sqlRows.forEach(row => {
|
|
1033
1036
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1034
|
-
const groupbyColumnCellValueKey =
|
|
1037
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1035
1038
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1036
1039
|
const columnGroupbyColumnCellValue = row[sqlColumnGroupbyColumnKey];
|
|
1037
|
-
const columnGroupbyColumnCellValueKey =
|
|
1040
|
+
const columnGroupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(columnGroupbyColumnCellValue, columnGroupbyColumn, tables);
|
|
1038
1041
|
const count = row[sqlSummaryColumnKey];
|
|
1039
1042
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1040
1043
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1041
|
-
|
|
1044
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, null, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1042
1045
|
} else {
|
|
1043
1046
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1044
|
-
|
|
1047
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, n, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1045
1048
|
});
|
|
1046
1049
|
}
|
|
1047
1050
|
} else {
|
|
1048
|
-
|
|
1051
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, count, isColumnGroupbyColumnDataAsAnArray, columnGroupbyColumnCellValueKey);
|
|
1049
1052
|
}
|
|
1050
1053
|
}
|
|
1051
1054
|
});
|
|
@@ -1062,15 +1065,15 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1062
1065
|
x_axis_include_empty_cells: includeEmpty
|
|
1063
1066
|
} = chart.config;
|
|
1064
1067
|
if (!column_groupby_column_key && !column_groupby_multiple_numeric_column) {
|
|
1065
|
-
return
|
|
1068
|
+
return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1066
1069
|
}
|
|
1067
1070
|
const {
|
|
1068
1071
|
groupbyColumn,
|
|
1069
1072
|
columnGroupbyColumn
|
|
1070
1073
|
} = columnMap;
|
|
1071
1074
|
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1072
|
-
if (!columnGroupbyColumn) return
|
|
1073
|
-
return
|
|
1075
|
+
if (!columnGroupbyColumn) return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1076
|
+
return _SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1074
1077
|
}
|
|
1075
1078
|
const {
|
|
1076
1079
|
sqlGroupbyColumnKey
|
|
@@ -1083,7 +1086,7 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1083
1086
|
const isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[groupbyColumn.type];
|
|
1084
1087
|
sqlRows.forEach(row => {
|
|
1085
1088
|
const groupbyColumnCellValue = row[sqlGroupbyColumnKey];
|
|
1086
|
-
const groupbyColumnCellValueKey =
|
|
1089
|
+
const groupbyColumnCellValueKey = _SQLStatisticsUtils.getGroupLabelFromDB(groupbyColumnCellValue, groupbyColumn, tables);
|
|
1087
1090
|
if (BaseUtils.isValidCellValue(groupbyColumnCellValueKey, includeEmpty)) {
|
|
1088
1091
|
Object.keys(summaryColumns).forEach(sqlSummaryColumnName => {
|
|
1089
1092
|
const {
|
|
@@ -1093,14 +1096,14 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1093
1096
|
const numberColumnCellValue = row[sqlSummaryColumnKey];
|
|
1094
1097
|
if (isGroupbyColumnDataAsAnArray) {
|
|
1095
1098
|
if (!Array.isArray(groupbyColumnCellValueKey) || groupbyColumnCellValueKey.length === 0) {
|
|
1096
|
-
|
|
1099
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, null, row, numberColumnCellValue, false, columnName);
|
|
1097
1100
|
} else {
|
|
1098
1101
|
groupbyColumnCellValueKey.forEach(n => {
|
|
1099
|
-
|
|
1102
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, n, row, numberColumnCellValue, false, columnName);
|
|
1100
1103
|
});
|
|
1101
1104
|
}
|
|
1102
1105
|
} else {
|
|
1103
|
-
|
|
1106
|
+
_SQLStatisticsUtils.updateGroupingChartRows(result, groupbyColumnCellValueKey, row, numberColumnCellValue, false, columnName);
|
|
1104
1107
|
}
|
|
1105
1108
|
});
|
|
1106
1109
|
}
|
|
@@ -1110,31 +1113,24 @@ SQLStatisticsUtils.groupingChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
|
|
|
1110
1113
|
return result;
|
|
1111
1114
|
}
|
|
1112
1115
|
if (!columnGroupbyColumn) {
|
|
1113
|
-
return
|
|
1116
|
+
return _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1114
1117
|
}
|
|
1115
|
-
return
|
|
1118
|
+
return _SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1116
1119
|
};
|
|
1117
1120
|
SQLStatisticsUtils.heatMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1118
|
-
const {
|
|
1119
|
-
config
|
|
1120
|
-
} = chart;
|
|
1121
|
-
const {
|
|
1122
|
-
time_column_key,
|
|
1123
|
-
summary_type
|
|
1124
|
-
} = config;
|
|
1125
1121
|
const {
|
|
1126
1122
|
summaryColumn
|
|
1127
1123
|
} = columnMap;
|
|
1128
1124
|
const {
|
|
1125
|
+
sqlGroupbyColumnKey,
|
|
1129
1126
|
sqlSummaryColumnKey
|
|
1130
1127
|
} = chartSQLMap;
|
|
1131
1128
|
let result = [];
|
|
1132
|
-
const isAdvanced = summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
1133
1129
|
sqlRows.forEach(item => {
|
|
1134
|
-
const currentValue = item[
|
|
1135
|
-
if (currentValue) {
|
|
1130
|
+
const currentValue = item[sqlGroupbyColumnKey];
|
|
1131
|
+
if (currentValue || currentValue === 0) {
|
|
1136
1132
|
let value = item[sqlSummaryColumnKey];
|
|
1137
|
-
if (
|
|
1133
|
+
if (summaryColumn) {
|
|
1138
1134
|
value = formatNumericValue(value, summaryColumn);
|
|
1139
1135
|
}
|
|
1140
1136
|
const name = typeof currentValue === 'string' ? currentValue : currentValue.country_region;
|
|
@@ -1161,13 +1157,9 @@ SQLStatisticsUtils.heatMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQLM
|
|
|
1161
1157
|
}
|
|
1162
1158
|
});
|
|
1163
1159
|
data.sort((current, next) => {
|
|
1164
|
-
if (current.year > next.year)
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
return 1;
|
|
1168
|
-
} else {
|
|
1169
|
-
return 0;
|
|
1170
|
-
}
|
|
1160
|
+
if (current.year > next.year) return -1;
|
|
1161
|
+
if (current.year < next.year) return 1;
|
|
1162
|
+
return 0;
|
|
1171
1163
|
});
|
|
1172
1164
|
return {
|
|
1173
1165
|
data,
|
|
@@ -1195,12 +1187,12 @@ SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQ
|
|
|
1195
1187
|
} = chartSQLMap;
|
|
1196
1188
|
const isAdvanced = summary_type === CHART_SUMMARY_TYPE.ADVANCED;
|
|
1197
1189
|
const newResult = [];
|
|
1198
|
-
const groupData =
|
|
1190
|
+
const groupData = _SQLStatisticsUtils.getGroupData(sqlRows, columnGroupbyColumn);
|
|
1199
1191
|
if (groupData.length > 0) {
|
|
1200
1192
|
const groupData0 = groupData[0] || {};
|
|
1201
1193
|
const groupData1 = groupData[1] || {};
|
|
1202
1194
|
sqlRows.forEach(item => {
|
|
1203
|
-
const label =
|
|
1195
|
+
const label = _SQLStatisticsUtils.getGroupLabelFromDB(item[column_key], groupbyColumn, tables);
|
|
1204
1196
|
const groupValue = item[group_column_key];
|
|
1205
1197
|
const equal2GroupData0 = groupData0.id === groupValue;
|
|
1206
1198
|
const equal2GroupData1 = groupData1.id === groupValue;
|
|
@@ -1295,11 +1287,11 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1295
1287
|
} = chart.config;
|
|
1296
1288
|
if (!column_groupby_column_key) {
|
|
1297
1289
|
return {
|
|
1298
|
-
result:
|
|
1290
|
+
result: _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1299
1291
|
};
|
|
1300
1292
|
}
|
|
1301
1293
|
return {
|
|
1302
|
-
result:
|
|
1294
|
+
result: _SQLStatisticsUtils.twoDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1303
1295
|
};
|
|
1304
1296
|
}
|
|
1305
1297
|
case CHART_TYPE.PIE:
|
|
@@ -1307,19 +1299,19 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1307
1299
|
case CHART_TYPE.TREE_MAP:
|
|
1308
1300
|
{
|
|
1309
1301
|
return {
|
|
1310
|
-
result:
|
|
1302
|
+
result: _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1311
1303
|
};
|
|
1312
1304
|
}
|
|
1313
1305
|
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
1314
1306
|
{
|
|
1315
1307
|
return {
|
|
1316
|
-
result:
|
|
1308
|
+
result: _SQLStatisticsUtils.basicNumberCardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1317
1309
|
};
|
|
1318
1310
|
}
|
|
1319
1311
|
case CHART_TYPE.DASHBOARD:
|
|
1320
1312
|
{
|
|
1321
1313
|
return {
|
|
1322
|
-
result:
|
|
1314
|
+
result: _SQLStatisticsUtils.dashboardSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1323
1315
|
};
|
|
1324
1316
|
}
|
|
1325
1317
|
case CHART_TYPE.BAR:
|
|
@@ -1328,13 +1320,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1328
1320
|
case CHART_TYPE.AREA:
|
|
1329
1321
|
{
|
|
1330
1322
|
return {
|
|
1331
|
-
result:
|
|
1323
|
+
result: _SQLStatisticsUtils.basicChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1332
1324
|
};
|
|
1333
1325
|
}
|
|
1334
1326
|
case CHART_TYPE.COMPLETENESS:
|
|
1335
1327
|
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
1336
1328
|
{
|
|
1337
|
-
const result =
|
|
1329
|
+
const result = _SQLStatisticsUtils.completenessSQlResult(chart, sqlRows, chartSQLMap, tables);
|
|
1338
1330
|
return {
|
|
1339
1331
|
result
|
|
1340
1332
|
};
|
|
@@ -1342,13 +1334,13 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1342
1334
|
case CHART_TYPE.COMBINATION:
|
|
1343
1335
|
{
|
|
1344
1336
|
return {
|
|
1345
|
-
result:
|
|
1337
|
+
result: _SQLStatisticsUtils.combinationSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1346
1338
|
};
|
|
1347
1339
|
}
|
|
1348
1340
|
case CHART_TYPE.COMPARE_BAR:
|
|
1349
1341
|
{
|
|
1350
1342
|
return {
|
|
1351
|
-
result:
|
|
1343
|
+
result: _SQLStatisticsUtils.compareSQLResult2Javascript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1352
1344
|
};
|
|
1353
1345
|
}
|
|
1354
1346
|
case CHART_TYPE.BAR_GROUP:
|
|
@@ -1359,51 +1351,51 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1359
1351
|
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1360
1352
|
{
|
|
1361
1353
|
return {
|
|
1362
|
-
result:
|
|
1354
|
+
result: _SQLStatisticsUtils.groupingChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1363
1355
|
};
|
|
1364
1356
|
}
|
|
1365
1357
|
case CHART_TYPE.SCATTER:
|
|
1366
1358
|
{
|
|
1367
1359
|
return {
|
|
1368
|
-
result:
|
|
1360
|
+
result: _SQLStatisticsUtils.scatterSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1369
1361
|
};
|
|
1370
1362
|
}
|
|
1371
1363
|
case CHART_TYPE.BAR_CUSTOM:
|
|
1372
1364
|
{
|
|
1373
1365
|
return {
|
|
1374
|
-
result:
|
|
1366
|
+
result: _SQLStatisticsUtils.customChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables, params)
|
|
1375
1367
|
};
|
|
1376
1368
|
}
|
|
1377
1369
|
case CHART_TYPE.MAP:
|
|
1378
1370
|
case CHART_TYPE.MAP_BUBBLE:
|
|
1379
1371
|
{
|
|
1380
1372
|
return {
|
|
1381
|
-
result:
|
|
1373
|
+
result: _SQLStatisticsUtils.mapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1382
1374
|
};
|
|
1383
1375
|
}
|
|
1384
1376
|
case CHART_TYPE.WORLD_MAP:
|
|
1385
1377
|
case CHART_TYPE.WORLD_MAP_BUBBLE:
|
|
1386
1378
|
{
|
|
1387
1379
|
return {
|
|
1388
|
-
result:
|
|
1380
|
+
result: _SQLStatisticsUtils.worldMapSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1389
1381
|
};
|
|
1390
1382
|
}
|
|
1391
1383
|
case CHART_TYPE.HEAT_MAP:
|
|
1392
1384
|
{
|
|
1393
1385
|
return {
|
|
1394
|
-
result:
|
|
1386
|
+
result: _SQLStatisticsUtils.heatMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1395
1387
|
};
|
|
1396
1388
|
}
|
|
1397
1389
|
case CHART_TYPE.MIRROR:
|
|
1398
1390
|
{
|
|
1399
1391
|
return {
|
|
1400
|
-
result:
|
|
1392
|
+
result: _SQLStatisticsUtils.mirrorMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1401
1393
|
};
|
|
1402
1394
|
}
|
|
1403
1395
|
case CHART_TYPE.TREND:
|
|
1404
1396
|
{
|
|
1405
1397
|
return {
|
|
1406
|
-
result:
|
|
1398
|
+
result: _SQLStatisticsUtils.trendMapChartSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
|
|
1407
1399
|
};
|
|
1408
1400
|
}
|
|
1409
1401
|
default:
|
|
@@ -1412,7 +1404,14 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
|
|
|
1412
1404
|
}
|
|
1413
1405
|
}
|
|
1414
1406
|
};
|
|
1415
|
-
SQLStatisticsUtils.
|
|
1407
|
+
SQLStatisticsUtils._get_completeness_name = (row, column) => {
|
|
1408
|
+
let value = row[column.key];
|
|
1409
|
+
if (Array.isArray(value)) {
|
|
1410
|
+
value = value.join('、');
|
|
1411
|
+
}
|
|
1412
|
+
return value;
|
|
1413
|
+
};
|
|
1414
|
+
SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, chartSQLMap, tables) => {
|
|
1416
1415
|
const {
|
|
1417
1416
|
config: {
|
|
1418
1417
|
type
|
|
@@ -1422,7 +1421,7 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1422
1421
|
const {
|
|
1423
1422
|
sqlColumns,
|
|
1424
1423
|
sqlColumnGroupByColumnKey
|
|
1425
|
-
} =
|
|
1424
|
+
} = chartSQLMap;
|
|
1426
1425
|
const {
|
|
1427
1426
|
name_column,
|
|
1428
1427
|
completed_column,
|
|
@@ -1433,19 +1432,11 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1433
1432
|
// format the fetched value
|
|
1434
1433
|
BaseUtils.updateTableViewList(sqlRows, name_column, name_column.key, 'color');
|
|
1435
1434
|
if (sqlColumnGroupByColumnKey) BaseUtils.updateTableViewList(sqlRows, column_groupby_column, sqlColumnGroupByColumnKey, 'color');
|
|
1436
|
-
function getFormatedKey(row, column) {
|
|
1437
|
-
// const newKey = column.name;
|
|
1438
|
-
let value = row[column.key];
|
|
1439
|
-
if (Array.isArray(value)) {
|
|
1440
|
-
value = value.join('、');
|
|
1441
|
-
}
|
|
1442
|
-
return value;
|
|
1443
|
-
}
|
|
1444
1435
|
const res = [];
|
|
1445
|
-
let
|
|
1436
|
+
let summedSqlRows;
|
|
1446
1437
|
if (!isGroup) {
|
|
1447
1438
|
const sumSqlRows = sqlRows.reduce((acc, row) => {
|
|
1448
|
-
const nameValue =
|
|
1439
|
+
const nameValue = _SQLStatisticsUtils._get_completeness_name(row, name_column);
|
|
1449
1440
|
if (!acc[nameValue]) {
|
|
1450
1441
|
acc[nameValue] = row;
|
|
1451
1442
|
} else {
|
|
@@ -1457,10 +1448,10 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1457
1448
|
}
|
|
1458
1449
|
return acc;
|
|
1459
1450
|
}, {});
|
|
1460
|
-
|
|
1451
|
+
summedSqlRows = Object.values(sumSqlRows);
|
|
1461
1452
|
} else {
|
|
1462
1453
|
const sumSqlRowsWithGroupBy = sqlRows.reduce((acc, row) => {
|
|
1463
|
-
const nameValue =
|
|
1454
|
+
const nameValue = _SQLStatisticsUtils._get_completeness_name(row, name_column);
|
|
1464
1455
|
const groupby = row[sqlColumnGroupByColumnKey];
|
|
1465
1456
|
const key = "".concat(nameValue, "_").concat(groupby);
|
|
1466
1457
|
if (!acc[key]) {
|
|
@@ -1475,10 +1466,10 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1475
1466
|
}
|
|
1476
1467
|
return acc;
|
|
1477
1468
|
}, {});
|
|
1478
|
-
|
|
1469
|
+
summedSqlRows = Object.values(sumSqlRowsWithGroupBy);
|
|
1479
1470
|
}
|
|
1480
|
-
|
|
1481
|
-
const nameValue =
|
|
1471
|
+
summedSqlRows.forEach(row => {
|
|
1472
|
+
const nameValue = _SQLStatisticsUtils._get_completeness_name(row, name_column);
|
|
1482
1473
|
let targetValue;
|
|
1483
1474
|
let completedValue;
|
|
1484
1475
|
let groupby;
|
|
@@ -1487,8 +1478,8 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1487
1478
|
completedValue = row["SUM(".concat(completed_column.name, ")")];
|
|
1488
1479
|
groupby = row[sqlColumnGroupByColumnKey] || intl.get('Empty');
|
|
1489
1480
|
} else {
|
|
1490
|
-
completedValue =
|
|
1491
|
-
targetValue =
|
|
1481
|
+
completedValue = _SQLStatisticsUtils._get_completeness_name(row, completed_column);
|
|
1482
|
+
targetValue = _SQLStatisticsUtils._get_completeness_name(row, target_column);
|
|
1492
1483
|
}
|
|
1493
1484
|
let completedRate;
|
|
1494
1485
|
if (!targetValue && completedValue) {
|
|
@@ -1526,26 +1517,21 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
|
|
|
1526
1517
|
return res;
|
|
1527
1518
|
};
|
|
1528
1519
|
SQLStatisticsUtils.scatterSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1529
|
-
const {
|
|
1530
|
-
x_axis_column_key,
|
|
1531
|
-
y_axis_column_key,
|
|
1532
|
-
column_groupby_column_key,
|
|
1533
|
-
table_id
|
|
1534
|
-
} = chart.config;
|
|
1535
1520
|
const {
|
|
1536
1521
|
sqlXColumnKey,
|
|
1537
1522
|
sqlYColumnKey,
|
|
1538
1523
|
sqlColumnGroupbyColumnKey
|
|
1539
1524
|
} = chartSQLMap;
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1525
|
+
const {
|
|
1526
|
+
groupbyColumn,
|
|
1527
|
+
columnGroupbyColumn,
|
|
1528
|
+
summaryColumn
|
|
1529
|
+
} = columnMap;
|
|
1544
1530
|
|
|
1545
1531
|
// format sql rows
|
|
1546
|
-
BaseUtils.updateTableViewList(sqlRows,
|
|
1547
|
-
BaseUtils.updateTableViewList(sqlRows,
|
|
1548
|
-
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows,
|
|
1532
|
+
BaseUtils.updateTableViewList(sqlRows, groupbyColumn, groupbyColumn.key, 'color');
|
|
1533
|
+
BaseUtils.updateTableViewList(sqlRows, summaryColumn, summaryColumn.key, 'color');
|
|
1534
|
+
if (sqlColumnGroupbyColumnKey) BaseUtils.updateTableViewList(sqlRows, columnGroupbyColumn, sqlColumnGroupbyColumnKey, 'color');
|
|
1549
1535
|
const res = [];
|
|
1550
1536
|
sqlRows.forEach(row => {
|
|
1551
1537
|
const xValue = row[sqlXColumnKey];
|
|
@@ -1607,7 +1593,7 @@ SQLStatisticsUtils.worldMapSQLResult2JavaScript = (chart, sqlRows, chartSQLMap,
|
|
|
1607
1593
|
});
|
|
1608
1594
|
return result;
|
|
1609
1595
|
};
|
|
1610
|
-
SQLStatisticsUtils.calculateChart = (chart, value, callback,
|
|
1596
|
+
SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
|
|
1611
1597
|
const {
|
|
1612
1598
|
tables
|
|
1613
1599
|
} = value;
|
|
@@ -1650,14 +1636,15 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1650
1636
|
const tipMessage = 'There_are_no_statistic_results_yet';
|
|
1651
1637
|
|
|
1652
1638
|
// Custom Bar
|
|
1653
|
-
if (
|
|
1639
|
+
if (chartType === CHART_TYPE.BAR_CUSTOM) {
|
|
1654
1640
|
const result = [];
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1641
|
+
sqlRows.forEach((item, index) => {
|
|
1642
|
+
if (item.length !== 0) {
|
|
1643
|
+
const chartResult = _SQLStatisticsUtils.sqlResult2JavaScript(newChart, item, chartSQLMap, columnMap, tables, {
|
|
1644
|
+
index
|
|
1645
|
+
});
|
|
1646
|
+
result.push(...chartResult.result);
|
|
1647
|
+
}
|
|
1661
1648
|
});
|
|
1662
1649
|
if (result.length === 0) {
|
|
1663
1650
|
callback && callback('', tipMessage, null);
|
|
@@ -1665,7 +1652,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1665
1652
|
}
|
|
1666
1653
|
callback && callback('', '', {
|
|
1667
1654
|
result,
|
|
1668
|
-
data_sources:
|
|
1655
|
+
data_sources: _SQLStatisticsUtils.dataSources,
|
|
1669
1656
|
groupbyColumn,
|
|
1670
1657
|
columnGroupbyColumn,
|
|
1671
1658
|
summaryColumn,
|
|
@@ -1673,15 +1660,14 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1673
1660
|
});
|
|
1674
1661
|
return;
|
|
1675
1662
|
}
|
|
1676
|
-
|
|
1677
|
-
results: sqlRows
|
|
1678
|
-
} = res.data;
|
|
1663
|
+
|
|
1679
1664
|
// map is special, still need to show map even data is empty
|
|
1680
1665
|
if (!Array.isArray(sqlRows) || sqlRows.length === 0 && !chartType.includes('map')) {
|
|
1681
1666
|
callback && callback('', tipMessage, null);
|
|
1682
1667
|
return;
|
|
1683
1668
|
}
|
|
1684
|
-
const chartResult =
|
|
1669
|
+
const chartResult = _SQLStatisticsUtils.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1670
|
+
|
|
1685
1671
|
// map is special
|
|
1686
1672
|
if (BaseUtils.imEmptyChartResult(chartResult) && !chartType.includes('map')) {
|
|
1687
1673
|
callback && callback('', tipMessage, null);
|
|
@@ -1689,7 +1675,7 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, res) => {
|
|
|
1689
1675
|
}
|
|
1690
1676
|
callback && callback('', '', {
|
|
1691
1677
|
...chartResult,
|
|
1692
|
-
data_sources:
|
|
1678
|
+
data_sources: _SQLStatisticsUtils.dataSources,
|
|
1693
1679
|
groupbyColumn,
|
|
1694
1680
|
columnGroupbyColumn,
|
|
1695
1681
|
summaryColumn,
|