<script type="text/javascript">
Highcharts.chart('container1', {
chart: {
type: 'spline',
animation: Highcharts.svg,
marginRight: 10,
backgroundColor: '#f8f8f8',
type: 'line',
events: {
load: function () {
//设置更新
var proR_id = $("#proR_id").val();
var series = this.series[0];
setInterval(function () {
$.ajax({
url:"/HighSupportModel/detectionEngineering/selectShishi?proR_id="+proR_id,
type:"post",
dataType:"json",
success : function(data){
for(var i=0;i<data.length;i++){
alert(data[i].test_date1);
var x = (new Date()).getTime(), // 当前时间
//y = Math.random();
y = data[i].test_date1;
series.addPoint([x, y], true, true);
}
}
});
}, 3000);
}
}
},
credits : {
enabled: false
},
time: {
useUTC: false
},
title: {
text: '立杆倾斜曲线'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text:''
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x:%Y-%m-%d %H:%M:%S}<br/>{point.y:.2f}'
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: '数据',
data: (function () {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i += 1) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
}())
}]
});
</script>
我这里数据可以接收到 alert有值 但就是add不进去
自己瞎写了点 不太明白 提前谢谢大佬回答!

highcharts怎么后台查询数据库赋值到前台
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 论业余我是专业的 2018-12-06 06:54关注
把请求数据放外面 , 请求数据成功之后再执行 Highcharts.chart('container1', { 图表详细设置 }) , 会更好
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报