利用ajax实现动态数据的问题
时间:2011-07-27
来源:互联网
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script src="./libraries/RGraph.common.core.js"></script>
<script src="./libraries/RGraph.line.js"></script>
<div>
<div style="width: 800px">
<div style="width: 450px; float: left">
<canvas id="cvs" width="600" height="250">[No canvas support]</canvas>
</div>
</div>
</div>
<script>
d1 = [];
// Pre-pad the arrays with 100 null values
for (var i=0; i< 100; ++i) {
d1.push(null);
}
function getGraph(id, d1)
{
var graph = new RGraph.Line(id, d1);
graph.Set('chart.background.barcolor1', 'black');
graph.Set('chart.title.xaxis', 'Time');
graph.Set('chart.filled', true);
graph.Set('chart.fillstyle', ['#daf1fa', '#faa']);
graph.Set('chart.colors', ['rgb(169, 222, 244)', 'red']);
graph.Set('chart.linewidth', 3);
graph.Set('chart.ymax', 20);
graph.Set('chart.xticks', 25);
return graph;
}
function drawGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs"));
var graph = getGraph('cvs', d1);
graph.Draw();
// Add some data to the data arrays
d1.push(AjaxCall('http://1.58.109.173:33999/1,128,V',myCallback)); //这个http是我想获取数据的地址
// Get rid of the first values of the arrays
if (d1.length > 100){
d1 = RGraph.array_shift(d1);
}
setTimeout(drawGraph,25);
}
drawGraph();
</script>
</html>
<html>
<script src="./libraries/RGraph.common.core.js"></script>
<script src="./libraries/RGraph.line.js"></script>
<div>
<div style="width: 800px">
<div style="width: 450px; float: left">
<canvas id="cvs" width="600" height="250">[No canvas support]</canvas>
</div>
</div>
</div>
<script>
d1 = [];
// Pre-pad the arrays with 100 null values
for (var i=0; i< 100; ++i) {
d1.push(null);
}
function getGraph(id, d1)
{
var graph = new RGraph.Line(id, d1);
graph.Set('chart.background.barcolor1', 'black');
graph.Set('chart.title.xaxis', 'Time');
graph.Set('chart.filled', true);
graph.Set('chart.fillstyle', ['#daf1fa', '#faa']);
graph.Set('chart.colors', ['rgb(169, 222, 244)', 'red']);
graph.Set('chart.linewidth', 3);
graph.Set('chart.ymax', 20);
graph.Set('chart.xticks', 25);
return graph;
}
function drawGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs"));
var graph = getGraph('cvs', d1);
graph.Draw();
// Add some data to the data arrays
d1.push(AjaxCall('http://1.58.109.173:33999/1,128,V',myCallback)); //这个http是我想获取数据的地址
// Get rid of the first values of the arrays
if (d1.length > 100){
d1 = RGraph.array_shift(d1);
}
setTimeout(drawGraph,25);
}
drawGraph();
</script>
</html>
作者: yuexuanyu 发布时间: 2011-07-27
我想通过这个代码实现读取后台数据并更新折线图,不考虑后台,只需要连接前台和获取数据网页即可,我在这里用了ajax,用d1.push()输出我获取的值,可是没有获得值,请问ajaxcall方法是封装在html5中了吧?我该引入那个.js文件,还有d1.push()里的格式该如何写
作者: yuexuanyu 发布时间: 2011-07-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28