function EchartsBase(){
	//图形容器
	EchartsBase.mainDiv=null;
	//柱图数据格式
	//EchartsBase.data={"title":"本周运维告警统计",xAxis: ["监控","NVR","服务器","应用系统"],"legend":[{"name":"Doset","data":[5, 20, 36, 50],"color":"#00accb"},{"name":"Yeland","data":[51, 210, 36, 10],"color":"#fa102a"}]};
	//柱形+折线图数据格式    折线图数据格式
	//EchartsBase.data={"title":"本周运维告警统计",xAxis: ["监控","NVR","服务器","应用系统"],"legend":[{"name":"Doset","data":[5, 20, 36, 50],"color":"green"},{"name":"Yeland","data":[51, 210, 36, 10],"color":"blue"},{"name":"Yeland1","data":[21,12,13,14],"color":"red"}]};
	//饼图数据格式
	//EchartsBase.data={"title":"本周运维告警统计",data:[{name:"直接访问",value:335,color:"red"},{name:"邮件营销",value:310,color:"blue"},{name:"联盟广告",value:234,color:"green"},{name:"视频广告",value:135,color:"yellow"},{name:"搜索引擎",value:1548,color:"pink"}]};

}
//饼图
//EchartsBase.pieChart();

EchartsBase.init=function(obj){
	EchartsBase();
	EchartsBase.mainDiv= parent.echarts.init(obj.idObj);
	EchartsBase.data= obj.data;
};

//饼图
EchartsBase.circularGraphChart=function(obj){
	EchartsBase.init(obj);
	var legendArr=[],seriesArr=[],colorArr=[];
	for(var i=0,len=EchartsBase.data.data.length;i<len;i++){
		legendArr.push(EchartsBase.data.data[i].name);
		seriesArr.push({name:EchartsBase.data.data[i].name,value:EchartsBase.data.data[i].value});
		colorArr.push(EchartsBase.data.data[i].color);
	}
	
	var option = {
		    title : {
		        text: EchartsBase.data.title,
		        left:"10px",
		        textStyle:{
		        	color:"black",
		        	fontStyle:"normal",
		        	fontSize:"16px"
		        }
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: '10px',
		        top:"50px",
		        data:[]
		    },
		    series : [
		        {
		            name: EchartsBase.data.seriesName,
		            type: 'pie',
		            radius : [ '50%', '80%' ],
		            center: ['50%', '50%'],
		            color:colorArr,
		            data:seriesArr,
		            label: {
		            	 normal: {
		            		   show:true,
			                    position: 'center',
			                    formatter: '{d}%',
			                    fontSize:18
		                 },
		                 emphasis: {
		                     show: true,
		                     position: 'center',
		                     textStyle: {
		                         fontSize: '20',
		                         fontWeight: 'bold'
		                     }
		                 }
		            }
		        }
		    ]
		};

    // 使用刚指定的配置项和数据显示图表。
    EchartsBase.mainDiv.setOption(option);
};

//饼图
EchartsBase.pieChart=function(obj){
	EchartsBase.init(obj);
	var legendArr=[],seriesArr=[],colorArr=[];
	for(var i=0,len=EchartsBase.data.data.length;i<len;i++){
		legendArr.push(EchartsBase.data.data[i].name);
		seriesArr.push({name:EchartsBase.data.data[i].name,value:EchartsBase.data.data[i].value});
		colorArr.push(EchartsBase.data.data[i].color);
	}
	
	var option = {
		    title : {
		        text: EchartsBase.data.title,
		        left:"10px",
		        textStyle:{
		        	color:"black",
		        	fontStyle:"normal",
		        	fontSize:"16px"
		        }
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        right:14,
		        top:0,
		        height:222,
		        itemGap:0.2,
		        textStyle:{
		        	fontSize:12,
		        	color:"#fff"
		        }
		    },
		    series : [
		        {
		            name: '故障检测',
		            type: 'pie',
		            radius : '90%',
		            center: ['32%', '54%'],
		            color:colorArr,
		            data:seriesArr,
		            roseType: 'radius',
		            label: {
	                    position: 'inner',
	                    formatter: '{d}%',
	                    align:"center",
	                    fontSize:"12px",
	                    verticalAlign:"bottom"
		            },
		            itemStyle: {
		                emphasis: {
	
		                }
		            }
		        }
		    ]
		};

    // 使用刚指定的配置项和数据显示图表。
    EchartsBase.mainDiv.setOption(option);
};


//折线图
EchartsBase.lineChart=function(obj){
	EchartsBase.init(obj);
	var option = {
		    tooltip: {
		    },
		    grid:{
		    	show:true,
		    	bottom:0,
		    	left:0,
		    	height:184,
		    	width:380,
		    	containLabel: true,
		    	borderColor:"#0b3d70",
		    },
		    xAxis:  {
		        boundaryGap: false,
		        axisLine:{
	     		       show:true,
	     		       lineStyle:{
	     		           color:"#0d3c70"
	     		       }
	     		   },
	     		   splitLine:{
   		              show:true,
		   		      lineStyle:{
		   		           color:"#0d3c70"
		   		       }
	     		 },
		        data: EchartsBase.data.xAxis,
		        axisLabel:{
		        	  interval:0,  
		             rotate:45,
		        	  color:"#699cd3"
		        }
		    }, 
		    yAxis: {
		        type: 'value',
		        axisLine:{
     		       show:true,
     		       lineStyle:{
     		           color:"#0d3c70"
     		       }
     		   },
     		   splitLine:{
		              show:true,
		   		      lineStyle:{
		   		           color:"#0d3c70"
		   		       }
	     		 },
		        axisLabel: {
	            	color:"#699cd3",
	            	formatter: function (value, index) {
	   	            	if(value.length>4)
	   	            		return value.substring(0,4)+"...";
	   	            	else
	   	            		return value;
	   	            },
        			interval:0
		        }
		    },
		    series: [
		        {
		            name: EchartsBase.data.legend[0].name,
		            type:'line',
		            areaStyle:{
		            	color:"#18446b",
		            	opacity:0.7
		            },
		            data: EchartsBase.data.legend[0].data,
		            itemStyle:{
		            	normal : {  
		            		lineStyle:{  
		            			color:EchartsBase.data.legend[0].color
		            		}  
		            	}
		            }
		        }
		    ]
		};

    // 使用刚指定的配置项和数据显示图表。
    EchartsBase.mainDiv.setOption(option);
};


//柱形图
EchartsBase.barChart=function(obj){
	EchartsBase.init(obj);
	// 指定图表的配置项和数据
    var option = {
        title: {
            text: EchartsBase.data.title
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid:{
        	show:true,
	    	bottom:0,
	    	left:0,
	    	height:184,
	    	width:380,
	    	containLabel: true,
	    	borderColor:"#0b3d70",
        },
        xAxis: {
        	type : 'category',
            boundaryGap: true,
            nameRotate:82,
            data:  EchartsBase.data.xAxis,
	        axisLabel: {
	            formatter: function (value, index) {
	            	if(value.length>4)
	            		return value.substring(0,4)+"...";
	            	else
	            		return value;
	            },
	            rotate:45,
            	color:"#699cd3",
            	width:12,
            	height:12,
    			interval:0
	        },
	        axisLine:{
  		       show:true,
  		       lineStyle:{
  		           color:"#0d3c70"
  		       }
  		   },
  		   splitLine:{
	              show:true,
	   		      lineStyle:{
	   		           color:"#0d3c70"
	   		       }
  		 }
        },
        yAxis: [
                {
                	type:"value",
                    boundaryGap: true,
		        	axisLabel: {
			            formatter: '{value}',
			        	color:"#699cd3",
						interval:0
					},
					axisLine:{
		     		       show:true,
		     		       lineStyle:{
		     		           color:"#0d3c70"
		     		       }
		     		   },
		     		   splitLine:{
	   		              show:true,
			   		      lineStyle:{
			   		           color:"#0d3c70"
			   		       }
		     		 }
                }],
		        series: [{
		            name: EchartsBase.data.legend[0].name,
		            type: 'bar',
					barWidth:40,
		            data: EchartsBase.data.legend[0].data,
		            itemStyle:{
		            	normal:{
		            		  color: new echarts.graphic.LinearGradient(
		                              0, 0, 0, 1,
		                              [
		                                  {offset: 0, color: '#d04a41'},
		                                  {offset: 0.5, color: '#cf844b'},
		                                  {offset: 1, color: '#d0ce45'}
		                              ]
		                          )
		            	}
		            }
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    EchartsBase.mainDiv.setOption(option);
};

//饼图
EchartsBase.workOrderGraphChart=function(obj){
	EchartsBase.init(obj);
	var legendArr=[],seriesArr=[],colorArr=[];
	for(var i=0,len=EchartsBase.data.data.length;i<len;i++){
		legendArr.push(EchartsBase.data.data[i].name);
		seriesArr.push({name:EchartsBase.data.data[i].name,value:EchartsBase.data.data[i].value});
		colorArr.push(EchartsBase.data.data[i].color);
	}
	
	var option = {
		    title : {
		        text: EchartsBase.data.title,
		        left:"10px",
		        textStyle:{
		        	color:"black",
		        	fontStyle:"normal",
		        	fontSize:"16px"
		        }
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        right:14,
		        top:0,
		        height:222,
		        itemGap:0.2,
		        textStyle:{
		        	fontSize:12,
		        	color:"#fff"
		        }
		    },
		    series : [
		        {
		            name: EchartsBase.data.seriesName,
		            type: 'pie',
		            radius : [ '40%', '70%' ],
		            center: ['50%', '50%'],
		            color:colorArr,
		            data:seriesArr,
		            label: {
		            	 normal: {
		            		   show:true,
			                    formatter: '{d}%',
			                    fontSize:12,
			                    color:"#fff"
		                 },
		                 emphasis: {
		                     show: true,
		                     position: 'center',
		                     textStyle: {
		                         fontSize: '14',
		                         fontWeight: 'bold'
		                     }
		                 }
		            }
		        }
		    ]
		};

    // 使用刚指定的配置项和数据显示图表。
    EchartsBase.mainDiv.setOption(option);
};

//监控设备力引导图
EchartsBase.relationalGraph1=function(obj){
	EchartsBase.init(obj);
	var mainDiv=EchartsBase.mainDiv;
	var option = {
	        legend: {
	            data: []
	        },
	       tooltip:{
	    	   show:true,
	    	   formatter: function (params) {
		    		var dataType=params.dataType;
		    		if(dataType=="node"){
			    	    return '<ul>\
						<li style="height:30px;line-height:30px;font-size:13px;"><span>设备名称：</span><span  id="show_sbmc">'+(params.data.channelname||params.data.machinename)+'</span></li>\
						</ul>';
		    		}
			   }},
	        series: [{
	        	name:"graph",
	            type: 'graph',
	            layout: 'force',
	            focusNodeAdjacency: true,
	            label: {
				    show: true,
				    color:'green',
				    distance:4,
				    position:'bottom'
				 },
	            draggable: true,
	            symbolSize :[52,52],
	            nodes:	EchartsBase.data.nodes ,
	            links: EchartsBase.data.links,
	            categories:EchartsBase.data.categories,
	            force: {
	                edgeLength: 150,
	                repulsion: 20,
	                gravity: 0.01,
	                layoutAnimation :false
	            } 
	        }]
	    };
	EchartsBase.mainDiv.setOption(option);
	mainDiv.on("mouseover",function(p){
		var type=p.dataType;
		if(type=='node'){
			   var dataIndex=p.dataIndex;
			   var symbol=p.data.symbol;
			   symbol=symbol.replace("Active","");
			   symbol=symbol.substring(0,symbol.length-4);
			   symbol+='Active.png';
			   //mainDiv._model.option.series[0].nodes[dataIndex].symbol =symbol;
		   	//	mainDiv.setOption(option);
		   	/*	mainDiv.dispatchAction({
		        	    type: 'highlight',
		        	    seriesIndex: 0,
		        	    dataIndex: dataIndex
		        	});*/
		   		mainDiv.dispatchAction({
	        	    type: 'focusNodeAdjacency',
	        	    seriesIndex: 0,
	        	    dataIndex: dataIndex
	        	});
			}
		})
		mainDiv.on("mouseout",function(p){
			var type=p.dataType;
			if(type=='node'){
			   var dataIndex=p.dataIndex;
			   var symbol=p.data.symbol;
			   symbol=symbol.replace("Active","");
		//	   mainDiv._model.option.series[0].nodes[dataIndex].symbol =symbol;
		   	//	mainDiv.setOption(option);
/*				mainDiv.dispatchAction({
		        	    type: 'downplay', 
			      	    seriesIndex: 0,
			      	    dataIndex: dataIndex
				});*/
		   		mainDiv.dispatchAction({
	        	    type: 'unfocusNodeAdjacency',
	        	    seriesIndex: 0,
	        	    dataIndex: dataIndex
	        	});
			}
		});
	
	// 使用刚指定的配置项和数据显示图表。
};
//服务器设备力引导图
EchartsBase.relationalGraph2=function(obj){
	EchartsBase.init(obj);
	var mainDiv=EchartsBase.mainDiv;
	var option = {
			legend: {
				data: []
			},
			tooltip:{
				show:true,
				enterable:false,
				formatter: function (params) {
					var dataType=params.dataType;
					if(dataType=="node"){
						return '<ul>\
						<li style="height:30px;line-height:30px;font-size:13px;"><span>设备名称：</span><span  id="show_sbmc">'+(params.data.channelname||params.data.machinename)+'</span></li>\
						</ul>';
					}
				}},
				animation:false,
				series: [{
					name:"graph",
					type: 'graph',
					layout: 'none',
					animation: false,
					hoverAnimation:false,
					label: {
						show: true,
						color:'green',
						distance:4,
						position:'bottom'
					},
					draggable: false,
			
					nodes:	EchartsBase.data.nodes ,
					links: EchartsBase.data.links,
					categories:EchartsBase.data.categories,
					force: {
						edgeLength: 150,
						repulsion: 20,
						gravity: 0.01,
						layoutAnimation :false
					} 
				}]
	};
	EchartsBase.mainDiv.setOption(option);
	mainDiv.on("mouseover",function(p){
		var type=p.dataType;
		if(type=='node'){
			var dataIndex=p.dataIndex;
			var symbol=p.data.symbol;
			symbol=symbol.replace("Active","");
			symbol=symbol.substring(0,symbol.length-4);
			symbol+='Active.png';
			option.series[0].nodes[dataIndex].symbol =symbol;
			//mainDiv.setOption(option);
		}
	})
	mainDiv.on("mouseout",function(p){
		/*	var type=p.dataType;
			if(type=='node'){
			   var dataIndex=p.dataIndex;
			   var symbol=p.data.symbol;
			   symbol=symbol.replace("Active","");
		   		option.series[0].nodes[dataIndex].symbol =symbol;
		   		mainDiv.setOption(option);
			}*/
	});
	
	// 使用刚指定的配置项和数据显示图表。
};


//树图
EchartsBase.treeGraph=function(obj){
	EchartsBase.init(obj);
	var option = {
	        tooltip: {
	            trigger: 'item',
	            triggerOn: 'mousemove'
	        },
	        series:[
	            {
	                type: 'tree',
	                data: [EchartsBase.data],
	                left: '2%',
	                right: '2%',
	                top: '8%',
	                bottom: '20%',

	                symbol: 'emptyCircle',

	                orient: 'vertical',

	                expandAndCollapse: true,

	                label: {
	                    normal: {
	                        color:"#fff",
	                        align: 'center',
	                        fontSize: 12,
	                        distance:4,
	                        verticalAlign: 'middle',
	                        position:'bottom'
	                    }
	                },

	                leaves: {
	                    label: {
	                        normal: {
	                        	color:"#fff",
	                        	align: 'center',
	                        	fontSize: 12,
	                        	verticalAlign: 'middle',
	                            rotate: -90,
	                        	distance:34,
	                        	position:'bottom'
	                        }
	                    }
	                },

	                animationDurationUpdate: 750
	            }
	        ]
	    };
	// 使用刚指定的配置项和数据显示图表。
	EchartsBase.mainDiv.setOption(option);
};