我正在尋找一種方式來顯示VM使用Flot(jquery)圖表當前的CPU使用率。實時圖表使用flot jquery
從現在開始,我會畫簡單的線條,但是,如何讓圖形向左移動作爲新的數據用武之地。
<script type="text/javascript">
var d1 = [ [0,0] ];
options = {
lines: {
show: true
},
points: {
show: true
},
xaxis: {
tickDecimals: 0,
tickSize: 1
},
grid: {
backgroundColor: {
colors: ["#fff", "#eee"]
}
}
};
function init() {
$.plot($("#placeholder"), d1, options);
} /* init Function */
function update(){
for (var i = 0; i < 14; i += 0.5) {
d1.push([i, Math.floor(Math.random()*11)]);
}
$.plot($("#placeholder"), [ d1 ], options);
}
init();
$("input.dataUpdate").click(function() {
update();
});
</script>
任何想法也許另一個插件,可以做的伎倆沒有線索?
編輯:
我需要關聯數組翻譯:
[ [1, (random1)], [2, (random2), [3, (random2) ]
到
[ [2, (random2)], [3, (random3), [4, (random4) ] (new element 4)
不知道如何實現這一目標。
如何調用該函數重新顯示情節? plot.setData不起作用...對不起我的無知 – Disco 2011-01-21 13:32:18
這是一個通過ajax和settimer進行更新的flot示例:http://people.iola.dk/olau/flot/examples/ajax.html – rcravens 2011-01-21 14:01:21