123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- <?php
- class Chart {
-
- static function create3dpie($title,$data=array(),$size=40,$height=100,$width=80,$legend=array(),$slice=0){
-
- vendor("Jpgraph.jpgraph");
- vendor("Jpgraph.jpgraph_pie");
- vendor("Jpgraph.jpgraph_pie3d");
-
- $graph = new PieGraph($width,$height,"auto");
- $graph->SetShadow();
-
- $graph->title->Set(iconv("utf-8","gb2312",$title));
-
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD,18);
- $graph->title->SetColor("darkblue");
- $graph->legend->Pos(0.1,0.2);
- $graph->SetFrame(false,'#ffffff',0);
-
- $p1 = new PiePlot3d($data);
- $p1->SetTheme("sand");
- $p1->SetCenter(0.4);
- $p1->SetSize($size);
-
- $p1->SetAngle(70);
-
- if($slice==0)
- $p1->ExplodeSlice(3);
-
- $p1->value->SetFont(FF_ARIAL,FS_BOLD,10);
-
- $p1->value->SetColor("navy");
- $graph->legend->SetFont(FF_SIMSUN,FS_BOLD,8);
-
- foreach ($legend as $k => $v) {
- $legend[$k] = iconv('utf-8', 'gb2312', $v);
- }
- $p1->SetLegends($legend);
- $graph->Add($p1);
- $graph->Stroke();
- }
-
-
- static function createcolumnar($title,$data=array(),$size=40,$height=100,$width=80,$legend=array()){
-
- vendor("Jpgraph.jpgraph");
- vendor("Jpgraph.jpgraph_bar");
-
-
- $graph = new Graph($width,$height,'auto');
- $graph->img->SetMargin(40,30,40,40);
- $graph->SetScale("textint");
- $graph->SetShadow();
- $graph->SetFrame(false);
-
-
-
- $graph->yaxis->scale->SetGrace(20);
-
-
-
- foreach ($legend as $k => $v) {
- $legend[$k] = iconv('utf-8', 'gb2312', $v);
- }
- $graph->xaxis->SetTickLabels($legend);
- $graph->xaxis->SetFont(FF_SIMSUN);
-
-
- $graph->title->Set(iconv("utf-8","gb2312",$title));
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD,11);
-
- $graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);
-
-
- $bplot = new BarPlot($data);
- $bplot->SetFillColor("#0080C0");
- $bplot->SetWidth(0.3);
-
-
-
- $bplot->value->Show();
-
- $bplot->value->SetFont(FF_ARIAL,FS_BOLD);
- $bplot->value->SetAngle(0);
-
- $bplot->value->SetColor("black","darkred");
- $graph->Add($bplot);
-
-
- $graph->Stroke();
- }
-
-
- function createring($title,$data=array(),$size=40,$height=100,$width=80,$legend=array()){
-
- vendor("Jpgraph.jpgraph");
- vendor("Jpgraph.jpgraph_pie");
-
-
-
- $graph = new PieGraph(700,350,'auto');
-
-
- $graph->title->Set(iconv("utf-8","gb2312","{$title}"));
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);
- $graph->title->SetMargin(2);
- $graph->legend->Pos(0.1,0.1);
- $graph->SetFrame(false,'#ffffff',0);
-
- $p1 = new PiePlotC($data);
-
-
- $p1->SetTheme("sand");
- $p1->SetCenter(0.4);
- $p1->SetSize(0.35);
-
-
- $p1->value->SetFont(FF_ARIAL,FS_BOLD,10);
- $p1->value->SetColor('black');
-
- $p1->midtitle->Set("");
- $p1->midtitle->SetFont(FF_SIMSUN,FS_NORMAL,10);
-
- $p1->SetMidColor('white');
-
- $p1->SetLabelType(PIE_VALUE_PER);
- $graph->legend->SetFont(FF_SIMSUN,FS_NORMAL,8);
-
- foreach ($legend as $k => $v) {
- $legend[$k] = iconv('utf-8', 'gb2312', $v);
- }
- $p1->SetLegends($legend);
-
- $graph->Add($p1);
-
-
- $graph->Stroke();
- }
-
-
- function createmonthline($title,$data=array(),$size=40,$height=100,$width=80,$legend=array()){
- vendor("Jpgraph.jpgraph");
- vendor("Jpgraph.jpgraph_line");
- $labels = $legend;
-
- foreach ($labels as $k => $v) {
- $labels[$k] = iconv('utf-8', 'gb2312', $v);
- }
- $data = $data;
- $graph = new Graph($width,$height,"auto");
- $graph->img->SetMargin(40,40,40,40);
- $graph->img->SetAntiAliasing();
- $graph->SetScale("textlin");
- $graph->SetShadow();
- $graph->title->Set(iconv('utf-8', 'gb2312',"{$title}"));
- $graph->title->SetFont(FF_SIMSUN,FS_NORMAL,14);
- $graph->SetFrame(false,'#ffffff',0);
- $graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL,9);
- $graph->xaxis->SetTickLabels($labels);
- $graph->xaxis->SetLabelAngle(0);
-
- $p1 = new LinePlot($data);
- $p1->mark->SetType(MARK_FILLEDCIRCLE);
- $p1->mark->SetFillColor("#0080C0");
- $p1->mark->SetWidth(4);
- $p1->SetColor("#000000");
- $p1->SetCenter();
- $graph->Add($p1);
-
- $graph->Stroke();
- }
-
- function createhorizoncolumnar($title,$subtitle,$data=array(),$size=40,$height=100,$width=80,$legend=array()){
- vendor("Jpgraph.jpgraph");
- vendor("Jpgraph.jpgraph_bar");
- $datay = $data;
- $datax = $legend;
-
- foreach ($datax as $k => $v) {
- $datax[$k] = iconv('utf-8', 'gb2312', $v);
- }
-
- $count = count($datay);
- $addheight = 0;
- if($count>10){
- $addheight = ($count-10)*20;
- }
- $height=$height+$addheight;
-
-
- $graph = new Graph($width,$height,'auto');
- $graph->SetScale("textlin");
-
-
- $graph->SetFrame(false);
- $graph->SetFrame(false,'#ffffff',0);
-
-
- $graph->Set90AndMargin(70,10,50,30);
-
-
- $graph->SetMarginColor('white');
-
-
- $graph->SetBox();
-
-
- $graph->SetBackgroundGradient('white','white',GRAD_HOR,BGRAD_PLOT);
-
-
- $graph->title->Set(iconv('utf-8', 'gb2312',"{$title}"));
- $graph->title->SetFont(FF_SIMSUN,FS_BOLD,12);
- $graph->subtitle->Set("(".iconv('utf-8', 'gb2312',$subtitle).")");
- $graph->subtitle->SetFont(FF_SIMSUN,FS_NORMAL,10);
-
- $graph->xaxis->SetTickLabels($datax);
- $graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL,10);
-
-
- $graph->xaxis->SetLabelMargin(10);
-
-
- $graph->xaxis->SetLabelAlign('right','center');
-
-
-
- $graph->yaxis->scale->SetGrace(10);
-
-
- $graph->yaxis->Hide();
-
-
- $bplot = new BarPlot($datay);
-
-
-
-
-
-
- $bplot->SetFillGradient('blue','#0080C0',GRAD_HOR);
-
-
- $bplot->value->Show();
- $bplot->value->SetFont(FF_ARIAL,FS_NORMAL,7);
- $bplot->value->SetAlign('left','center');
- $bplot->value->SetColor("black");
- $bplot->value->SetFormat('%.0f');
-
-
-
- $graph->Add($bplot);
-
-
- $txt = new Text('');
- $txt->SetPos(130,399,'center','bottom');
- $txt->SetFont(FF_COMIC,FS_NORMAL,8);
- $graph->Add($txt);
-
-
- $graph->Stroke();
- }
- }
|