2016-12-27 95 views
0

我想使用谷歌圖表來表示我的技能水平在列圖表風格。但我不知道如何添加文字到我的Y軸。我試圖實現的是沿着x軸的技能以及像初學者,中級,高級和專家這樣的y軸水平。如何將文字添加到谷歌圖表柱形圖軸?

我的代碼:

google.load("visualization", "1", {packages:["corechart"]}); 
function drawData(){ 

var data = google.visualization.arrayToDataTable([ 

     ['Skill','Skill Level', { role: 'style' }], 
     ['Graphic Design', 8.94, 'blue'],    
     ['Branding', 21.45, 'red' ], 
     ['Photoshop CC', 21.45, 'green' ], 
     ['Illustrator CC', 200, 'yellow' ], 
    ]); 
var options = { 
    legend: {position: 'none'}, 
}; 
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); 
chart.draw(data, options); 
} 
google.setOnLoadCallback(drawData); 

回答

0

使用vAxis.ticks具有格式化值。看看這個生活的例子:https://jsfiddle.net/Balrog30/009nk1fp/

options.vAxis = { 
    ticks: [ 
    {v: 0, f: 'Nap Time'}, 
    {v: 2.5, f: 'Bored'}, 
    {v: 5, f: 'Productive'}, 
    {v: 7.5, f: 'Excited'}, 
    {v:10, f: 'Caffeine Overload'} 
    ] 
}