2017-04-02 152 views
1

在Vuejs2.0組件中使用Echarts3.0,我試圖在堆積條形圖中的y軸上指定百分比。我嘗試了boundaryGap,splitnumber等,但都沒有工作。 但我無法實現它,任何人都有想法我怎麼能得到Y軸%?Echarts3.0顯示堆積條形圖中y軸的百分比

export default { 
    data:() => ({ 
    loading: true, 
    bar: {    
    xAxis: { 
      type: 'category', 
      data: ['Location1','Location2'] 
     }, 
    yAxis: { 
      type: 'value', 
      splitNumber: 10, 
      boundaryGap: ['0', '100%'], 
      min:0, 
      max:100, 
      scale:true, 
      splitArea : {show : true}, 
      label: { 
       formatter: function(){ 
       return 100 * value /$(this.axis.tickPositions).last()[0]        
       + '%'; 
         } 
        } 
      }, 
    series: [ 
      { 
       name: 'Location1', 
       type: 'bar', 
       stack: 'one', 
       label: { 
        normal: { 
         show: true, 
         position: 'insideRight' 
        } 
       }, 
       data: [1100, 2050] 
      }, 
      { 
       name: 'Location2', 
       type: 'bar', 
       stack: 'one', 
       label: { 
        normal: { 
         show: true, 
         position: 'insideRight' 
        } 
       }, 
       data: [291064, 34789] 
      } 
     ] 
     } 

})

回答

0

集YAXIS以下格式

yAxis: [{ 
    type: "value", 
    name: "%", 
    axisLabel: { 
    formatter: "{value} %" 
    } 
}]