经常和数据打交道的避免不了生成各种图形,pChart是一个开源的图表生成库,可以生成几十种简单或者复杂或者看不懂的图标,这里的代码是生成饼形图,使用该程序PHP需要开启GD服务,另外pChart支持中文的话,修改代码中的:$Test->setFontProperties(“Fonts/simkai.ttf”,8); 并将要simkai.ttf(楷体)文件拷贝到 pChart\Fonts下。
pchart饼图实例
include("./include/pChart/class/pData.class.php");
include("./include/pChart/class/pDraw.class.php");
include("./include/pChart/class/pPie.class.php");
include("./include/pChart/class/pImage.class.php");
/* 创建一个pData对象 */
$MyData = new pData();
$MyData->addPoints(array(220,273,32,184),"ScoreA"); // 要显示的数据值
// $MyData->setSerieDescription("ScoreA","Application A"); // 设置描述??
/* 图例 */