Javascript Highcharts删除批注时抛出类型错误
我正在使用highcharts,并试图通过调用Javascript Highcharts删除批注时抛出类型错误,javascript,highcharts,Javascript,Highcharts,我正在使用highcharts,并试图通过调用chart.removeAnnotation(chart.currentAnnotation)删除当前选定的注释,该操作正常,但会导致应用程序抛出 Uncaught TypeError: Cannot read property 'forEach' of undefined at g.setControlPointsVisibility 以下是代码的相关部分: 选择权 chart:{ events:{ load : func
chart.removeAnnotation(chart.currentAnnotation)
删除当前选定的注释,该操作正常,但会导致应用程序抛出
Uncaught TypeError: Cannot read property 'forEach' of undefined at g.setControlPointsVisibility
以下是代码的相关部分:
选择权
chart:{
events:{
load : function(){
var chart = this;
document.querySelectorAll('.my-toolbar-classname .dbtn')[0]
.addEventListener('click',function(){
chart.removeAnnotation(chart.currentAnnotation)
})
}
}
},
navigation:{
//other events are skipped here
events: {
showPopup: function(event){
if (!this.annotationsPopupContainer) {
this.annotationsPopupContainer=them.toolbarPopup.current;
}
if (event.formType === 'annotation-toolbar') {
this.chart.currentAnnotation = event.annotation;
}
}
}
}
上述配置正确地删除了注释,但当我尝试向图表添加另一个注释时,错误就会弹出。Hi@saeed ghotb,你能在一些在线代码编辑器中创建一些问题的实例吗?Hi@ppotaczek。谢谢你的回复。我看了更多,发现这似乎正是我陷入的困境。这里提供的例子可能足够了。不知道是否需要做一些额外的工作来执行注释删除。您使用哪个Highcharts版本?您提供的问题已解决,因此该问题不应出现在当前版本中。react包装器不应影响该问题。github版本的演示没有显示最新版本中的错误:由您创建一些实时示例将非常有帮助。@ppotaczek我非常抱歉回复太晚,这里是周末!!因此,我以全新的眼光查看错误并调用chart.navigationBindings.deselectAnnotation()解决了这个问题;就在调用chart.removeAnnotation(currentAnntin)之前,是answerHi@saeed ghotb,你能在一些在线代码编辑器中创建一些问题的实例吗?Hi@ppotaczek。谢谢你的回复。我看了更多,发现这似乎正是我陷入的困境。这里提供的例子可能足够了。不知道是否需要做一些额外的工作来执行注释删除。您使用哪个Highcharts版本?您提供的问题已解决,因此该问题不应出现在当前版本中。react包装器不应影响该问题。github版本的演示没有显示最新版本中的错误:由您创建一些实时示例将非常有帮助。@ppotaczek我非常抱歉回复太晚,这里是周末!!因此,我以全新的眼光查看错误并调用chart.navigationBindings.deselectAnnotation()解决了这个问题;就在调用chart.removeAnnotation(currentAnntin)之前,答案是