Cannot read property 'info' of undefined

三世轮回 提交于 2020-01-03 04:34:06

问题


I am having an issue where I get the error in the title of this question when I create a chart like the one in this fiddle http://jsfiddle.net/w43m47hL/.

I get this problem when selecting a point.

this.select();

The problem occurs when performing these steps.

  1. create the chart
  2. click on a point to select it
  3. destroy the chart
  4. create the chart again

The size of the data set seems to have something to do with the problem. If you change 1500 to 15 you will see that you don't get this problem any more. However the data point that was selected is still selected after the chart is destroyed and created again. I would have thought that the point would not be selected since the chart was destroyed. How is the data point remembering that it was selected?


回答1:


The issue is caused by keeping reference to "old" data array. During chart initialisation, you set the reference to data array, which is modified. So when you destroy chart, reference still exists. Use the copy of data ($.extend([],data)) in Highcharts objects.

  series: [{
    data: $.extend([], data)
  }],

Example:

  • http://jsfiddle.net/nazr3det/


来源:https://stackoverflow.com/questions/37795970/cannot-read-property-info-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!