PHP中的GD庫本身是一套很強大的繪圖庫了,繪制的圖像基本可以滿足日常要求,但強大規強大,還是不夠方便哈,因為強大方便的基於PHP的GD庫的jpgraph也就誕生啦!
PHP默認是不啟用GD庫的,因為需要在php.ini的配置文件中將extension=php_gd2.dll注釋打開。打開後你就可以畫一些你想畫的各種奇葩圖案了。什麼?不會畫?那回去學基礎!
今天看了一下某培訓機構的視頻,看了jpgraph報表這塊兒,按照視頻方法,在http://jpgraph.net/download/上下載了Version: 3.0.7版本,解壓後在Examples目錄下創建一個jpgraph目錄,並將src目錄下的除開Examples的所有文件剪切到Examples目錄下剛創建的jpgraph目錄內。然後把Examples拷貝到apache所配置的目錄即可。
可是結果試了半天,老報錯:
Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in H:\TestFile\Examples\jpgraph\jpgraph.php on line 391
JpGraph Error: HTTP headers have already been sent.
Caused by output from file jpgraph.php at line 392.Explanation:
HTTP
headers have already been sent back to the browser indicating the data
as text before the library got a chance to send it's image HTTP header
to this browser. This makes it impossible for the library to send back
image data to the browser (since that would be interpretated as text by
the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.
For example it is a common mistake to leave a blank line before the opening "<?php".
上面的Warning報了一堆後,出現了一個錯誤:JpGraph Error,於是乎,英文不好的博主索性將這堆英文拉到百度翻譯去,索性還是沒看懂,網上找了一堆也是無人答之,後在Google下搜一下才找到。http://bbs.php100.com/simple/?t294044.html ,答案大概就是時區什麼什麼問題的,也給出了解決方案用date_default_timezone_set('Asia/Chongqing');設置對應的時區即可,這裡設置成了重慶。問題也就隨之解決了。
隨後又下載了Version: 3.5.0b1的jpgraph,按同樣的方法試之,首頁的圖片還是加載不出來,原因是沒有‘jpgraph/jpgraph_odo.php’這個文件,導致引入時就出了問題,而博主到網上搜了相應的文件也復制到jpgraph目錄下,也還是未能解決,最後不了了之。
有解決方法否?