sea-chart 1.1.63 → 1.1.64
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.
|
@@ -2,7 +2,7 @@ var _BaseUtils;
|
|
|
2
2
|
import shallowEqual from 'shallowequal';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString, isArchiveView, getViewById, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP } from 'dtable-utils';
|
|
5
|
-
import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE, HORIZONTAL_BAR_CHART_TYPES, COMPLTETELESS_CHART_TYPES, CHART_STYLE_CONFIG_SETTING_KEYS } from '../../constants';
|
|
5
|
+
import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE, HORIZONTAL_BAR_CHART_TYPES, COMPLTETELESS_CHART_TYPES, CHART_STYLE_CONFIG_SETTING_KEYS, MAP_CHART_TYPES } from '../../constants';
|
|
6
6
|
import { getClientFormulaDisplayString } from '../cell-format-utils';
|
|
7
7
|
import { getKnownCollaboratorByEmail, generateDefaultUser, getUsers } from '../collaborator-utils';
|
|
8
8
|
import { getDateColumnFormat, getColumnByKey } from '../column-utils';
|
|
@@ -189,6 +189,9 @@ BaseUtils.getGroupColumn = (table, chart) => {
|
|
|
189
189
|
if (type === CHART_TYPE.HEAT_MAP) {
|
|
190
190
|
return getTableColumnByKey(table, config.time_column_key);
|
|
191
191
|
}
|
|
192
|
+
if (MAP_CHART_TYPES.includes(type)) {
|
|
193
|
+
return getTableColumnByKey(table, config.geo_column_key);
|
|
194
|
+
}
|
|
192
195
|
return getTableColumnByKey(table, config.x_axis_column_key);
|
|
193
196
|
};
|
|
194
197
|
BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
@@ -1933,16 +1933,53 @@ SQLStatisticsUtils.mapSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, colum
|
|
|
1933
1933
|
sqlGeoColumnKey,
|
|
1934
1934
|
sqlSummaryColumnKey
|
|
1935
1935
|
} = chartSQLMap;
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1936
|
+
const {
|
|
1937
|
+
groupbyColumn
|
|
1938
|
+
} = columnMap;
|
|
1939
|
+
if (groupbyColumn.type === 'link-formula') {
|
|
1940
|
+
const {
|
|
1941
|
+
data,
|
|
1942
|
+
key
|
|
1943
|
+
} = groupbyColumn;
|
|
1944
|
+
const {
|
|
1945
|
+
array_data: {
|
|
1946
|
+
geo_format
|
|
1947
|
+
}
|
|
1948
|
+
} = data;
|
|
1949
|
+
if (!geo_format) {
|
|
1950
|
+
return [];
|
|
1951
|
+
}
|
|
1952
|
+
const nameValueMap = sqlRows.reduce((acc, row) => {
|
|
1953
|
+
const geoList = row[key];
|
|
1954
|
+
const value = row[sqlSummaryColumnKey];
|
|
1955
|
+
geoList.forEach(geo => {
|
|
1956
|
+
const name = geo[geo_format];
|
|
1957
|
+
if (!acc[name]) {
|
|
1958
|
+
acc[name] = value;
|
|
1959
|
+
} else {
|
|
1960
|
+
acc[name] += value;
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
return acc;
|
|
1964
|
+
}, {});
|
|
1965
|
+
return Object.keys(nameValueMap).reduce((acc, name) => {
|
|
1966
|
+
acc.push({
|
|
1967
|
+
name,
|
|
1968
|
+
value: nameValueMap[name]
|
|
1969
|
+
});
|
|
1970
|
+
return acc;
|
|
1971
|
+
}, []);
|
|
1972
|
+
} else {
|
|
1973
|
+
return sqlRows.reduce((acc, row) => {
|
|
1974
|
+
const name = row[sqlGeoColumnKey];
|
|
1975
|
+
const value = row[sqlSummaryColumnKey];
|
|
1976
|
+
acc.push({
|
|
1977
|
+
name,
|
|
1978
|
+
value
|
|
1979
|
+
});
|
|
1980
|
+
return acc;
|
|
1981
|
+
}, []);
|
|
1982
|
+
}
|
|
1946
1983
|
};
|
|
1947
1984
|
SQLStatisticsUtils.worldMapSQLResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables) => {
|
|
1948
1985
|
const {
|
|
@@ -1956,25 +1993,67 @@ SQLStatisticsUtils.worldMapSQLResult2JavaScript = (chart, sqlRows, chartSQLMap,
|
|
|
1956
1993
|
const {
|
|
1957
1994
|
sqlSummaryColumnKey
|
|
1958
1995
|
} = chartSQLMap;
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1996
|
+
if (groupbyColumn.type === 'link-formula') {
|
|
1997
|
+
const {
|
|
1998
|
+
data,
|
|
1999
|
+
key
|
|
2000
|
+
} = groupbyColumn;
|
|
2001
|
+
const {
|
|
2002
|
+
array_data: {
|
|
2003
|
+
geo_format
|
|
2004
|
+
}
|
|
2005
|
+
} = data;
|
|
2006
|
+
if (!geo_format) {
|
|
2007
|
+
return [];
|
|
1967
2008
|
}
|
|
1968
|
-
|
|
1969
|
-
const
|
|
1970
|
-
|
|
2009
|
+
const nameValueMap = sqlRows.reduce((acc, row) => {
|
|
2010
|
+
const geoList = row[key];
|
|
2011
|
+
const value = row[sqlSummaryColumnKey];
|
|
2012
|
+
geoList.forEach(geo => {
|
|
2013
|
+
const name = geo[geo_format];
|
|
2014
|
+
if (!acc[name]) {
|
|
2015
|
+
acc[name] = value;
|
|
2016
|
+
} else {
|
|
2017
|
+
acc[name] += value;
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
return acc;
|
|
2021
|
+
}, {});
|
|
2022
|
+
return Object.keys(nameValueMap).reduce((acc, name) => {
|
|
2023
|
+
let value = nameValueMap[name];
|
|
2024
|
+
let formatted_value = value;
|
|
2025
|
+
if (summary_type === 'advanced') {
|
|
2026
|
+
value = formatNumericValue(value, summaryColumn);
|
|
2027
|
+
formatted_value = getFormattedValue(value, summaryColumn, summary_method);
|
|
2028
|
+
}
|
|
2029
|
+
acc.push({
|
|
1971
2030
|
name,
|
|
1972
2031
|
value,
|
|
1973
2032
|
formatted_value
|
|
1974
2033
|
});
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2034
|
+
return acc;
|
|
2035
|
+
}, []);
|
|
2036
|
+
} else {
|
|
2037
|
+
const result = [];
|
|
2038
|
+
sqlRows.forEach(item => {
|
|
2039
|
+
const currentValue = item[groupbyColumn.key];
|
|
2040
|
+
let value = item[sqlSummaryColumnKey];
|
|
2041
|
+
let formatted_value = value;
|
|
2042
|
+
if (summary_type === 'advanced') {
|
|
2043
|
+
value = formatNumericValue(value, summaryColumn);
|
|
2044
|
+
formatted_value = getFormattedValue(value, summaryColumn, summary_method);
|
|
2045
|
+
}
|
|
2046
|
+
if (currentValue) {
|
|
2047
|
+
const name = typeof currentValue === 'string' ? currentValue : currentValue.country_region;
|
|
2048
|
+
result.push({
|
|
2049
|
+
name,
|
|
2050
|
+
value,
|
|
2051
|
+
formatted_value
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
});
|
|
2055
|
+
return result;
|
|
2056
|
+
}
|
|
1978
2057
|
};
|
|
1979
2058
|
SQLStatisticsUtils.calculateChart = async (chart, value, callback, sqlRows) => {
|
|
1980
2059
|
const {
|