Highcharts - 提供系列数据的URL以打开可点击链接

agr*_*lev 4 javascript highcharts

我想在我的系列中的每个数据点添加一个url,当点击的用户被重定向到该页面时.例如jsfiddle.

series:[{data: [ [123.12,'http://xyz.com'],[332.32,'http://zzs.com'] ] }]
Run Code Online (Sandbox Code Playgroud)

我能够得到点可点击,但我如何让他们找到我点击的点和使用哪个网址我无法弄清楚.我显然可以通过使用存储链接的替代数组来破解它...但我想使用图表,因为它的意思.

现在它已被解决以供将来参考,以便能够在这里添加链接到您的点是代码:

http://jsfiddle.net/awasM/2/

Mar*_*ark 11

这是一种方法(在这里小提琴):

                       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);
                                    }
                                }
                            }
                       }],
Run Code Online (Sandbox Code Playgroud)


Seb*_*han 5

你可以使用结构:

 data:[{
   y:10,
   ownURL:'http://www.google.com'
 },{
   y:11,
   ownURL:'http://www.google2.com'
 },{
   y:5,
   ownURL:'http://www.google3.com'
 }]
Run Code Online (Sandbox Code Playgroud)

然后你就有能力"获得"这个价值了

this.point.options.ownURL
Run Code Online (Sandbox Code Playgroud)