我有一个JSP程序,它以JSON格式提供输出。我想用该输出更新highchart
速度表。我的仪表只从输出中获取一个值。它没有得到进一步更新。但我可以使用alert语句打印正确的值。有人可以帮我吗?
这是我的代码:
$(function () {
var chart1=new Highcharts.Chart({
chart:{
renderTo:'container',
type:'gauge',
alignTicks:false
},
title:{
text:'Speedometer'
},
pane:[{
startAngle:-150,
endAngle:150,
size:350,
background:{
outerRadius:'105%',
innerRadius:'72%',
backgroundColor:{
radialGradient:{
cx:0.5,
cy:0.6,
r:1.0
},
stops:[
[0.3,'#A7A9A4'],
[0.45,'#DDD'],
[0.7,'#EBEDEA']
]
}
}
},
{
startAngle:-150,
endAngle:150,
size:210
}],
yAxis:[{
min:0,
max:100,
minorTickInterval:'auto',
tickPixelInterval:70,
plotBands:[{
from:0,
to:50,
color:'green'
},{
from:50,
to:80,
color:'yellow'
},{
from:80,
to:100,
color:'red'
}],
pane:0
},{
min:0,
max:220 ,
tickPosition:'inside',
minorTickPosition:'inside',
minorTickInterval:'auto',
tickPixelInterval:60,
plotBands:[{
from:0,
to:70,
color:'red'
},{
from:70,
to:130,
color:'yellow'
},{
from:130,
to:220,
color:'green'
}],
pane:1
}],
series:[{
data:[70],
name:'Speed',
tooltip:{
valueSuffix:' km/h'
},
dataLabels:{
formatter:function(){
if(this.point.realVal)
return this.y;
}
},
yAxis:0
},{
data:[100],
name:'RPM',
dataLabels:{
formatter:function(){
if(this.point.realVal1)
return this.y;
}
},
yAxis:1
}]
},
function (chart) {
setInterval(function () {
var point = chart.series[0].points[0],
point1=chart.series[1].points[0],
newVal=[],newVal1=[],i,j;
$.get('Db.jsp', null, function (tsv,state,xhr) {
var data = eval ( '(' + xhr.responseText + ')' );
for(i=0; i<data.points.length; i++){
$.each(data.points[i],function(key,val){
newVal.push(val);
//alert(newVal);
point.update(newVal);
}
}
for(j=0; j<data.points.length; j++){
$.each(data.values[j], function(key,val){
newVal1.push(val);
//alert(newVal1);
point1.update(newVal);
}
}
});
});
});
});