2014-06-25 144 views
1

顯示鋸齒狀標籤我在谷歌圖表顯示中的問題,在x軸,所述標籤是顯示在Z字形這樣谷歌圖表在x軸

enter image description here

我想它這樣enter image description here

var data = new google.visualization.DataTable(); 
     data.addColumn('string','Mois'); 
    data.addColumn('number', 'Depense'); 
    data.addColumn('number', 'Depasse'); 




      new google.visualization.ColumnChart(document 
            .getElementById('visualizationNatM')) 
            .draw(data, { 
             width:viewport.width, 
             height : viewport.height - 400, 

             isStacked : true, 
             legend : { 
              position : 'none' 
             }, 
             sortData: false, 
             hAxis : { 
              gridlines : { 
               count : 12 
              } 
             }, 
             colors : [ '#a8cf04', '#d44c33' ], 
             backgroundColor : '#FFFFFF', 
             chartArea : { 
              left : 70 
             } 
            }); 

任何一個有解決這個問題呢?

回答

3

嘗試設置hAxis.maxAlternationhAxis.showTextEveryhAxis.minTextSpacing選項:

hAxis : { 
    gridlines : { 
     count : 12 
    }, 
    maxAlternation: 1, // use a maximum of 1 line of labels 
    showTextEvery: 1, // show every label if possible 
    minTextSpacing: 8 // minimum spacing between adjacent labels, in pixels 
} 
+0

謝謝您的答覆,我修改了像你提到,但低於個月(J,S,N,J,M,M)是不顯示 –

+0

您可能還需要設置'hAxis.showTextEvery'和'hAxis.minTextSpacing'選項。查看更新的答案。還有一些其他的'hAxis' [選項](https://developers.google.com/chart/interactive/docs/gallery/columnchart#Configuration_Options)可能會對您有用,也可能不會對您有用。 – asgallant

+0

謝謝你解決了這個問題 –