2012-07-29 26 views
3

我正在使用谷歌圖表顯示一些用戶統計信息。 如何刪除谷歌折線圖底部的文字?谷歌圖表刪除底部的文字

入住紅圈

http://i49.tinypic.com/se3cpj.jpg

+0

可能的複製:隱藏在谷歌圖表圖例(http://stackoverflow.com/questions/5202029/hiding-the-legend-in -google-chart) – 2012-07-29 17:11:33

+0

這只是刪除右邊的圖例 – Allen 2012-07-29 17:22:55

回答

3
hAxis: { textPosition: 'none' } 

這裏查看相關文件(搜索 「textPosition」):https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart

所以一個完整的,簡單的例子是這樣的:

google.charts.load('current', { packages: ['corechart', 'line'] }); 
google.charts.setOnLoadCallback(drawBasic); 

function drawBasic() { 

    var data = new google.visualization.DataTable(); 
    data.addColumn('number', 'X'); 
    data.addColumn('number', 'Dogs'); 

    data.addRows([ 
     [0, 0], [1, 10], [2, 23], [3, 17], [4, 18], [5, 9], 
     [6, 11], [7, 27], [8, 33], [9, 40], [10, 32], [11, 35], 
     [12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48], 
     [18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57], 
     [24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53], 
     [30, 55], [31, 60], [32, 61], [33, 59], [34, 62], [35, 65], 
     [36, 62], [37, 58], [38, 55], [39, 61], [40, 64], [41, 65], 
     [42, 63], [43, 66], [44, 67], [45, 69], [46, 69], [47, 70], 
     [48, 72], [49, 68], [50, 66], [51, 65], [52, 67], [53, 70], 
     [54, 71], [55, 72], [56, 73], [57, 75], [58, 70], [59, 68], 
     [60, 64], [61, 60], [62, 65], [63, 67], [64, 68], [65, 69], 
     [66, 70], [67, 72], [68, 75], [69, 80] 
    ]); 

    var options = { 
     hAxis: { 
      textPosition: 'none' 
     }, 
     vAxis: { 
      title: 'Popularity' 
     } 
    }; 

    var chart = new google.visualization.LineChart(document.getElementById('chart_div')); 

    chart.draw(data, options); 
} 

運行自己這裏代碼:​https://jsfiddle.net/p80uggL0/1/

+0

正在工作!謝謝 – Allen 2012-07-29 18:42:56

+0

不明原因的反對票是什麼?它不再有效嗎? – 2016-09-02 21:52:09

+0

它正在工作;除了一個脾氣暴躁的人散佈他們的脾氣外,我能想到的唯一事情就是與可視化遊樂場的聯繫不再起作用。更新爲jsfiddle,並更新了示例。 – 2016-09-02 21:57:32

0

嘗試改變x軸標籤字體顏色相同的背景顏色這樣

chart.draw(daily, { 
    hAxis : {textColor: '#ffffff'}, 
    [... your other options here ...] 
}); 

如果它不工作使用hAxis: {baselineColor: '#FFFFFF'}代替textColor,任何人這些應該工作。

+0

正在工作!現在不顯示,但仍然在這裏。有沒有任何選項可以刪除它? – Allen 2012-07-29 17:55:04

+0

不要試試#ffffff;像baselineColor:'none'。也請試試這個hAxis:{baselineColor:'none',網格線:{color:'none'}} – kiranvj 2012-07-29 17:55:57

0

如果是PieChart,然後像這樣。

傳說:{位置: '無'}

google.setOnLoadCallback(drawChart); 
    function drawChart() { 

    var data = google.visualization.arrayToDataTable([ 
     ['Task', 'Hours per Day'], 
     ['Work',  11], 
     ['Eat',  2], 
     ['Commute', 2], 
     ['Watch TV', 2], 
     ['Sleep', 7] 
    ]); 

    var options = { 
     title: 'My Daily Activities', 
     fontSize: 10, 
     legend : { position : 'none' } 
    }; 

    var chart = new google.visualization.PieChart(document.getElementById('piechart')); 

    chart.draw(data, options); 
    }