[英]Highcharts - Provide URL's for series data to open clickable link
我想在我的系列中的每個數據點添加一個url,當點擊的用戶被重定向到該頁面時。 例如jsfiddle 。
series:[{data: [ [123.12,'http://xyz.com'],[332.32,'http://zzs.com'] ] }]
我能夠得到點可點擊,但我如何讓他們找到我點擊的點和使用哪個網址我無法弄清楚。 我顯然可以通過使用存儲鏈接的替代數組來破解它...但我想使用圖表,因為它的意思。
現在它已被解決以供將來參考,以便能夠在這里添加鏈接到您的點是代碼:
這是一種方法( 在這里小提琴):
series: [{
name: 'Batch',
URLs: ['www.google.com', null, null, 'www.yahoo.com', null, null, 'www.cnn.com', null, null, 'www.minecraft.net'], // pass in array of URLs
data: [4375.48, 113599.39, 1278, 83950.12, 6579.65, 94582, 1285.65, 48700.39, 500, 62917.27],
color:'#b8ecce',
point: {
events: {
click: function() {
var someURL = this.series.userOptions.URLs[this.x]; // onclick get the x index and use it to find the URL
if (someURL)
window.open('http://'+someURL);
}
}
}
}],
你可以使用結構:
data:[{
y:10,
ownURL:'http://www.google.com'
},{
y:11,
ownURL:'http://www.google2.com'
},{
y:5,
ownURL:'http://www.google3.com'
}]
然后你就有能力“獲得”這個價值了
this.point.options.ownURL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.