关于AJAX只刷新数据 无页面刷新的问题
时间:2011-07-25
来源:互联网
HTML code
麻烦看一下这段代码 我也感觉不到哪里有问题 求大神讲解
<!DOCTYPE html> <html> <head> <script src="./libraries/RGraph.common.core.js"></script> <script src="./libraries/RGraph.common.annotate.js" ></script> <script src="./libraries/RGraph.common.context.js" ></script> <script src="./libraries/RGraph.common.tooltips.js" ></script> <script src="./libraries/RGraph.common.resizing.js" ></script> <script src="./libraries/RGraph.bar.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 = []; d2 = []; // Pre-pad the arrays with 100 null values for (var i=0; i< 100; ++i) { d1.push(null); d2.push(null); } function getGraph(id, d1, d2) { var graph = new RGraph.Line(id, d1, d2); graph.Set('chart.background.barcolor1', 'black'); graph.Set('chart.background.barcolor2', '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, d2); graph.Draw(); // Add some data to the data arrays d1.push(RGraph.random(5, 10)); d2.push(RGraph.random(5, 10)); // Get rid of the first values of the arrays if (d1.length > 100) { d1 = RGraph.array_shift(d1); d2 = RGraph.array_shift(d2); } setTimeout(drawGraph,25); } drawGraph(); </script> </head> </html>
麻烦看一下这段代码 我也感觉不到哪里有问题 求大神讲解
作者: yuexuanyu 发布时间: 2011-07-25
没用过RGraph,帮顶
作者: lsw645645645 发布时间: 2011-07-25
。。。这个问题我解决了,但是我想继续问一下用canvas标签绘制棒图的时候 怎么让棒图的数据值为变量,我一旦设置变量,页面就显示不出数据
作者: yuexuanyu 发布时间: 2011-07-25
继续附上代码一段
<!DOCTYPE html>
<html>
<head>
<body>
<script src="./libraries/RGraph.common.core.js"></script>
<script src="./libraries/RGraph.common.annotate.js" ></script>
<script src="./libraries/RGraph.common.context.js" ></script>
<script src="./libraries/RGraph.common.tooltips.js" ></script>
<script src="./libraries/RGraph.common.resizing.js" ></script>
<script src="./libraries/RGraph.bar.js" ></script>
<script scr="./libraries/RGraph.line.js"></script>
<script>
d1 = [];
d2 = [];
// Pre-pad the arrays with 100 null values
for (var i=0; i< 100; ++i) {
d1.push(null);
d2.push(null);
}
window.onload=function (e)
{
var bar = new RGraph.Bar('cvs',['d1','d2']);
bar.Set('chart.colors', ['blue', 'pink']);
bar.Set('chart.labels.above', true);
bar.Set('chart.shadow', true);
bar.Set('chart.shadow.color', '#aaa');
bar.Set('chart.strokestyle', 'rgba(0,0,0,0)');
bar.Set('chart.adjustable', true);
bar.Set('chart.labels', ['2000','2001']);
bar.Draw();
}
function drawGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs"));
var bar = getGraph('cvs', d1, d2);
bar.Draw();
// Add some data to the data arrays
d1.push(RGraph.random(5, 10));
d2.push(RGraph.random(5, 10));
// Get rid of the first values of the arrays
if (d1.length > 100) {
d1 = RGraph.array_shift(d1);
d2 = RGraph.array_shift(d2);
}
setTimeout(drawGraph,25);
}
drawGraph();
</script>
<div>
<div style="width: 800px">
<div style="width: 450px; float: left">
<canvas id="cvs" width="500" height="200">[No canvas support]</canvas>
</div>
</div>
</div>
</body>
</head>
</html>
<!DOCTYPE html>
<html>
<head>
<body>
<script src="./libraries/RGraph.common.core.js"></script>
<script src="./libraries/RGraph.common.annotate.js" ></script>
<script src="./libraries/RGraph.common.context.js" ></script>
<script src="./libraries/RGraph.common.tooltips.js" ></script>
<script src="./libraries/RGraph.common.resizing.js" ></script>
<script src="./libraries/RGraph.bar.js" ></script>
<script scr="./libraries/RGraph.line.js"></script>
<script>
d1 = [];
d2 = [];
// Pre-pad the arrays with 100 null values
for (var i=0; i< 100; ++i) {
d1.push(null);
d2.push(null);
}
window.onload=function (e)
{
var bar = new RGraph.Bar('cvs',['d1','d2']);
bar.Set('chart.colors', ['blue', 'pink']);
bar.Set('chart.labels.above', true);
bar.Set('chart.shadow', true);
bar.Set('chart.shadow.color', '#aaa');
bar.Set('chart.strokestyle', 'rgba(0,0,0,0)');
bar.Set('chart.adjustable', true);
bar.Set('chart.labels', ['2000','2001']);
bar.Draw();
}
function drawGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs"));
var bar = getGraph('cvs', d1, d2);
bar.Draw();
// Add some data to the data arrays
d1.push(RGraph.random(5, 10));
d2.push(RGraph.random(5, 10));
// Get rid of the first values of the arrays
if (d1.length > 100) {
d1 = RGraph.array_shift(d1);
d2 = RGraph.array_shift(d2);
}
setTimeout(drawGraph,25);
}
drawGraph();
</script>
<div>
<div style="width: 800px">
<div style="width: 450px; float: left">
<canvas id="cvs" width="500" height="200">[No canvas support]</canvas>
</div>
</div>
</div>
</body>
</head>
</html>
作者: yuexuanyu 发布时间: 2011-07-25
还没做过html5呢
作者: xuexiaodong2009 发布时间: 2011-07-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28