我想使用Highcharts样条曲线动态地从数据库中检索情节值。问题是我不能找出一种方法来将值传递给Javascript函数而不刷新整个函数,这将从头开始绘制整个图。当前的代码包含一个数组,它只是用一个数组和一个随机函数来绘制生成新值。我想找到一种方法来使用PHP从数据库中将新值插入到该数组中。问题是我不知道如何在不影响图形的情况下继续调用数据库查询。一些使用数据库动态值动态绘制图形的帮助将会很有帮助。从数据库中获取的动态值,动态图表绘制
$(function() {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'spline',
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: 'Trend analysis'
},
xAxis: {
labels: {
rotation: 320
},
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
credits:{
enabled:false
},
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: 'Random data',
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;
})()
}]
});
});
});
你能告诉我的asp.net任何的例子吗?正如你提到的PHP – SPandya 2013-11-26 11:07:44
对不起,我不熟悉witj asp.net。 – SteveP 2013-11-28 08:39:41