sea-chart 1.1.89 → 1.1.91
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/api/index.js
CHANGED
|
@@ -17,42 +17,16 @@ class SeaChartAPI {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
this.getBaseData = () => {
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
dtableUuid,
|
|
23
|
-
accessToken
|
|
24
|
-
} = this;
|
|
25
|
-
const url = dtableServer + 'dtables/' + dtableUuid;
|
|
26
|
-
const headers = {
|
|
27
|
-
'Authorization': 'Token ' + accessToken
|
|
28
|
-
};
|
|
29
|
-
return axios.get(url, {
|
|
30
|
-
headers
|
|
31
|
-
});
|
|
20
|
+
const url = `/api/v2/dtables/${this.dtableUuid}/`;
|
|
21
|
+
return this.req.get(url);
|
|
32
22
|
};
|
|
33
23
|
this.getBaseMetaData = () => {
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
dtableUuid,
|
|
37
|
-
accessToken
|
|
38
|
-
} = this;
|
|
39
|
-
const url = dtableServer + 'api/v1/dtables/' + dtableUuid + '/metadata';
|
|
40
|
-
const headers = {
|
|
41
|
-
'Authorization': 'Token ' + accessToken
|
|
42
|
-
};
|
|
43
|
-
return axios.get(url, {
|
|
44
|
-
headers
|
|
45
|
-
});
|
|
24
|
+
const url = `/api/v2/dtables/${this.dtableUuid}/metadata/`;
|
|
25
|
+
return this.req.get(url);
|
|
46
26
|
};
|
|
47
27
|
this.sqlQuery = function (sql, parameters) {
|
|
48
28
|
let convert_keys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
49
|
-
const {
|
|
50
|
-
dtableServer,
|
|
51
|
-
dtableUuid,
|
|
52
|
-
accessToken
|
|
53
|
-
} = _this;
|
|
54
|
-
const apiGatewayUrl = (dtableServer || '').replace(/\/*$/, '') + '/api-gateway/';
|
|
55
|
-
const url = `${apiGatewayUrl}api/v2/dtables/${dtableUuid}/sql/`;
|
|
29
|
+
const url = `/api/v2/dtables/${_this.dtableUuid}/sql/`;
|
|
56
30
|
const data = {
|
|
57
31
|
sql,
|
|
58
32
|
convert_keys,
|
|
@@ -60,20 +34,16 @@ class SeaChartAPI {
|
|
|
60
34
|
parameters: parameters
|
|
61
35
|
})
|
|
62
36
|
};
|
|
63
|
-
|
|
64
|
-
'Authorization': 'Token ' + accessToken
|
|
65
|
-
};
|
|
66
|
-
return axios.post(url, data, {
|
|
67
|
-
headers
|
|
68
|
-
});
|
|
37
|
+
return _this.req.post(url, data);
|
|
69
38
|
};
|
|
70
39
|
this.config = config;
|
|
40
|
+
const {
|
|
41
|
+
server: _server
|
|
42
|
+
} = config;
|
|
71
43
|
this.instance = null;
|
|
72
44
|
this.appName = '';
|
|
73
|
-
this.accessToken = '';
|
|
74
45
|
this.dtableUuid = '';
|
|
75
|
-
this.
|
|
76
|
-
this.dtableSocket = '';
|
|
46
|
+
this.baseURL = _server[_server.length - 1] === '/' ? `${_server}api-gateway` : `${_server}/api-gateway`;
|
|
77
47
|
}
|
|
78
48
|
static getInstance(config) {
|
|
79
49
|
if (this.instance) return this.instance;
|
|
@@ -85,27 +55,16 @@ class SeaChartAPI {
|
|
|
85
55
|
const {
|
|
86
56
|
app_name,
|
|
87
57
|
access_token,
|
|
88
|
-
dtable_uuid
|
|
89
|
-
dtable_server,
|
|
90
|
-
dtable_socket,
|
|
91
|
-
dtable_db
|
|
58
|
+
dtable_uuid
|
|
92
59
|
} = accessTokenRes.data;
|
|
93
60
|
this.appName = app_name;
|
|
94
|
-
this.accessToken = access_token;
|
|
95
61
|
this.dtableUuid = dtable_uuid;
|
|
96
|
-
this.
|
|
97
|
-
|
|
62
|
+
this.req = axios.create({
|
|
63
|
+
baseURL: this.baseURL,
|
|
64
|
+
headers: {
|
|
65
|
+
'Authorization': 'Token ' + access_token
|
|
66
|
+
}
|
|
67
|
+
});
|
|
98
68
|
}
|
|
99
|
-
|
|
100
|
-
// queryUsers(userIdList) {
|
|
101
|
-
// const { dtableServer, accessToken } = this;
|
|
102
|
-
// const url = dtableServer + 'api/v2.1/user-list';
|
|
103
|
-
// let operation = { user_id_list: userIdList };
|
|
104
|
-
// const headers = {
|
|
105
|
-
// 'Content-type': 'application/json',
|
|
106
|
-
// 'Authorization': 'Token ' + accessToken
|
|
107
|
-
// };
|
|
108
|
-
// return axios.post(url, operation, { headers });
|
|
109
|
-
// }
|
|
110
69
|
}
|
|
111
70
|
export default SeaChartAPI;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var _SQLStatisticsUtils;
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
|
|
4
|
-
import { isObject
|
|
4
|
+
import { isObject } from 'lodash';
|
|
5
|
+
import deepCopy from 'deep-copy';
|
|
5
6
|
import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES, CHART_STYLE_COLORS, MAP_CHART_TYPES } from '../../constants';
|
|
6
7
|
import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
|
|
7
8
|
import { getClientLinkDisplayString } from '../cell-format-utils';
|
|
@@ -1724,23 +1725,10 @@ SQLStatisticsUtils.sqlResult2JavaScript = async (chart, sqlRows, chartSQLMap, co
|
|
|
1724
1725
|
}
|
|
1725
1726
|
}
|
|
1726
1727
|
};
|
|
1727
|
-
SQLStatisticsUtils._get_completeness_name = (row, column) => {
|
|
1728
|
-
let value = row[column.key];
|
|
1729
|
-
if (Array.isArray(value)) {
|
|
1730
|
-
value = value.join('、');
|
|
1731
|
-
}
|
|
1732
|
-
return value;
|
|
1733
|
-
};
|
|
1734
1728
|
SQLStatisticsUtils.completenessSQlResult = async (chart, sqlRows, chartSQLMap, tables) => {
|
|
1735
|
-
const {
|
|
1736
|
-
config: {
|
|
1737
|
-
type
|
|
1738
|
-
}
|
|
1739
|
-
} = chart;
|
|
1740
|
-
const isGroup = type === CHART_TYPE.COMPLETENESS_GROUP;
|
|
1741
1729
|
const {
|
|
1742
1730
|
sqlColumns,
|
|
1743
|
-
|
|
1731
|
+
sqlColumnGroupbyColumnKey
|
|
1744
1732
|
} = chartSQLMap;
|
|
1745
1733
|
const {
|
|
1746
1734
|
name_column,
|
|
@@ -1748,134 +1736,23 @@ SQLStatisticsUtils.completenessSQlResult = async (chart, sqlRows, chartSQLMap, t
|
|
|
1748
1736
|
target_column,
|
|
1749
1737
|
column_groupby_column
|
|
1750
1738
|
} = sqlColumns;
|
|
1751
|
-
const res = [];
|
|
1752
|
-
let summedSqlRows;
|
|
1753
1739
|
const nameColumnDataAsAnArray = findIfColumnDataIsArray(name_column);
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return acc;
|
|
1762
|
-
}
|
|
1763
|
-
names.forEach(name => {
|
|
1764
|
-
if (!acc[name]) {
|
|
1765
|
-
row[name_column.key] = name;
|
|
1766
|
-
acc[name] = row;
|
|
1767
|
-
} else {
|
|
1768
|
-
const accRow = acc[name];
|
|
1769
|
-
Object.keys(row).forEach(key => {
|
|
1770
|
-
if (key === completed_column.key || key === target_column.key) {
|
|
1771
|
-
// in case of null
|
|
1772
|
-
if (!row[key]) {
|
|
1773
|
-
row[key] = 0;
|
|
1774
|
-
}
|
|
1775
|
-
if (!accRow[key]) {
|
|
1776
|
-
accRow[key] = 0;
|
|
1777
|
-
}
|
|
1778
|
-
accRow[key] = accRow[key] + row[key];
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
});
|
|
1783
|
-
return acc;
|
|
1784
|
-
}, {});
|
|
1785
|
-
summedSqlRows = Object.values(sumSqlRows);
|
|
1786
|
-
} else {
|
|
1787
|
-
const sumSqlRows = sqlRows.reduce((acc, row) => {
|
|
1788
|
-
const nameValue = row[name_column.key];
|
|
1789
|
-
if (!nameValue) {
|
|
1790
|
-
row[name_column.key] = intl.get('Empty');
|
|
1791
|
-
acc[intl.get('Empty')] = row;
|
|
1792
|
-
return acc;
|
|
1793
|
-
}
|
|
1794
|
-
if (!acc[nameValue]) {
|
|
1795
|
-
acc[nameValue] = row;
|
|
1796
|
-
} else {
|
|
1797
|
-
const accRow = acc[nameValue];
|
|
1798
|
-
Object.keys(row).forEach(key => {
|
|
1799
|
-
if (key === completed_column.key || key === target_column.key) {
|
|
1800
|
-
accRow[key] = accRow[key] + row[key];
|
|
1801
|
-
}
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
|
-
return acc;
|
|
1805
|
-
}, {});
|
|
1806
|
-
summedSqlRows = Object.values(sumSqlRows);
|
|
1807
|
-
}
|
|
1808
|
-
} else {
|
|
1809
|
-
if (nameColumnDataAsAnArray) {
|
|
1810
|
-
const sumSqlRows = sqlRows.reduce((acc, row) => {
|
|
1811
|
-
const groupby = row[sqlColumnGroupByColumnKey];
|
|
1812
|
-
const names = row[name_column.key];
|
|
1813
|
-
if (!names) {
|
|
1814
|
-
const key = `empty_${groupby}`;
|
|
1815
|
-
row[name_column.key] = intl.get('Empty');
|
|
1816
|
-
acc[key] = row;
|
|
1817
|
-
return acc;
|
|
1818
|
-
}
|
|
1819
|
-
names.forEach(name => {
|
|
1820
|
-
const key = `${name}_${groupby}`;
|
|
1821
|
-
if (!acc[key]) {
|
|
1822
|
-
row[name_column.key] = name;
|
|
1823
|
-
acc[key] = row;
|
|
1824
|
-
} else {
|
|
1825
|
-
const accRow = acc[key];
|
|
1826
|
-
Object.keys(row).forEach(k => {
|
|
1827
|
-
if (key === completed_column.key || key === target_column.key) {
|
|
1828
|
-
accRow[key] = accRow[key] + row[key];
|
|
1829
|
-
}
|
|
1830
|
-
});
|
|
1831
|
-
}
|
|
1832
|
-
});
|
|
1833
|
-
return acc;
|
|
1834
|
-
}, {});
|
|
1835
|
-
summedSqlRows = Object.values(sumSqlRows);
|
|
1836
|
-
} else {
|
|
1837
|
-
const sumSqlRows = sqlRows.reduce((acc, row) => {
|
|
1838
|
-
const nameValue = row[name_column.key];
|
|
1839
|
-
const groupby = row[sqlColumnGroupByColumnKey];
|
|
1840
|
-
if (!nameValue) {
|
|
1841
|
-
const key = `empty_${groupby}`;
|
|
1842
|
-
row[name_column.key] = intl.get('Empty');
|
|
1843
|
-
acc[key] = row;
|
|
1844
|
-
return acc;
|
|
1845
|
-
}
|
|
1846
|
-
const key = `${nameValue}_${groupby}`;
|
|
1847
|
-
if (!acc[key]) {
|
|
1848
|
-
acc[key] = row;
|
|
1849
|
-
} else {
|
|
1850
|
-
const accRow = acc[key];
|
|
1851
|
-
Object.keys(row).forEach(key => {
|
|
1852
|
-
if (key === completed_column.key || key === target_column.key) {
|
|
1853
|
-
accRow[key] = accRow[key] + row[key];
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
}
|
|
1857
|
-
return acc;
|
|
1858
|
-
}, {});
|
|
1859
|
-
summedSqlRows = Object.values(sumSqlRows);
|
|
1860
|
-
}
|
|
1740
|
+
// group by name_column, so it can only have one value
|
|
1741
|
+
let originalSqlRows = deepCopy(sqlRows);
|
|
1742
|
+
if (nameColumnDataAsAnArray) {
|
|
1743
|
+
sqlRows.forEach(row => {
|
|
1744
|
+
var _row$name_column$key;
|
|
1745
|
+
row[name_column.key] = (_row$name_column$key = row[name_column.key]) === null || _row$name_column$key === void 0 ? void 0 : _row$name_column$key[0];
|
|
1746
|
+
});
|
|
1861
1747
|
}
|
|
1862
|
-
|
|
1863
|
-
// format the fetched value
|
|
1864
1748
|
await BaseUtils.updateTableViewList(sqlRows, name_column, name_column.key, 'color', false, true);
|
|
1865
|
-
if (
|
|
1866
|
-
|
|
1749
|
+
if (sqlColumnGroupbyColumnKey) await BaseUtils.updateTableViewList(sqlRows, column_groupby_column, sqlColumnGroupbyColumnKey, 'color', false, false);
|
|
1750
|
+
const res = [];
|
|
1751
|
+
sqlRows.forEach((row, index) => {
|
|
1867
1752
|
const nameValue = row[name_column.key];
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
if (sqlColumnGroupByColumnKey) {
|
|
1872
|
-
targetValue = row[`SUM(${target_column.name})`];
|
|
1873
|
-
completedValue = row[`SUM(${completed_column.name})`];
|
|
1874
|
-
groupby = row[sqlColumnGroupByColumnKey] || intl.get('Empty');
|
|
1875
|
-
} else {
|
|
1876
|
-
completedValue = _SQLStatisticsUtils._get_completeness_name(row, completed_column);
|
|
1877
|
-
targetValue = _SQLStatisticsUtils._get_completeness_name(row, target_column);
|
|
1878
|
-
}
|
|
1753
|
+
const targetValue = row[`SUM(${target_column.name})`];
|
|
1754
|
+
const completedValue = row[`SUM(${completed_column.name})`];
|
|
1755
|
+
const groupby = row[sqlColumnGroupbyColumnKey] || intl.get('Empty');
|
|
1879
1756
|
let completedRate;
|
|
1880
1757
|
if (!targetValue && completedValue) {
|
|
1881
1758
|
completedRate = 100;
|
|
@@ -1893,7 +1770,8 @@ SQLStatisticsUtils.completenessSQlResult = async (chart, sqlRows, chartSQLMap, t
|
|
|
1893
1770
|
group_name: 'completed',
|
|
1894
1771
|
groupby,
|
|
1895
1772
|
color: row.color || CHART_STYLE_COLORS[0],
|
|
1896
|
-
value: completedValue
|
|
1773
|
+
value: completedValue,
|
|
1774
|
+
rows: [originalSqlRows[index]]
|
|
1897
1775
|
});
|
|
1898
1776
|
res.push({
|
|
1899
1777
|
name: nameValue,
|
|
@@ -1902,7 +1780,8 @@ SQLStatisticsUtils.completenessSQlResult = async (chart, sqlRows, chartSQLMap, t
|
|
|
1902
1780
|
value: Math.max(targetValue - completedValue, 0),
|
|
1903
1781
|
groupby,
|
|
1904
1782
|
color: '#bdbdbd',
|
|
1905
|
-
completedRate
|
|
1783
|
+
completedRate,
|
|
1784
|
+
rows: [originalSqlRows[index]]
|
|
1906
1785
|
});
|
|
1907
1786
|
});
|
|
1908
1787
|
|
|
@@ -611,12 +611,18 @@ export const getFilterConditions = (statisticRecord, chart, table) => {
|
|
|
611
611
|
const groupColumnKey = groupAxisMap[type];
|
|
612
612
|
chart.config = BaseUtils.convertConfig(config);
|
|
613
613
|
const chartSQLMap = chartColumn2SqlColumn(chart, table);
|
|
614
|
-
|
|
614
|
+
let {
|
|
615
615
|
sqlColumnGroupbyColumnKey,
|
|
616
616
|
sqlGroupbyColumnKey,
|
|
617
617
|
sqlXColumnKey,
|
|
618
618
|
sqlYColumnKey
|
|
619
619
|
} = chartSQLMap;
|
|
620
|
+
if (type === CHART_TYPE.COMPLETENESS_GROUP || type === CHART_TYPE.COMPLETENESS) {
|
|
621
|
+
const {
|
|
622
|
+
sqlColumns
|
|
623
|
+
} = chartSQLMap;
|
|
624
|
+
sqlGroupbyColumnKey = sqlColumns.name_column.key;
|
|
625
|
+
}
|
|
620
626
|
if (isPivot && rows.length) {
|
|
621
627
|
const xValueList = [];
|
|
622
628
|
const yValueList = [];
|
|
@@ -796,12 +796,12 @@ const chartColumn2SqlColumn = (chartElement, table) => {
|
|
|
796
796
|
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
797
797
|
{
|
|
798
798
|
const sqlColumns = getCompletenessSettingColumn(chart, table);
|
|
799
|
-
const
|
|
800
|
-
// only has
|
|
799
|
+
const sqlColumnGroupbyColumnKey = completenessColumn2SqlColumn(chart, table);
|
|
800
|
+
// only has columnGroupbyColumn key need maped to sql key
|
|
801
801
|
// for example: 'xxx' => 'ISODATE(xxxx)'
|
|
802
802
|
return {
|
|
803
803
|
sqlColumns,
|
|
804
|
-
|
|
804
|
+
sqlColumnGroupbyColumnKey
|
|
805
805
|
};
|
|
806
806
|
}
|
|
807
807
|
case CHART_TYPE.SCATTER:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.91",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@antv/scale": "0.3.14",
|
|
26
|
-
"dtable-ui-component": "^6.0.
|
|
26
|
+
"dtable-ui-component": "^6.0.37",
|
|
27
27
|
"dtable-utils": "~5.0.*",
|
|
28
28
|
"prop-types": "15.8.1",
|
|
29
29
|
"react": "^18.3.1",
|