2012-02-01 28 views
4

我想在上面顯示的值我的專欄圖表 就像這個形象:如何顯示在列谷歌圖表API的頂部值

expected chart

但我想說明他們使用新的Google Chart API。 這是the site及其source code


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<script type="text/javascript" src="https://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
google.load("visualization", "1", {packages:["corechart"]}); 
google.setOnLoadCallback(drawChart); 
function drawChart() { 
var data = new google.visualization.DataTable(); 
data.addColumn('string', 'Month'); 
data.addColumn('number','a'); 
data.addColumn('number','v'); 
data.addColumn('number','c'); 
data.addColumn('number','e'); 
data.addRows(5); 
data.setCell(0, 0, 'dfa'); 
data.setCell(1, 0, 'Sdfa'); 
data.setCell(2, 0, 'Mdz'); 
data.setCell(3, 0, 'sd'); 
data.setCell(4, 0, 'Rsdr'); 
data.setCell(0, 1, 114); 
data.setCell(1, 1, 723); 
data.setCell(2, 1, 238); 
data.setCell(3, 1, 509); 
data.setCell(0, 2, 636); 
data.setCell(1, 2, 410); 
data.setCell(2, 2, 395); 
data.setCell(3, 2, 668); 
data.setCell(0, 3, 508); 
data.setCell(1, 3, 709); 
data.setCell(2, 3, 686); 
data.setCell(3, 3, 533); 
data.setCell(0, 4, 643); 
data.setCell(1, 4, 737); 
data.setCell(2, 4, 964); 
data.setCell(3, 4, 945); 
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')). 
draw(data, 
{title:"Parc localisé par région et par offre", 
width:500, height:300, 
series: {0:{color: '#CF0980', visibleInLegend: true}, 1:{color: '#999999', visibleInLegend: true}, 2:{color: '#990099', visibleInLegend: true}, 3:{color: '#FF99CC', visibleInLegend: true}},isStacked:"true"});} 
</script> 
</head> 
<body><div id="chart_div"></div> 
</body> 
</html> 
+0

請在這裏發表您的代碼。 – 2012-02-01 15:18:44

+0

你可以在我寫的鏈接上看到我的代碼(這裏是我的代碼) – YassineGeom 2012-02-01 15:47:40

+0

可能重複的[Google Visualization:Column Chart,簡單的問題卻找不到答案](http://stackoverflow.com/questions/5409060/google-visualization-column-chart-simple-question-but-can-find-the-answer) – 2012-06-04 15:53:37

回答

0

對於柱形圖它是不可能的。
https://groups.google.com/forum/?fromgroups=#!topic/google-visualization-api/2PxrqYv2ZBk

但是與此不建議使用的圖像圖表,它是: https://developers.google.com/chart/image/docs/chart_wizard 可以使用形狀與標記號碼類型,但它已被棄用所以沒有使用。

+0

可以使用柱形圖(我已經完成了),但是我必須編寫自己的方法來設置軸值,以確保頂部有足夠的空間用於註釋。 – sadpanda 2017-03-29 19:59:18

1

只需添加

annotations: { 
    alwaysOutside: true 
} 

的配置對象