Highcharts触发后台点击事件
Highcharts trigger background click event
我正在使用 Highcharts 在单击背景时触发事件:
$("#my-chart").highcharts({
chart: {
type: "pie",
events: {
click: function() {
console.log("I'm working!"); // This is the event I want to trigger
};
}
}
});
var myChart = $("#my-chart").highcharts();
我想在单击图表外的内容时触发此事件。例如:
<button>Trigger the Highcharts Event!</button>
<script>
$("button").on('click', function() {
// I'd like to trigger the event here
// $('#my-chart').click(); does nothing
// myChart.chart.events.click(); does nothing
// myChart.events.click(); does nothing
// $('#my-chart').find('rect.highcharts-background').click() does nothing
});
</script>
如何以编程方式触发事件?
我尝试了几种方法来获取更多信息。查看 arguments.callee.caller.name
,值为 ""
(空字符串)。
arguments.callee.caller
给我以下内容:
function (a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}}
没有人有时间破译它!
更有用的信息是 event.target
,即 rect.highcharts-background
。触发点击什么都不做。绝对没有。我做了一些其他尝试,都在上面 $('button').click()
函数的注释中。
您可以添加 fireEvent
函数,然后从外部添加 trigger
这个函数。
我正在使用 Highcharts 在单击背景时触发事件:
$("#my-chart").highcharts({
chart: {
type: "pie",
events: {
click: function() {
console.log("I'm working!"); // This is the event I want to trigger
};
}
}
});
var myChart = $("#my-chart").highcharts();
我想在单击图表外的内容时触发此事件。例如:
<button>Trigger the Highcharts Event!</button>
<script>
$("button").on('click', function() {
// I'd like to trigger the event here
// $('#my-chart').click(); does nothing
// myChart.chart.events.click(); does nothing
// myChart.events.click(); does nothing
// $('#my-chart').find('rect.highcharts-background').click() does nothing
});
</script>
如何以编程方式触发事件?
我尝试了几种方法来获取更多信息。查看 arguments.callee.caller.name
,值为 ""
(空字符串)。
arguments.callee.caller
给我以下内容:
function (a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}}
没有人有时间破译它!
更有用的信息是 event.target
,即 rect.highcharts-background
。触发点击什么都不做。绝对没有。我做了一些其他尝试,都在上面 $('button').click()
函数的注释中。
您可以添加 fireEvent
函数,然后从外部添加 trigger
这个函数。