一起使用HIghchart 与EXTJS 抛出异常
界面是这样的界面最大的容器是一个EXTJS 的panel
panel里面是一个tab
我想把highchart放到一个tab中的时候报错了
异常信息
uncaught exception: Highcharts error #13:
var tabs = new Ext.TabPanel({
renderTo: strspot[a] + '-body',
activeTab: 0,
tabCls: 'tab-class',
items: [{
title: '实时数据',
html: html,
}, {
title: '实时曲线',
html: '<div id=chart' + a + ' class=tab_kid></div>'
}]
});
var chart = new Highcharts.Chart({
chart: {
renderto: 'chart' + a,
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function () {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true, true);
}, 1000);
}
}
},
title: {
text: strspot[a]
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: strspot[a],
data: (function () {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
})()
}]
});
[解决办法]
Highcharts error #13
http://www.highcharts.com/errors/13
这里有你要的错误原因,你把Highcharts 部分写在tab 的 afterrender里应该就可以了
原因Highcharts 找不到容器