2014-05-12 262 views
0
谷歌圖表工具提示

我的圖表很簡單,是這樣的:用百分比

function drawVisualization() { 

    var data = google.visualization.arrayToDataTable([ 
    ['week', 'rate'], 
    ['1', 0.156], 
    ['2', 0.232], 
    ['3', 0.446], 
    ['4', 0.832], 
    ['5', 0.702], 
    ['6', 0.773], 
    ['7', 0.842], 
    ['8', 0.413], 
    ['9', 0.278], 
    ['10', 0.323], 
    ['11', 0.312], 
    ['12', 0.309], 
    ['13', 0.134], 
    ['14', 0.137] 
    ]); 

    new google.visualization.LineChart(document.getElementById('visualization')). 
     draw(data, {curveType: "function", 
        width: 500, height: 400, 
        vAxis: {maxValue: 1}} 
     ); 
} 

但我不知道如何對數據進行格式化欄,顯示作爲工具提示pecentage 。你們能幫忙嗎?

回答

3

使用的NumberFormatter:

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

您可能還需要格式化Y軸:

vAxis: { 
    maxValue: 1, 
    format: '#%' 
}