php jpgraph生成曲線グラフ
3832 ワード
<?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()
?>