我在Ruby on Rails应用程序中使用 Jquery版本1.11和highcharts 4.0.1 。
堆叠列高图表在所有浏览器上运行良好,除了在IE8中抛出错误" 对象不支持此属性或方法:eval代码,第1行字符3855 (Jquery.js第7060行第5个字符)"
这是js代码:
<%= javascript_tag do %>
new Highcharts.Chart({
chart: {
renderTo: <%= render_div.to_json.html_safe %>,
type: 'column'
},
credits: {
enabled: false
},
title: {
text: <%= ("#{heading} Data Chart").to_json.html_safe %>
},
xAxis: {
categories: <%= graph_months.to_json.html_safe %>
},
yAxis: {
min: 0,
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black, 0 0 3px black'
},
formatter: function() {
if (this.y != 0) {
return this.y +'%';
} else {
return null;
}
}
}
}
},
series: [{
name: 'A',
color: '#003D66',
data: <%= a_array.to_json.html_safe%>
},
{
name: 'B',
color: '#006BB2',
data: <%= b_array.to_json.html_safe %>
},
{
name: 'C',
color: '#B2E0FF',
data: <%= c_array.to_json.html_safe %>
},
{
name: 'D',
color: '#4DB8FF',
data: <%= d_array.to_json.html_safe %>
}
]
});
<% end %>