0
誰知道rgraph和HTML5? (http://www.rgraph.net)HTML5:將圖表保存爲服務器上的圖像
我的圖表的代碼是以下,我的問題是,我不能保存在服務器上的畫布(圖像),即使他們的建議。
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Title</title>
<meta name="keywords" content="rgraph javascript charts html5 canvas basic example" />
<meta name="description" content="A basic example of an RGraph chart for implementation help" />
<meta name="googlebot" content="NOODP">
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script src="../libraries/RGraph.common.core.js" ></script>
<script src="../libraries/RGraph.common.context.js" ></script>
<script src="../libraries/RGraph.common.annotate.js" ></script>
<script src="../RGraph.common.tooltips.js" ></script>
<script src="../libraries/RGraph.common.zoom.js" ></script>
<script src="../libraries/RGraph.common.effects.js" ></script>
<script src="../libraries/RGraph.common.key.js" ></script>
<script src="../libraries/RGraph.line.js" ></script>
<script src="../libraries/RGraph.common.key.js" ></script>
<!--[if lt IE 9]><script src="../excanvas/excanvas.original.js"></script><![endif]-->
<script src="../libraries/jquery.min.js" ></script>
<script>
window.onload = function()
{
var line1 = new RGraph.Line('line1', [3,56,22,7,84,8,34,1,1], [3,4,45,0,5,97,46,29,7]);
line1.Set('chart.background.grid', true);
line1.Set('chart.linewidth', 3);
line1.Set('chart.gutter.left', 35);
line1.Set('chart.hmargin', 5);
if (!document.all || RGraph.isIE9up()) {
line1.Set('chart.shadow', true);
}
line1.Set('chart.tickmarks', null);
line1.Set('chart.units.post', '');
line1.Set('chart.colors', ['#FA4E1D', '#2D659A']);
line1.Set('chart.background.grid.autofit', true);
line1.Set('chart.background.grid.autofit.numhlines', 10);
line1.Set('chart.background.grid.autofit.numvlines', 29);
line1.Set('chart.curvy', 0);
line1.Set('chart.curvy.factor', 0.25);
line1.Set('chart.labels',['1','2','3','4','5','6','7','8','9']);
line1.Set('chart.title','Title of the Chart');
line1.Set('chart.key.text.size',7);
line1.Set('chart.key',['A','B']);
line1.Set('chart.key.shadow','shadow');
line1.Set('chart.key.position','graph');
line1.Set('chart.ymax',200);
line1.Draw();
}
</script>
</head>
<body>
<center><h2>My title</h2><center>
<!-- 2/3. This is the canvas that the graph is drawn on -->
<div style="text-align: center">
<canvas id="line1" width="300" height="180">[Please wait...]</canvas>
</div>
</body>
</html>
的建議是在這個頁的結束:在該特定段落的「保存圖表作爲服務器上的圖像」 http://www.rgraph.net/docs/index.html#image。 我的唯一結果是在我的服務器中有一個0長文件.png。
有人可以幫助我嗎? 在此先感謝。
馬修
非常感謝你,它工作得很好! PNG完美生成。我的進一步問題是,不幸的是它不可能通過cronjob自動完成。但我會環顧四周,尋求一些好的建議。 Tnx再次! – mattew 2012-03-04 10:02:10
不幸的是,我發現了一個很大的問題:我想通過cron命令每天生成圖像,我不能認爲腳本沒有執行。我試圖用Lynx調用這個文件,但是圖像沒有被創建。我如何做?問題真的很大。 :/ – mattew 2012-03-04 22:10:53
我真的不知道,但也許如果cron工作是做這個頁面的'file_get_contents'之類的東西,它可能會觸發所有必需的ajax等?對不起,只是在黑暗中拍攝。 – 2012-03-05 04:53:04