[英]Retrieve annotation text in Google Charts
我的網站上有一個Google圖表,當用戶單擊值時,我想將用戶重定向到其他頁面。
為此,我正在使用select事件,如下所示:
google.visualization.events.addListener(chart, 'select', function() {
// Selected item
var item = chart.getSelection()[0];
});
問題是我不知道如何獲取所需的批注文本。 一個簡單的例子將在這里有用。 例如, 在此圖表中 ,如果我單擊藍線的最高點,我想檢索文本:“ G”。 僅此文本,我就不需要“ Cats:8”。
這可能嗎? 我該怎么辦?
通過使用data.getValue()
google.visualization.events.addListener(chart, 'select', function(args) {
if (chart.getSelection().length>0) {
var selection = chart.getSelection()[0];
var annotationText=data.getValue(selection.row, 0);
//redirect with annotationText = 'D' here
//..
}
});
參見上面基於Google操場示例的小提琴-> http://jsfiddle.net/F7WVG/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.