点击图表上的点击事件 [英] Click event on clicking on the graph

查看:101
本文介绍了点击图表上的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列用高图形绘制的线图,并且它们之间共享工具提示。

http://jsfiddle.net/FhF3A/

  $('# (
tooltip:{
shared:true
},
series:[{
name:'Berlin',
data :[-0.9,0.6,3.5,8.4,13.5,17.0,18.6,17.9,14.3,9.0,3.9,1.0]
},{
名称:'伦敦',
数据:[-0.9,0.6,3.5,8.4,13.5,17.0,18.6,17.9,14.3,9.0,3.9,1.0] [3.9,4.2,5.7,8.5,11.9,15.2,17.0,16.6,14.2,10.3,6.6,4.8]
}]
});

捕获dblclick事件并在图形上获取悬停y轴值的最佳方法是什么?

解决方案

这在 /jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/stock/chart/events-click/rel =nofollow noreferrer>这



所以你必须在你的代码中加入这样的内容:

 图表:{
events:{
click:function(event){
alert(
'x:'+ Highcharts.dateFormat('%Y-%m-% d',event.xAxis [0] .value)+','+
'y:'+ event.yAxis [0] .value
);





$ b

这是一个示例



更新



为确保点击图形本身也已启用,请添加以下内容:

  plotOptions:{
series:{
cursor:'pointer',
point:{
events:{
click:function(){
alert ('Category:'+ this.category +',value:'+ this.y);
}
}
}
}
},

你可以看到一个有效的例子这里


I have a series of line graph plotted with highcharts and the tooltip is shared among them.

http://jsfiddle.net/FhF3A/

 $('#container').highcharts({
        tooltip: {
            shared: true
        },
        series: [{
            name: 'Berlin',
            data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
        }, {
            name: 'London',
            data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
        }]
    });

What should be the best way to capture the dblclick event and obtain the hover y axis value on the graph ?

解决方案

This is explained fairly well in the documentation.

What you can do is something similar to THIS.

So you have to add something like this to your code:

chart: {
            events: {
                click: function(event) {
                    alert (
                    'x: '+ Highcharts.dateFormat('%Y-%m-%d', event.xAxis[0].value) +', ' +
                    'y: '+ event.yAxis[0].value
                    );
                }
            }
        }

Here is an example of that implementation.

Update

To ensure clicking on the graph itself is also enabled, add the following:

plotOptions: {
    series: {
         cursor: 'pointer',
         point: {
             events: {
                click: function() {
                    alert ('Category: '+ this.category +', value: '+ this.y);
                }
            }
        }
    }
},

You can see a working example HERE

这篇关于点击图表上的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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