|
|
@@ -177,7 +177,6 @@ export default {
|
|
|
console.log('解析图表数据', code, res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
let resData = res.data.data;
|
|
|
- let groupBy = JSON.parse(resData.groupBy) || [];
|
|
|
let chartConfig = JSON.parse(resData.chartConfig || '{ "xAxis": { "column": {}, "granularity": {} }, "yAxis": { "column": {}, "gauge": {} } }');
|
|
|
let styleConfig = JSON.parse(resData.style || '{}');
|
|
|
let otherConfig = JSON.parse(resData.otherConfig || '{}');
|
|
|
@@ -186,7 +185,7 @@ export default {
|
|
|
let chartOption = JSON.parse(resData.chartOption || '{}');
|
|
|
|
|
|
let data = {
|
|
|
- code: resData.chartId,
|
|
|
+ code: resData.chartId + '',
|
|
|
creatorCode: resData.createId+'',
|
|
|
creatorName: resData.createBy,
|
|
|
header: {
|
|
|
@@ -194,7 +193,7 @@ export default {
|
|
|
},
|
|
|
baseConfig: {
|
|
|
dataSource: {
|
|
|
- code: resData.dataId,
|
|
|
+ code: resData.dataId + '',
|
|
|
name: resData.dataName,
|
|
|
},
|
|
|
viewType: viewType
|
|
|
@@ -208,35 +207,15 @@ export default {
|
|
|
}
|
|
|
|
|
|
if(viewType === 'bar') {
|
|
|
- data.barConfig = { ...chartConfig, groupBy: groupBy.map(g => {
|
|
|
- return {
|
|
|
- key: g.columnName.toLowerCase(),
|
|
|
- label: g.columnRename
|
|
|
- }
|
|
|
- })[0] };
|
|
|
+ data.barConfig = chartConfig;
|
|
|
}else if(viewType === 'pie') {
|
|
|
data.pieConfig = chartConfig;
|
|
|
}else if(viewType === 'line') {
|
|
|
- data.lineConfig = { ...chartConfig, groupBy: groupBy.map(g => {
|
|
|
- return {
|
|
|
- key: g.columnName.toLowerCase(),
|
|
|
- label: g.columnRename
|
|
|
- }
|
|
|
- })[0] };
|
|
|
+ data.lineConfig = chartConfig;
|
|
|
}else if(viewType === 'scatter') {
|
|
|
- data.scatterConfig = { ...chartConfig, groupBy: groupBy.map(g => {
|
|
|
- return {
|
|
|
- key: g.columnName.toLowerCase(),
|
|
|
- label: g.columnRename
|
|
|
- }
|
|
|
- })[0] };
|
|
|
+ data.scatterConfig = chartConfig;
|
|
|
}else if(viewType === 'aggregateTable') {
|
|
|
- data.aggregateTableConfig = { ...chartConfig, groupBy: groupBy.map(g => {
|
|
|
- return {
|
|
|
- key: g.columnName.toLowerCase(),
|
|
|
- label: g.columnRename
|
|
|
- }
|
|
|
- }) };
|
|
|
+ data.aggregateTableConfig = chartConfig;
|
|
|
}else if(viewType === 'dataView') {
|
|
|
data.dataViewConfig = chartConfig;
|
|
|
}
|
|
|
@@ -268,7 +247,7 @@ export default {
|
|
|
chartName: header.label,
|
|
|
dataId: baseConfig.dataSource.code,
|
|
|
describes: description,
|
|
|
- style: '',
|
|
|
+ style: '{}',
|
|
|
otherConfig: JSON.stringify(otherConfig),
|
|
|
chartsGroup: group ? group : '-1',
|
|
|
filters: JSON.stringify(filters),
|
|
|
@@ -277,36 +256,18 @@ export default {
|
|
|
if(baseConfig.viewType === 'bar') {
|
|
|
body.chartType = 'Histogram';
|
|
|
body.chartConfig = JSON.stringify(barConfig);
|
|
|
- body.groupBy = barConfig.groupBy.key ? [{
|
|
|
- columnName: barConfig.groupBy.key,
|
|
|
- columnRename: barConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'pie') {
|
|
|
body.chartType = 'Pie';
|
|
|
body.chartConfig = JSON.stringify(pieConfig);
|
|
|
}else if(baseConfig.viewType === 'line') {
|
|
|
body.chartType = 'Line';
|
|
|
body.chartConfig = JSON.stringify(lineConfig);
|
|
|
- body.groupBy = lineConfig.groupBy.key ? [{
|
|
|
- columnName: lineConfig.groupBy.key,
|
|
|
- columnRename: lineConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'scatter') {
|
|
|
body.chartType = 'scatter';
|
|
|
body.chartConfig = JSON.stringify(scatterConfig);
|
|
|
- body.groupBy = scatterConfig.groupBy.key ? [{
|
|
|
- columnName: scatterConfig.groupBy.key,
|
|
|
- columnRename: scatterConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'aggregateTable') {
|
|
|
body.chartType = 'population';
|
|
|
body.chartConfig = JSON.stringify(aggregateTableConfig);
|
|
|
- body.groupBy = aggregateTableConfig.groupBy && aggregateTableConfig.groupBy.length > 0 ? aggregateTableConfig.groupBy.map(g => {
|
|
|
- return {
|
|
|
- columnName: g.key,
|
|
|
- columnRename: g.label
|
|
|
- }
|
|
|
- }) : []
|
|
|
}else if(baseConfig.viewType === 'dataView') {
|
|
|
body.chartType = 'individual';
|
|
|
body.chartConfig = JSON.stringify(dataViewConfig);
|
|
|
@@ -350,36 +311,18 @@ export default {
|
|
|
if(baseConfig.viewType === 'bar') {
|
|
|
body.chartType = 'Histogram';
|
|
|
body.chartConfig = JSON.stringify(barConfig);
|
|
|
- body.groupBy = barConfig.groupBy && barConfig.groupBy.key ? [{
|
|
|
- columnName: barConfig.groupBy.key,
|
|
|
- columnRename: barConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'pie') {
|
|
|
body.chartType = 'Pie';
|
|
|
body.chartConfig = JSON.stringify(pieConfig);
|
|
|
}else if(baseConfig.viewType === 'line') {
|
|
|
body.chartType = 'Line';
|
|
|
body.chartConfig = JSON.stringify(lineConfig);
|
|
|
- body.groupBy = lineConfig.groupBy && lineConfig.groupBy.key ? [{
|
|
|
- columnName: lineConfig.groupBy.key,
|
|
|
- columnRename: lineConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'scatter') {
|
|
|
body.chartType = 'scatter';
|
|
|
body.chartConfig = JSON.stringify(scatterConfig);
|
|
|
- body.groupBy = scatterConfig.groupBy && scatterConfig.groupBy.key ? [{
|
|
|
- columnName: scatterConfig.groupBy.key,
|
|
|
- columnRename: scatterConfig.groupBy.label
|
|
|
- }] : []
|
|
|
}else if(baseConfig.viewType === 'aggregateTable') {
|
|
|
body.chartType = 'population';
|
|
|
body.chartConfig = JSON.stringify(aggregateTableConfig);
|
|
|
- body.groupBy = aggregateTableConfig.groupBy && aggregateTableConfig.groupBy.length > 0 ? aggregateTableConfig.groupBy.map(g => {
|
|
|
- return {
|
|
|
- columnName: g.key,
|
|
|
- columnRename: g.label
|
|
|
- }
|
|
|
- }) : []
|
|
|
}else if(baseConfig.viewType === 'dataView') {
|
|
|
body.chartType = 'individual';
|
|
|
body.chartConfig = JSON.stringify(dataViewConfig);
|