2016-09-16 145 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