高图:如何通过plotOptions.series.events处理触摸事件 [英] Highcharts: how to handle touch events via plotOptions.series.events

查看:202
本文介绍了高图:如何通过plotOptions.series.events处理触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Highcharts条形图上,当用户单击其中一个条形图时,其他数据将通过loadDetails功能加载到页面上的其他位置.

On a Highcharts bar chart, when the user clicks one of the bars, additional data is loaded elsewhere on the page via the loadDetails function.

loadDetails指定为图表的点击回调函数:

loadDetails is specified as a click callback function for a chart via plotOptions.series.events:

var chart = new Highcharts.Chart({
    defaultSeriesType: 'bar',
    ...
    plotOptions: {
        series: {
            events: {
                click: loadDetails
            }
        }
    },
    ...

});

function loadDetails() {
    ...
}

问题是我需要在移动设备上为touchstart事件调用相同的回调函数.

The problem is I need to call the same callback function for a touchstart event on mobile devices.

据我所知,似乎没有任何明显的方法可以通过Highcharts API添加触摸事件处理程序:

There doesn't seem to be any obvious way of adding a touch event handler via the Highcharts API as far as I could tell: http://api.highcharts.com/highcharts#plotOptions.series.events.

有人知道如何为触摸事件添加回调函数,或从触摸事件触发点击回调函数吗?

Has anyone got any idea how to add callback functions for touch events, or trigger the click callback function from a touch event?

推荐答案

是的,不支持这种方法,我建议您创建想法

Yeah, something like this is not supported, I advice you to create idea here.

我想到的唯一解决方法是使用 Element.on 函数可将自定义事件添加到图表上存在的元素.例如: http://jsfiddle.net/3bQne/269/

The only workaround which comes to my mind is use Element.on function to add custom events to elements which exists on a chart. For example: http://jsfiddle.net/3bQne/269/

    chart: {
        renderTo: 'container',
        events: {
            load: function(){
                var chart = this,
                    path = chart.series[0].tracker;

                path.on('click', function() {
                   alert("click");; 
                });
            }
        }
    }

这篇关于高图:如何通过plotOptions.series.events处理触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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