使Highcharts中的系列可点击 [英] making series in Highcharts clickable

查看:75
本文介绍了使Highcharts中的系列可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使高图表中的系列可点击吗?就像您单击其中一个项目一样,它将带您到外部链接?

Does anyone know how to make the series in the highcharts clickable? as in if you click one of the items it will take you to an external link?

我仔细阅读了文档,但在高级图表中找不到选项.

I looked through the documentation and could not find an option in the highcharts.

http://www.highcharts.com/docs/chart-concepts/series

这是文档中提供的小提琴.如果有人能使该系列变得可点击,那就太棒了!

Here is the fiddle provided in the doc. if anyone could make the series clickable that would be awesome!!

谢谢!

推荐答案

您可以在点对象中设置url(或使用全局对象),捕获点上的click事件并运行window.location.

You can set url in your point object (or use global), catch click event on points and run window.location.

plotOptions: {
                 series: {
                     cursor: 'pointer',
                     point: {
                         events: {
                             click: function () {
                                 var url = this.options.url;
                                 window.open(url);
                             }
                         }
                     },
                 }
             },
    series: [{
                 data: [{
                     x: 0,
                     y: 29.9,
                     url: 'http://www.google.com'
                 }, {
                     x: 1,
                     y: 71.5,
                     url: 'http://www.yahoo.com'
                 }]
             }]

http://jsfiddle.net/287JP/2/

这篇关于使Highcharts中的系列可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆