我在这里的谷歌图表游戏场上玩了很多谷歌图表:
我一直在玩的代码是这样的:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria'],
['2003', 1336060],
['2004', 1538156],
['2005', 1576579],
['2006', 1600652],
['2007', 1968113],
['2008', 1901067]
]);
// Create and draw the visualization.
new google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
vAxis: {title: "Year"},
hAxis: {title: "Cups"}}
);
}
这给了我一个很好的图表,看起来像这样:
我正在尝试使此图表适合我的网站的需求,为此,我需要将左侧的栏名称链接到另一个页面。因此,例如 2003 将是用户可以单击的链接,2004 等也是如此。
我试图做这样的事情:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria'],
['<a href="url">Link text</a>', 1336060],
['2004', 1538156],
['2005', 1576579],
['2006', 1600652],
['2007', 1968113],
['2008', 1901067]
]);
// Create and draw the visualization.
new google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
vAxis: {title: "Year"},
hAxis: {title: "Cups"}}
);
}
但我只能希望它变得那么容易,但事实并非如此。有谁知道这是否可能?