Highcharts 自定义事件插件右键单击事件未触发
Highcharts custom events plugin right click event not firing
http://jsfiddle.net/ovbpacrt/1/
我无法在上面的右键单击中触发 contextmenu
事件。
chart = new Highcharts.Chart(
{
series:[
{
"data": data,
type: 'pie',
animation: false,
point:{
events:{
contextmenu: function (event) {
alert(this.id);
}
}
}
}
],
"chart":{
"renderTo":"container"
},
});
如果我将 contextmenu
更改为 click
(而不是单击鼠标左键),那么该事件将正常运行。
问题的可能原因是什么?
您不能使用原始 github 文件,因为它们会被 CORS 阻止。
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/blacklabel/custom_events/master/js/customEvents.js with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
尝试使用 CDN https://cdn.jsdelivr.net/npm/highcharts-custom-events@2.2.4/js/customEvents.min.js
在这里您可以了解更多关于如何在没有 CDN 的情况下绕过它的方法 https://gist.github.com/jesperorb/6ca596217c8dfba237744966c2b5ab1e
http://jsfiddle.net/ovbpacrt/1/
我无法在上面的右键单击中触发 contextmenu
事件。
chart = new Highcharts.Chart(
{
series:[
{
"data": data,
type: 'pie',
animation: false,
point:{
events:{
contextmenu: function (event) {
alert(this.id);
}
}
}
}
],
"chart":{
"renderTo":"container"
},
});
如果我将 contextmenu
更改为 click
(而不是单击鼠标左键),那么该事件将正常运行。
问题的可能原因是什么?
您不能使用原始 github 文件,因为它们会被 CORS 阻止。
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/blacklabel/custom_events/master/js/customEvents.js with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
尝试使用 CDN https://cdn.jsdelivr.net/npm/highcharts-custom-events@2.2.4/js/customEvents.min.js
在这里您可以了解更多关于如何在没有 CDN 的情况下绕过它的方法 https://gist.github.com/jesperorb/6ca596217c8dfba237744966c2b5ab1e