1. 程式人生 > >echarts-2.2.7柱狀圖隱藏y軸和x軸

echarts-2.2.7柱狀圖隱藏y軸和x軸

var dataNum = ["100","200","300","400","500","600"];     
var myChartfour = ec.init(document.getElementById('box-four'));             
    myChartfour.setOption({
   title : {
       text: '',
       subtext: ''
   },
   tooltip : {
       trigger: 'item',
       formatter: function(data){
        var txt =data.name+":   "+dataNum[data.dataIndex]+"人   ("+data.value+"%)";
           return txt;
       }
   },

   grid:{ 

   borderWidth:0,
   x:'10%',
   y:'15%',
   x2:'15%',
   y2:'15%',    
   },
   xAxis: [{
       type: 'value',
       max:100,
       show:false,
       boundaryGap:true,
       axisLabel:{
           margin:0
       },
       splitLine:{
           show:false,  //不顯示分割線         
       },  
   }
],
yAxis: [
   {
       type: 'category',
       position:'right',
       boundaryGap:false,
       axisTick:{
           show:false
       },
       // y 軸線
       axisLine:{
           show:false,        
       },  
       // 分割線設定
       splitLine:{
            lineStyle:{            
               width:2,
               color:"red",
           }      
       },
       axisLabel:{

       },
       //show:false,
       data: ['8:00-9:00','11:00-12:00','15:00-16:00','12:00-13:00','14:00-15:00','13:00-14:00',]
   }
],
   series : [
       {
           name:'',
           type:'bar',
           itemStyle : {
               normal: {
                   color: function(params) {
                       var colorList = [
                           '#ee4065','#2196f4','#6ccc00','#f9cb00','#c065ff',
                           '#41daea'
                       ];
                       return colorList[params.dataIndex]
                   },
                   label : {
                       show: true,
                       position: 'left',
                       formatter:function(params){
                           return params.value+'%';
                       }
                   }
               },
               emphasis:{
                   label : {
                       show: true,
                       textStyle:{
                           fontSize:12
                       }

                   }
               }
           },
           data:[10,20,30,40,50,60]           
       }
   ]

});