<?php /* *用jpgraph生成曲线图 *3d图 */ include_once("lib/jpgraph.php"); include_once("lib/jpgraph_pie.php"); include_once("lib/jpgraph_pie3d.php"); $data = array(18 ,23, 26 , 27 , 48 , 25 , 49 , 50 , 45 , 23 , 20 ,30); //模拟数据 $month = array('北京','上海','广东','天津' , '河南' , '河北' , '浙江' , '山西' , '重庆','香港','台湾','其他'); $graph = new PieGraph(600 , 450); $graph->SetShadow(); $graph->title->Set("注册人数地区分布"); $pieplot = new PiePlot3D($data); $graph->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->legend->SetFont(FF_SIMSUN,FS_BOLD); $graph->legend->SetPos(0.01,0.2,'right','right');//0.01距左边的偏移 0.2距上方的偏移 后面两个默认为 right top $graph->legend->SetColumns(1);//设置图例一列显示 $graph->legend->SetLineSpacing(15);//设置行距 $pieplot->SetCenter(0.4) ; //设置饼图的中心位置 $pieplot->SetLegends($month); //设置图例 $graph->Add($pieplot); $graph->Stroke(); ?>
注意php文件上方不能有空格不然会出现 图片内部错误的异常。
<?php /* *用户注册数统计曲线图 */ include_once("lib/jpgraph.php"); include_once("lib/jpgraph_pie.php"); include_once("lib/jpgraph_pie3d.php"); require_once ('lib/jpgraph_line.php'); $datay1 = array(20,15,23,15,38,42,25,30); $datay2 = array(16,14,20,12,28,32,22,26); // Setup the graph $graph = new Graph(600,450); $graph->SetScale("textlin"); //$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);//设置背景图片 $theme_class=new UniversalTheme; $graph->SetTheme($theme_class);//设置主题 $graph->img->SetAntiAliasing(false); $graph->title->Set('会员统计'); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false,false); //设置中文显示 $graph->title->SetFont(FF_SIMSUN,FS_BOLD); //设置标题字体为中文 $graph->legend->SetFont(FF_SIMSUN,FS_BOLD); //设置中文字体 $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid");//设置字体 $graph->xaxis->SetTickLabels(array('2011-02-12','2011-02-13','2011-02-14','2011-02-15','2011-02-16','2011-02-17','2011-02-18','2011-02-19'));//设置x轴数据 $graph->xgrid->SetColor('#E3E3E3');//颜色 //设置x y 轴的属性 $graph->xaxis->title->Set('date'); $graph->yaxis->title->Set('number'); // Create the first line $p1 = new LinePlot($datay1); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('会员加入数');//图例名称 $p1->mark->SetType(MARK_FILLEDCIRCLE,'',1.0); $p1->mark->SetColor('#6495ED'); $p1->mark->SetFillColor('#6495ED'); $p2 = new LinePlot($datay2); $graph->Add($p2); $p2->SetColor("red"); $p2->SetLegend('vip会员加入数'); $p2->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);//设置节点类型 $p2->mark->SetColor('red');//节点颜色 $p2->mark->SetFillColor('red');// $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke() ?>