type : 'category',
boundaryGap : false
}
],
yAxis : [
{
type : 'value',
axisLabel : {
formatter: '{value}'
}
}
] } //echarts 初始化参数
},
methods:{
table : function(ev){
if(this.rowOrColumn){
this.indicators=this.listToRowObject(this.initData);
this.mapOptions= this.listToColumnMap(this.initData);
this.rowOrColumn=false;
}else{
this.indicators=this.listToColumnObject(this.initData);
this.mapOptions= this.listToRowMap(this.initData);
this.rowOrColumn=true;
}
for(var i=0;i<this.mapOptions.length;i++){
var indicatorName= this.mapOptions[i].title.text;
var dom = document.getElementById([indicatorName])
var heigth = $(dom).siblings('div').height()*1.5;
var width = $(dom).siblings('div').width();
$(dom).css({
height:heigth,
width:width
});
var myChart= echarts.init(document.getElementById([indicatorName]),'macarons');
myChart.setOption(this.mapOptions[i]);
}
ev.stopPropagation();
},
listToRowObject :function (ListAndList){
var indicatorNames=[];
var tableDatas=[];
var columns = [];
var options = [];
ListAndList = ListAndList.indicatorResult;
for(var i=0;i<ListAndList.indicatorNames.length;i++){
var objects=[];
var column =[];
var indicatorName = ListAndList.indicatorNames[i];
for(var yIndex in ListAndList[indicatorName]){
var obj = {};
obj[indicatorName]=ListAndList.colKeys[yIndex];
for(var xIndex in ListAndList[indicatorName][yIndex]){
obj[ListAndList.rowKeys[xIndex]]=ListAndList[indicatorName][yIndex][xIndex];
}
objects.push(obj);
}
indicatorNames.push(indicatorName);
column.push(indicatorName);
column=column.concat(ListAndList.rowKeys);
var indicator={};
indicator[indicatorName]=objects;
columns.push(column);
tableDatas.push(indicator);
}
for(var j = 0; j<indicatorNames.length;j++){
var indicatorObj = {};
indicatorObj["tableData"]=tableDatas[j][indicatorNames[j]];
indicatorObj["columns"] = columns[j];
indicatorObj["indicatorName"] = indicatorNames[j];
options.push(indicatorObj);
}
return options;
},
listToColumnObject :function (ListAndList) {
var options = [];
var columns = [];
var indicatorNames = [];
var indicatorMap = {};
ListAndList = ListAndList.indicatorResult;
for (var i = 0; i < ListAndList.indicatorNames.length; i++) {
var column = [];
var objs = [];
var indicatorName = ListAndList.indicatorNames[i];
indicatorNames.push(indicatorName);
column.push(indicatorName);










