2014-08-28 29 views
1

我有一個谷歌圖表與百分比值從0到100%(即0至1) 當我設置hAxis.gridlines.count爲10期望獲得網格線在0, 10, 20, ... 90, 100 我得到網格線0, 12, 24, 36, ..., 96, 108谷歌圖表hAxis.gridlines.count不按預期工作

我現在找不到任何解決方案。

這裏是我的代碼:

function getData() { 

    // Create the data table. 
    var data = new google.visualization.arrayToDataTable([ 
     ['Category', 'Fulfillment (%)'], 
     ['A', .75], 
     ['B', .50], 
     ['C', .50], 
     ['D', .30], 
     ['E', 0] 
    ]); 

    // Set chart options 
    var options = { 
     'title': 'My Title', 
     'height': 300, 
     'backgroundColor': 'none', 
     'hAxis': { 
      'maxValue': 1, 
      format: '#%', 
      gridlines: { 
       count: 10 
      } 
     }, 
     'colors': ['#F5821E'], 
     legend: { position: "none" } 
    }; 

    var formatter = new google.visualization.NumberFormat({ pattern: '#%' }); 
    formatter.format(data, 1); 

    // Instantiate and draw our chart, passing in some options. 
    var chart = new google.visualization.BarChart(document.getElementById('chart_div')); 
    chart.draw(data, options); 
} 

回答

4

閱讀the documentation,你可以看到,hAxis.gridlines.count指定線多少畫,不是在哪裏畫他們。您正在尋找的可能是hAxis.ticks

+2

差不多:)它是'hAxis.ticks'不是'gridlines.ticks' – 2014-08-28 16:10:44

0

使用count: 11而不是10。這將改變網格線的標籤。