CLASS LinearScale
(Defined in: jpgraph.php : 4805)
 LinearScale 
 SetAutoMax() 
 SetAutoMin() 
 SetAutoTicks() 
 SetGrace() 
 

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 SetAutoMax($aMax)
Fix the maximum value for a scale

ArgumentDefaultDescription
$aMax  Maximum value

Description
Fix a maximum value for a scale eventhough autoscaling is used for the min value. 

Example

// For a negative scale we might want to make sure it
// always start at the top from 0
$graph->y2scale->SetAutoMax(0);

 

 

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 SetAutoTicks($aFlag)
Determine ticks automtically with manual scale

ArgumentDefaultDescription
$aFlag true TRUE = determine ticks automatically

Description
This is used in conjunction when a manual scale is specified. In normall cases one has also to specify major and minor tick steps.

For example:
$graph->SetScale("textlin",0,70);
$graph->yscale->ticks->Set(10,2);

However by instead using

$graph->SetScale("textlin",0,70);
$graph->yscale->SetAutoTicks();

The major and minor ticks are determined automatically.

The thing you have to be aware of is that the specified min and max values might be slightly modified so that the end/beginning of the scale will fall on a major tick step.

By default the auto ticks are off.  
 

See also
Graph::SetScale

Example

// Manually set Y-scale min=30, max=90
$graph->SetScale('textlin',30,90);

// Let JpGraph figure out suitable tick marks
$graph->yscale->SetAutoTicks();


 

 

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);