A recently written GD gallery is used to generate a class library of column and line graphs, which is a teaching routine.
Class imagereport{
var $X;//Picture size X-axis
var $Y;//Picture size Y-axis
var $R;//Background color R value
var $G;//... G.
var $B;//... B.
var $TRANSPARENT;//whether transparent 1 or 0
var $IMAGE;//Picture pair image
//-------------------
var $ARRAYSPLIT;//Specify a symbol to separate the values
var $ITEMARRAY;//value
var $REPORTTYPE;//Chart type, 1 for vertical column 2 for horizontal column 3 for fold line
var $BORDER;//Distance
//-------------------
var $FONTSIZE;//font size
var $FONTCOLOR;//Font Color
--------parameter setting function
function SetImage ($SizeX, $SizeY, $R, $G, $B, $Transparent) {
$this->x= $SizeX;
$this->y= $SizeY;
$this->r= $R;
$this->g= $G;
$this->b= $B;
$this->transparent= $Transparent;
}
function SetItem ($ArraySplit, $ItemArray, $ReportType, $Border) {
$this->arraysplit= $ArraySplit;
$this->itemarray= $ItemArray;
$this->reporttype= $ReportType;
$this->border= $Border;
}
function SetFont ($FontSize) {
$this->fontsize= $FontSize;
}
----------------Body
function PrintReport () {
Header ("Content-type:image/gif");
Build Canvas Size
$this->image=imagecreate ($this->x, $this->y);
Set the canvas background color
$background =imagecolorallocate ($this->image, $this->r, $this->g, $this->b);
if ($this->transparent== "1") {
Background transparent
Imagecolortransparent ($this->image, $background);
}else{
Fill the background color if you are not transparent
Imagefilledrectangle ($this->image,0,0, $this->x, $this->y, $background);
}
parameter font text small and color
$this->fontcolor=imagecolorallocate ($this->image,255-$this->r,255-$this->g,255-$this->b);
Switch ($this->reporttype) {
Case "0":
Break
Case "1":
$this->imagecolumns ();
Break
Case "2":
$this->IMAGECOLUMNH ();
Break
Case "3":
$this->imageline ();
Break
}
$this->printxy ();
$this->printall ();
}
-----------Print an XY axis
function Printxy () {
Draw XY Axis */
$color =imagecolorallocate ($this->image,255-$this->r,255-$this->g,255-$this->b);
$xx = $this->x/10;
$yy = $this->y-$this->y/10;
Imageline ($this->image, $this->border, $this->border, $this->border, $this->y-$this->border,$ color);//x axis
Imageline ($this->image, $this->border, $this->y-$this->border, $this->x-$this->border, $this- >y-$this->border, $color);//y axis
Scale on y-axis
$rulerY = $this->y-$this->border;
while ($rulerY > $this->border*2) {
$rulerY = $rulerY-$this->border;
Imageline ($this->image, $this->border, $rulerY, $this->border-2, $rulerY, $color);
}
Scale on X-axis
$rulerX = $rulerX + $this->border;
while ($rulerX < ($this->x-$this->border*2)) {
$rulerX = $rulerX + $this->border;
Imageline ($this->image, $this->border,10, $this->border+10,10, $color);
http://www.bkjia.com/PHPjc/508716.html www.bkjia.com true http://www.bkjia.com/PHPjc/508716.html techarticle recently wrote a GD library used to generate a column chart and a line chart class library, is a teaching routine bar imagereport var x;//picture size X axis var y;//picture size Y-axis var r;//back ...