2016-09-16 147 views
0

我只是试图使用RGraph生成图表,以便我可以开始使用SQL来操纵图形。但是,我遇到的问题是它根本没有显示基本图形。任何人都知道我在哪里错了吗?RGraph不显示任何东西?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Charts</title> 
<script src="JAVASCRIPT/RGraph.common.core.js"></script> 
<script src="JAVASCRIPT/RGraph.bar.js"></script>  
</head> 

<body> 
<canvas id="cvs1" width="600" height="250">[No canvas support]</canvas> 
<script> 
    window.onload = function() 
    { 
     var bar = new RGraph.Bar({ 
      id:'cvs1', 
      data: [4,5,3,8,4,9,6,5,3], 
      options: { 
       backgroundGridDashed: true, 
       labels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'], 
       title: 'A dashed background grid', 
       strokestyle: 'rgba(0,0,0,0)', 
       textAccessible: true 
      } 
     }).draw(); 
    }; 
</script> 
</body> 
</html> 

浏览器错误

Uncaught TypeError: Cannot read property 'getContext' of null

RGraph.Bar @ RGraph.bar.js:28

window.onload @ Charts.php:17

+0

你检查了浏览器控制台是否有任何js错误? –

+0

我刚刚添加了错误,我得到我的帖子 –

回答

1

我测试你的代码。它没有错,但它似乎非常依赖于你使用的是哪个版本的RGraph。尝试下载the latest version of RGraph并将'libraries'下的内容(或者只是你需要的两个文件)提取到你的'JAVASCRIPT'文件夹。

+0

这工作,我只是更新文件。谢谢你的帮助。 –

+0

没问题!使用SQL玩得开心。 – Brian