先安裝gd的套件
sudo apt-get install php5-gd
然後下載 jpgraph http://jpgraph.net/download/
然後解壓縮完....傳到RPI...
進到 src/Examples ... 裡面有很多sample
先來看 combgraphex1.php 例子
修改一下header
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_bar.php');
require_once ('jpgraph/jpgraph_utils.inc.php');
require_once ('jpgraph/jpgraph_mgraph.php');
改成
require_once ('../jpgraph.php');
require_once ('../jpgraph_line.php');
require_once ('../jpgraph_bar.php');
require_once ('../jpgraph_utils.inc.php');
require_once ('../jpgraph_mgraph.php');
因為 jpgraph.php 在 上一個資料夾....
其他的檔案也是一樣
然後執行...會遇到這個issue
查了一下google..... 在reference 2 說可以把它先remark...
Open the file
~/public_html/lib/jpgraph/src/gd_image.inc.php
, find the functionSetAntiAliasing
and comment this line out like this:
再執行一次....會遇到另外一個問題
他在 /usr/share/fonts/truetype 找不到 arial.ttf....
首先先安裝 microsoft 的字型
sudo apt-get install msttcorefonts
裝完之後...他把 arial.ttf 放在 /usr/share/fonts/truetype/msttcorefonts
並不是 /usr/share/fonts/truetype....
所以再來個 ln -s 連結過去...
再執行一次...就可以看到成功的畫面
Reference 1 : http://jpgraph.net/doc/howto1.php
Reference 2 : https://ubuntuincident.wordpress.com/2011/01/28/drawing-graphs-in-php-with-jpgraph/
沒有留言:
張貼留言