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.init=function(obj){
	EchartsBase();
	EchartsBase.mainDiv= echarts.init(document.getElementById(obj.id));
	EchartsBase.data= obj.data;
};

//柱形图
EchartsBase.barChart=function(obj){
	EchartsBase.init(obj);
	var title = EchartsBase.data.title;
	var xAxis = EchartsBase.data.xAxis;
	var legends = EchartsBase.data.legend;
	
	var xdata = [];
	var ser = [];
	legends.forEach(function(item,index){
		xdata[index] = item.name;
		var ydata = {};
		ydata.name = item.name;
		ydata.type = 'bar';
		ydata.data = item.data;
		ydata.itemStyle = {"color":item.color};
		ser[index] = ydata;
	})
	
	// 指定图表的配置项和数据
    var option = {
        title: {
            text: EchartsBase.data.title
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend:{'data':xdata},
        xAxis: {
        	type : 'category',
        	data: xAxis
        },
        yAxis: [{type:"value"}],
        series : ser
       
    };

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