无法在 IE8 中为 Highcharts 获取未定义或空引用的 属性 '1'
Unable to get property '1' of undefined or null reference for Highcharts in IE8
我试图在 IE8 中使用 Highchart,但出现错误:
Unable to get property '1' of undefined or null reference
根据该网站,Highcharts 适用于 IE6,因此在 IE8 中应该可以正常工作...它在我测试过的所有其他浏览器中都可以正常工作。
知道问题出在哪里吗?
我在这里设置了一个fiddle,在IE8中测试时出错:http://jsfiddle.net/w1ebp44w/
(最好在 IE 中测试完整结果:http://jsfiddle.net/w1ebp44w/embedded/result/)
代码如下:
Highcharts.theme = {
colors: [
'#5e2750',
'#eb9700',
'#007c92',
'#a8b400'
]
};
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
// Radialize the colors
Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
//[1, Highcharts.Color(color).brighten(-0.1).get('rgb')] // darken
]
};
});
// Build the chart
var options = {
chart: {
//renderTo: 'chart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor: 'transparent',
spacingTop: 0,
spacingLeft: 0,
spacingRight: 0,
spacingBottom: 0,
animation: false,
shadow: false,
type: 'pie'
},
credits: {
enabled: false
},
title: {
text: null
},
tooltip: {
enabled: false,
formatter: function() {
return '<b>' + this.point.name + '</b> : ' + Math.round(this.percentage) + '%';
}
},
plotOptions: {
pie: {
animation: true,
allowPointSelect: false,
dataLabels: {
enabled: true,
//format: '<b style="font-weight:400;font-family:VodafoneBold;">{point.name}</b> {point.y}/{point.total} ({point.percentage:.1f}%)',
formatter: function(){
return '<b style="font-weight:400;font-family:Arial;">' + this.point.name + '</b> ' + this.point.y + '/' + this.point.total + ' (' + this.point.percentage.toFixed(0) + '%)';
},
style: {
"color": "#666",
"fontSize": "18px",
"fontWeight": "400",
"fontFamily": "Arial"
}
},
shadow: false
},
series: {
states: {
hover: {
enabled: false
}
}
}
},
series: [{
data: [{
name: 'Basic',
x: 0,
y: Math.round( 1 )
}, {
name: 'Intermediate',
x: 0,
y: Math.round( 2 )
}, {
name: 'Advanced',
x: 0,
y: Math.round( 3 )
}, {
name: 'Expert',
x: 0,
y: Math.round( 4 )
}]
}]
};
$(document).ready(function(){
$('#chart').highcharts(options).highcharts();
});
IE8 存在尾随逗号问题
stops: [
[0, color], <-- remove the trailing comma
我试图在 IE8 中使用 Highchart,但出现错误:
Unable to get property '1' of undefined or null reference
根据该网站,Highcharts 适用于 IE6,因此在 IE8 中应该可以正常工作...它在我测试过的所有其他浏览器中都可以正常工作。
知道问题出在哪里吗?
我在这里设置了一个fiddle,在IE8中测试时出错:http://jsfiddle.net/w1ebp44w/
(最好在 IE 中测试完整结果:http://jsfiddle.net/w1ebp44w/embedded/result/)
代码如下:
Highcharts.theme = {
colors: [
'#5e2750',
'#eb9700',
'#007c92',
'#a8b400'
]
};
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
// Radialize the colors
Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
//[1, Highcharts.Color(color).brighten(-0.1).get('rgb')] // darken
]
};
});
// Build the chart
var options = {
chart: {
//renderTo: 'chart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor: 'transparent',
spacingTop: 0,
spacingLeft: 0,
spacingRight: 0,
spacingBottom: 0,
animation: false,
shadow: false,
type: 'pie'
},
credits: {
enabled: false
},
title: {
text: null
},
tooltip: {
enabled: false,
formatter: function() {
return '<b>' + this.point.name + '</b> : ' + Math.round(this.percentage) + '%';
}
},
plotOptions: {
pie: {
animation: true,
allowPointSelect: false,
dataLabels: {
enabled: true,
//format: '<b style="font-weight:400;font-family:VodafoneBold;">{point.name}</b> {point.y}/{point.total} ({point.percentage:.1f}%)',
formatter: function(){
return '<b style="font-weight:400;font-family:Arial;">' + this.point.name + '</b> ' + this.point.y + '/' + this.point.total + ' (' + this.point.percentage.toFixed(0) + '%)';
},
style: {
"color": "#666",
"fontSize": "18px",
"fontWeight": "400",
"fontFamily": "Arial"
}
},
shadow: false
},
series: {
states: {
hover: {
enabled: false
}
}
}
},
series: [{
data: [{
name: 'Basic',
x: 0,
y: Math.round( 1 )
}, {
name: 'Intermediate',
x: 0,
y: Math.round( 2 )
}, {
name: 'Advanced',
x: 0,
y: Math.round( 3 )
}, {
name: 'Expert',
x: 0,
y: Math.round( 4 )
}]
}]
};
$(document).ready(function(){
$('#chart').highcharts(options).highcharts();
});
IE8 存在尾随逗号问题
stops: [
[0, color], <-- remove the trailing comma