无法读取未定义的属性“信息” [英] Cannot read property 'info' of undefined

查看:1584
本文介绍了无法读取未定义的属性“信息”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我在这个小提琴中创建一个图表时,我在这个问题的标题中得到错误 http://jsfiddle.net/w43m47hL/

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/.

选择点时出现此问题。

this.select();

执行这些步骤时会出现问题。

The problem occurs when performing these steps.


  1. 创建图表

  2. 点击某一点以选择它

  3. 销毁图表

  4. 再次创建图表

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

数据集的大小似乎与问题有关。如果您将1500更改为15,则会看到您不再遇到此问题。但是,在图表被销毁并重新创建之后,所选数据点仍然处于选中状态。我会认为自从图表被销毁以后就不会选择这一点。数据点是如何记住它被选中的?

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?

推荐答案

该问题是由保持对旧数据数组的引用引起的。在图表初始化期间,您将对参考数据的引用设置为已修改。所以当你销毁图表时,引用依然存在。使用Highcharts对象中的数据副本($ .extend([],data))。

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)
  }],

  • http://jsfiddle.net/nazr3det/

这篇关于无法读取未定义的属性“信息”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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