CLASS CanvasScale
(Defined in: jpgraph_canvtools.php : 24)
 CanvasScale 
 CanvasScale() 
 Set() 
 Translate() 
 TranslateX() 
 TranslateY() 
 

Class usage and Overview
This class defines a scale which is meant to be used with canvas graphs to make it possibles to pecify a more convinient scale compared to absoilute pixels coordinates.
This will also let you scale the canvas without any coordinate changes.

 


Class Methods

 

 

function CanvasScale(&$graph,$xmin,$xmax,$ymin,$ymax)
Define a scale for canvas graphs

ArgumentDefaultDescription
&$graph  Canvas graph
$xmin 0 Min X-value for scale
$xmax 10 Max X-value for scale
$ymin 0 Min Y-value for scale
$ymax 10 Max Y-value for scale

Description
Define a scale for canvas graphs. Note the scale values is optionally in this call. The may be later set witha call to the Set() method. 
 
See also
CanvasScale::Set

 

 

function Set($xmin,$xmax,$ymin,$ymax)
Specify scale to use

ArgumentDefaultDescription
$xmin 0 Min X value
$xmax 10 Max X-value
$ymin 0 Min Y-value
$ymax 10 Max Y-value

Description
SPecify min/max values for scale. 

Example

// Setup a basic canvas we can work 
$g = new CanvasGraph(400,200,'auto');
$g->SetMargin(5,11,6,11);
$g->SetShadow();
$g->SetMarginColor("teal");

// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();

// Create a new scale
$scale = new CanvasScale($g);
$scale->Set(0,$xmax,0,$ymax);

 

 

function Translate($x,$y)
Translate a point to absolute screen coordinates

ArgumentDefaultDescription
$x  X-value
$y  Y-value

Description
Translate a point to absolute screen coordinates 
 
See also
CanvasScale::TranslateX and CanvasScale::TranslateY

Example

list($xt,$yt) = $scale->Translate($x,$y);
$graph->img->Point($xt,$yt);

 

 

function TranslateX($x)
Translate X-coordinate

ArgumentDefaultDescription
$x  X-value

Description
Translate X-value into absolute screen coordinates 
 
See also
CanvasScale::Translate

 

 

function TranslateY($y)
Translate Y-value to absolute screen coordinates

ArgumentDefaultDescription
$y  Y-value

Description
Translate Y-value to absolute screen coordinates 
 
See also
CanvasScale::Translate