我想使用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