CLASS LinearScale
(Defined in: jpgraph.php : 2852)
 LinearScale 
 GetMaxVal() 
 GetMinVal() 
 MatchMin3() 
 SetAutoMin() 
 SetGrace() 
 Translate() 
 

Class usage and Overview
This class is the main scale class and implements the linear and integer scale for the axis.

 

See also related classes:
Axis and LogScale

 


Class Methods

 

 

function GetMaxVal()
// get maximum value for scale


Description
Return max value for scale 
 
See also
LinearScale::GetMinVal

Example

$max $graph->xaxis->scale->getMaxval();

 

 

function GetMinVal()
// Get the minimum value in the scale


Description
Return the minimum value of scale 
 
See also
LinearScale::GetMaxVal

Example

$max $graph->xaxis->scale->getMaxval();

 

 

function MatchMin3($a,$b,$c,$weight)
Determine the minimum of three values with a weight for last value

ArgumentDefaultDescription
$a  First value
$b  Second value
$c  Third value
$weight  Weight for third value

Description
Determine the minimum of three values. The third value is weighted with '$weight' in a positive since so the other values have to be '$weight' times smaller to be choosen.

This helper method is used when we decide on waht scale the autoscaling should use. The weighting is normally used to give a slight favour for multiples of 5 as scale values. 

Example

// For a or b to be choosen as min they have to be less than
// 80% of c.
// If a=12, b=13, c=14 then b will be choosen since a and b are
// not small enough
// If a=5, b=13, c=14 then a is the smallest since it is lower
// than 80% of c
$min $this->MatchMin3($a,$b,$c,0.8);

 

 

function SetAutoMin($aMin)
Set the minimum data value when the autoscaling is used.

ArgumentDefaultDescription
$aMin  Min value

Description
Set the minimum data value when the autoscaling is used. Usefull if you want a fix minimum (like 0) but automtic maximum value. 

Example

// Just let the maximum be autoscaled
$graph->yaxis->scale->SetAutoMin(0);

 

 

function SetGrace($aGraceTop,$aGraceBottom)
// Specify scale "grace" value (top and bottom)

ArgumentDefaultDescription
$aGraceTop  Top grace value
$aGraceBottom 0 Bottom grace value

Description
By default the autoscaling determines the minimum and maximum as close to the plots min and max values as possible. Sometimes this might not be suitable and you need some more "air". For example if you plot a bar plot with values on top of the bar. If the bar reaces the max value (which is also the scale end point) the value on top of the bar might be out in the margin.)

By specifyin the grace you get added space. The value specified is interpretated as extra percentage of the total scale range.

For example if the scale range (without grace) is (0,100) and you add 10% top grace (with SetGrace(10)) the modified scale will be (0,110) and if you use a 100% top grace the scale will be (0,200) and so on. 

Example

$graph->xaxis->scale->SetGrace(50);

 

 

function Translate($aCoord)
// Translate between world and screen

ArgumentDefaultDescription
$aCoord  World coordinate

Description
translate between world and screen coordinate for this scale. This is normally just an private internal routine but if you wnat to you could theoretically use this to position arbitrarty object in the graph space. 
 
See also
LinearScale::RelTranslate

Example

$pixcoord $graph->yaxis->scale->Translate(134.76);