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

更新雷达图

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