2 /*=======================================================================
3 // File: JPGRAPH_CANVAS.PHP
4 // Description: Canvas drawing extension for JpGraph
6 // Author: Johan Persson (johanp@aditus.nu)
7 // Ver: $Id: jpgraph_canvas.php,v 1.1 2006/07/07 13:37:14 powles Exp $
9 // Copyright (c) Aditus Consulting. All rights reserved.
10 //========================================================================
13 //===================================================
15 // Description: Creates a simple canvas graph which
16 // might be used together with the basic Image drawing
17 // primitives. Useful to auickoly produce some arbitrary
18 // graphic which benefits from all the functionality in the
19 // graph liek caching for example.
20 //===================================================
21 class CanvasGraph
extends Graph
{
24 function CanvasGraph($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) {
25 $this->Graph($aWidth,$aHeight,$aCachedName,$timeout,$inline);
31 function InitFrame() {
32 $this->StrokePlotArea();
36 function Stroke($aStrokeFileName="") {
37 if( $this->texts
!= null ) {
38 for($i=0; $i < count($this->texts
); ++
$i) {
39 $this->texts
[$i]->Stroke($this->img
);
42 if( $this->iTables
!== null ) {
43 for($i=0; $i < count($this->iTables
); ++
$i) {
44 $this->iTables
[$i]->Stroke($this->img
);
47 $this->StrokeTitles();
49 // Should we do any final image transformation
50 if( $this->iImgTrans
) {
51 if( !class_exists('ImgTrans') ) {
52 require_once('jpgraph_imgtrans.php');
55 $tform = new ImgTrans($this->img
->img
);
56 $this->img
->img
= $tform->Skew3D($this->iImgTransHorizon
,$this->iImgTransSkewDist
,
57 $this->iImgTransDirection
,$this->iImgTransHighQ
,
58 $this->iImgTransMinSize
,$this->iImgTransFillColor
,
59 $this->iImgTransBorder
);
63 // If the filename is given as the special _IMG_HANDLER
64 // then the image handler is returned and the image is NOT
66 if( $aStrokeFileName == _IMG_HANDLER
) {
67 return $this->img
->img
;
70 // Finally stream the generated picture
71 $this->cache
->PutAndStream($this->img
,$this->cache_name
,$this->inline
,$aStrokeFileName);