admin管理员组

文章数量:1415460

I'm using highcharts for pie charts. There is a problem in the script in IE7 which says:

SCRIPT5007: Unable to get value of the property '0': object is null or undefined highcharts.js, line 10 character 3841

Here is the line of code from the script:

if(typeof a[0]==="number")
    this.x=a[0],this.y=a[1];
else if(d==="object"&&typeof a.length!=="number") {
    if(u(this,a),this.options=a,a.dataLabels)c._hasPointLabels=!0
}
else if(typeof a[0]==="string")
    this.name=a[0],this.y=a[1];

How do I resolve this issue?

I'm using highcharts for pie charts. There is a problem in the script in IE7 which says:

SCRIPT5007: Unable to get value of the property '0': object is null or undefined highcharts.js, line 10 character 3841

Here is the line of code from the script:

if(typeof a[0]==="number")
    this.x=a[0],this.y=a[1];
else if(d==="object"&&typeof a.length!=="number") {
    if(u(this,a),this.options=a,a.dataLabels)c._hasPointLabels=!0
}
else if(typeof a[0]==="string")
    this.name=a[0],this.y=a[1];

How do I resolve this issue?

Share Improve this question edited Aug 5, 2015 at 15:40 atw 5,86010 gold badges42 silver badges66 bronze badges asked Jan 4, 2013 at 5:57 Indira JeldiIndira Jeldi 411 silver badge6 bronze badges 1
  • Could you post the options that you are passing to Highcharts? – Pulkit Goyal Commented Jan 4, 2013 at 12:43
Add a ment  | 

4 Answers 4

Reset to default 4

This happened to me as well. After debugging, I eventually found the issue was because I had an extra ma ',' after the last element of my series data array.

An example of the issue can be found on this JSFiddle: http://jsfiddle/lewisdavidcole/Be43c/14/

The error only showed up in IE7 and IE8. It worked fine in IE9, Chrome and Firefox, which are more forgiving. To fix the issue, remove the extra ma on line 266 of the JSFIddle that looks like this:

}, //TO FIX, REMOVE THE EXTRA COMMA HERE WHICH CREATES PROBLEMS IN IE7 and IE8

The error happened because defining an array like

var myArray = [1,2,3,4,5,]; Creates an issue in IE7 and IE8, it should never end in a ma.

This is a mon misconfiguration, so we added a fix for it in Highcharts. See http://jsfiddle/highcharts/sw5rY/ .

series: [{
    data: [29.9, 71.5, 106.4, 129.2,],
    showInLegend: true
}]

Please alert(a[0]) and see does that array element has some value or not If not please used this condition before your code:-

if(a.length>0){
//your code
}

try this:

if(a.length>0){
if(typeof a[0]==="number")
    this.x=a[0],this.y=a[1];
else if(d==="object"&&typeof a.length!=="number") {
    if(u(this,a),this.options=a,a.dataLabels)c._hasPointLabels=!0
}
else if(typeof a[0]==="string")
    this.name=a[0],this.y=a[1];
}

本文标签: javascriptUnable to get value of the property 39039 object is null or undefined in IE7Stack Overflow