
    function 柱状图(name){  
        this.名称 = name;
        this.chartData = [];
        this.legendData = [];
        this.xData = [];  
        
        this.置可视 = function (value){
            if(value==true){
                var div = document.getElementById(this.名称);
                div.style.display="";	                
            }else{
                var div = document.getElementById(this.名称);
                div.style.display="none"; //不占位               
            }
        } 

        this.置可视2 = function (value){
            if(value==true){
                var div = document.getElementById(this.名称);
                div.style.visibility="visible";	                
            }else{
                var div = document.getElementById(this.名称);
                div.style.visibility="hidden"; //占位               
            }
        } 

        this.置图表高度 = function (value){
            var div = document.getElementById(this.名称);
            div.style.setProperty("height",value);
        } 
        
        this.初始化= function(data1,data2){
            this.barChart = echarts.init(document.getElementById(name));
            this.chartData = [];
            this.legendData = data1;
            this.xData = data2;
            var option = {
                legend: {
                    data: data1
                },
                grid: {
                    x: 35,
                    x2: 10,
                    y: 30,
                    y2: 25
                },
                xAxis: [{
                    type: 'category',
                    data: data2
                }],
                yAxis: [{
                    type: 'value',
                    splitArea: {
                        show: true
                    }
                }],
                series: [{
                                name: 'name1',
                                type: 'bar',
                                data: []
                            }, {
                                name: 'name2',
                                type: 'bar',
                                data: []
                            }]
            };
            this.barChart.setOption(option);
            this.barChart.showLoading();//显示等待动画
        }

        this.添加数据=function(dataName,dataValue){
            var temp = '{ "name": dataName, "type": "bar", "data": dataValue }'; 
            temp = eval("(" + temp + ")");  //将字符串转换成json对象
            this.chartData.push(temp); //加入数组
        }

        this.添加完毕=function(){
            var option = {
                legend: {
                    data: this.legendData
                },
                grid: {
                    x: 35,
                    x2: 10,
                    y: 30,
                    y2: 25
                },
                xAxis: [{
                    type: 'category',
                    data: this.xData
                }],
                yAxis: [{
                    type: 'value',
                    splitArea: {
                        show: true
                    }
                }],
                series: this.chartData
            };
            this.barChart.hideLoading();//关闭等待动画
            this.barChart.setOption(option);    
        }

    }  


 