提交 fab8a43e 编写于 作者: tony001's avatar tony001

更新雷达图

上级 03ef6766
...@@ -7,7 +7,7 @@ ${item.render.code} ...@@ -7,7 +7,7 @@ ${item.render.code}
name:'<#if item.getCaption()??>${item.getCaption()}</#if>', name:'<#if item.getCaption()??>${item.getCaption()}</#if>',
type:'radar', type:'radar',
encode:{ encode:{
<#if item.getCatalogField()??>itemName:"${item.getCatalogField()}"</#if> itemName:"type"
}<#if item.getBaseOptionJOString()??>, }<#if item.getBaseOptionJOString()??>,
${item.getBaseOptionJOString()} ${item.getBaseOptionJOString()}
</#if> </#if>
......
...@@ -276,7 +276,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -276,7 +276,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
</#if> </#if>
this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)),arg,this.showBusyIndicator).then((res) => { this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)),arg,this.showBusyIndicator).then((res) => {
if (res) { if (res) {
this.transformToBasicChartSetData(res.data,() =>{_this.drawCharts()}); this.transformToBasicChartSetData(res.data,(codelist:any) =>{_this.drawCharts(codelist)});
} }
}).catch((error) => { }).catch((error) => {
console.error(error); console.error(error);
...@@ -289,12 +289,12 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -289,12 +289,12 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
* @returns {*} * @returns {*}
* @memberof ${srfclassname('${ctrl.name}')}Base * @memberof ${srfclassname('${ctrl.name}')}Base
*/ */
public drawCharts(){ public drawCharts(codelist:any){
if(!this.myChart){ if(!this.myChart){
let element:any = document.getElementById(this.chartId); let element:any = document.getElementById(this.chartId);
this.myChart = echarts.init(element); this.myChart = echarts.init(element);
} }
this.handleChartOPtion(); this.handleChartOPtion(codelist);
console.log(this.chartOption); console.log(this.chartOption);
this.myChart.setOption(this.chartOption); this.myChart.setOption(this.chartOption);
this.myChart.resize(); this.myChart.resize();
...@@ -305,7 +305,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -305,7 +305,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
* *
* @memberof ${srfclassname('${ctrl.name}')}Base * @memberof ${srfclassname('${ctrl.name}')}Base
*/ */
public handleChartOPtion(){ public handleChartOPtion(codelist:any){
if(Object.keys(this.seriesModel).length > 0){ if(Object.keys(this.seriesModel).length > 0){
let tempDataSourceMap:Map<string,any> = new Map(); let tempDataSourceMap:Map<string,any> = new Map();
for(let i=0;i<Object.keys(this.seriesModel).length;i++){ for(let i=0;i<Object.keys(this.seriesModel).length;i++){
...@@ -339,10 +339,12 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -339,10 +339,12 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
// 雷达图 // 雷达图
if(tempSeries.type && Object.is(tempSeries.type,'radar') && tempSeries.seriesIdField && tempSeries.seriesValues.length > 0){ if(tempSeries.type && Object.is(tempSeries.type,'radar') && tempSeries.seriesIdField && tempSeries.seriesValues.length > 0){
let tempIndicator:any = []; let tempIndicator:any = [];
tempSeries.seriesValues.forEach((item:any) =>{ if(allcodelist.get(tempSeries.categorCodeList.tag)){
let singleIndicatorObj:any = {name:item,max:this.computeMaxValue(tempSeries)}; allcodelist.get(tempSeries.categorCodeList.tag).forEach((item:any) =>{
tempIndicator.push(singleIndicatorObj); let singleIndicatorObj:any = {name:item,max:100};
}) tempIndicator.push(singleIndicatorObj);
})
}
this.chartOption.radar = {'indicator':tempIndicator}; this.chartOption.radar = {'indicator':tempIndicator};
}else{ }else{
// 非雷达图 // 非雷达图
...@@ -369,30 +371,6 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -369,30 +371,6 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
} }
} }
/**
* 计算雷达图最大值
*
*
* @param {*} tempSeries 当前序列
* @memberof ${srfclassname('${ctrl.name}')}Base
*/
public computeMaxValue(tempSeries:any){
let tempArray:Array<any> = [];
let chartData:Array<any> = tempSeries.data;
let seriesValues:Array<any> = tempSeries.seriesValues;
if(chartData && chartData.length >0 && seriesValues && seriesValues.length >0){
seriesValues.forEach((seriesValue:any) =>{
chartData.forEach((singleData:any) =>{
tempArray.push(singleData[seriesValue]);
})
})
tempArray.sort((a:any, b:any) => {
return a - b;
});
}
return tempArray.length>0?(tempArray[tempArray.length - 1] + 20):50;
}
/** /**
* 实体数据集转化为图表数据集 * 实体数据集转化为图表数据集
* *
...@@ -520,7 +498,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -520,7 +498,7 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
item.data = this.groupAndAdd(tempGroupField,[],tempValueField,data,item,groupField,allCodeList); item.data = this.groupAndAdd(tempGroupField,[],tempValueField,data,item,groupField,allCodeList);
} }
if(callback && callback instanceof Function){ if(callback && callback instanceof Function){
callback(); callback(allCodeList);
} }
} }
...@@ -634,11 +612,19 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char ...@@ -634,11 +612,19 @@ import { ChartDataSetField,ChartLineSeries,ChartFunnelSeries,ChartPieSeries,Char
} }
returnArray = this.sortReturnArray(returnArray,groupFieldModel,allCodeList); returnArray = this.sortReturnArray(returnArray,groupFieldModel,allCodeList);
// 雷达图数据格式处理 // 雷达图数据格式处理
if(Object.is(item.type,'radar')){ if(Object.is(item.type,'radar') && returnArray.length >0){
returnArray.forEach((item:any) =>{ let tempReturnArray:Array<any> = [];
item.type = item[groupField[0]]; let seriesValues:Array<any> = item.seriesValues;
delete item[groupField[0]]; if(seriesValues && seriesValues.length >0){
}) seriesValues.forEach((singleSeriesName:any) =>{
let singleSeriesObj:any = {type:singleSeriesName};
returnArray.forEach((item:any) =>{
Object.assign(singleSeriesObj,{[item[groupField[0]]]:item[singleSeriesName]});
})
tempReturnArray.push(singleSeriesObj);
})
}
returnArray = tempReturnArray;
} }
console.log(JSON.stringify(returnArray)); console.log(JSON.stringify(returnArray));
return returnArray; return returnArray;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册