Source for file Axis.class.php
Documentation is available at Axis.class.php 
 * This work is hereby released into the Public Domain.  
 * To view a copy of the public domain dedication,  
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to  
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.  
require_once dirname(__FILE__ ). "/../Graph.class.php";  
 * @package linea21.externals  
     * Axis left and right padding  
     * Axis range callback function  
        'toValue' =>  'toProportionalValue',  
        'toPosition' =>  'toProportionalPosition'  
     * @param float $min Begin of the range of the axis  
     * @param float $max End of the range of the axis  
     function awAxis($min =  NULL, $max =  NULL) {  
        if($min !==  NULL and $max !==  NULL) {  
     * Enable/disable auto-scaling mode  
        $this->auto = (bool) $auto;  
     * Get auto-scaling mode status  
     function hide($hide =  TRUE) {  
        $this->hide = (bool) $hide;  
     function show($show =  TRUE) {  
        $this->hide =  !(bool) $show;  
     * Return a tick object from its name  
     * @param string $name Tick object name  
            return $tick =  &$this->ticks[$name];  
     * @param string $name Tick object name  
     * @param &$tick Tick object  
        $this->ticks[$name] =  &$tick;  
     * @param string $name Tick object name  
            unset ($this->ticks[$name]); 
     * @param bool $hide Hide or not ?  
        foreach($this->ticks as $key =>  $tick) {  
            $this->ticks[$key]->hide($hide);  
     * @param int $style Ticks style  
        foreach($this->ticks as $key =>  $tick) {  
            $this->ticks[$key]->setStyle($style);  
     * @param int $interval Ticks interval  
        foreach($this->ticks as $key =>  $tick) {  
            $this->ticks[$key]->setInterval($interval);  
     * Change number of ticks relative to others ticks  
     * @param &$to Change number of theses ticks  
     * @param &$from Ticks reference  
     * @param float $number Number of ticks by the reference  
        $this->ticks[$to]->setNumberByTick($this->ticks[$from], $number);  
        foreach($this->ticks as $key =>  $tick) {  
     * Change interval of labels  
     * @param int $interval Interval  
        $this->label->setInterval($interval);  
     * Change number of labels  
     * @param int $number Number of labels to display (can be NULL)  
     * Change precision of labels  
     * @param int $precision Precision  
        eval ('function '. $function. '($value) { 
            return sprintf("%.'.(int) $precision. 'f", $value);  
        $this->label->setCallbackFunction($function);  
     * @param array $texts Some texts  
            eval ('function '. $function. '($value) { 
                return isset($texts[$value]) ? $texts[$value] : \'?\';  
            $this->label->setCallbackFunction($function);  
     * Get the position of a point  
     * @param $p Position of the point  
     * @return Point Position on the axis  
        $p1 =  $xAxis->getPointFromValue($p->x);  
        $p2 =  $yAxis->getPointFromValue($p->y);  
     * @param int $alignment New Alignment  
     * Change title position on the axis  
     * @param float $position A new awposition between 0 and 1  
     * Change axis and axis title color  
        $this->title->setColor($color);  
     * @param int $left Left padding in pixels  
     * @param int $right Right padding in pixels  
        $this->padding->set($left, $right);  
            $this->range[0] = (float) $min;  
            $this->range[1] = (float) $max;  
     * Change axis range callback function  
     * @param string $toValue Transform a position between 0 and 1 to a value  
     * @param string $toPosition Transform a value to a position between 0 and 1 on the axis  
            'toValue' => (string) $toValue,  
            'toPosition' => (string) $toPosition  
     * Center X values of the axis  
     * @param float $value The reference value on the axis  
        if($this->line->isVertical() ===  FALSE) {  
            awImage::drawError("Class Axis: setXCenter() can only be used on vertical axes.");  
        $p =  $axis->getPointFromValue($value);  
     * Center Y values of the axis  
     * @param float $value The reference value on the axis  
        if($this->line->isHorizontal() ===  FALSE) {  
            awImage::drawError("Class Axis: setYCenter() can only be used on horizontal axes.");  
        $p =  $axis->getPointFromValue($value);  
     * Get the distance between to values on the axis  
     * @param float $from The first value  
     * @param float $to The last value  
        return $p1->getDistance($p2);  
     * Get a point on the axis from a value  
        list ($min, $max) =  $this->range; 
        $position =  $callback($value, $min, $max);  
     * Get a point on the axis from a position  
     * @param float $position A position between 0 and 1  
        $angle =  $vector->getAngle();  
        $size =  $vector->getSize();  
        return $vector->p1->move(  
            cos($angle) *  $size *  $position,  
            - 1 *  sin($angle) *  $size *  $position 
     * @param $driver A driver  
        $this->title->draw($driver, $p);  
        if($this->isAuto() ===  FALSE) {  
            $partMax =  $max /  $interval;  
            $partMin =  $min /  $interval;  
        $difference =  log($interval) /  log(10);  
        $difference =  floor($difference);  
        $pow =  pow(10, $difference);  
            $intervalNormalize =  $interval /  $pow;  
            $precision =  $difference * - 1 +  1;  
            if($intervalNormalize >  2) {  
        if($min !=  0 and $max !=  0) {  
        if($this->label->getCallbackFunction() ===  NULL) {  
        if($intervalNormalize <=  1.5) {  
        } else if($intervalNormalize <=  2) {  
        } else if($intervalNormalize <=  3) {  
        } else if($intervalNormalize <=  4) {  
        } else if($intervalNormalize <=  5) {  
        } else if($intervalNormalize <=  8) {  
        } else if($intervalNormalize <=  10) {  
                $intervalReal *  $pow * - 1,  
        foreach($this->ticks as $tick) {  
            $tick->setColor($this->color);  
            $tick->draw($driver, $vector);  
            list ($min, $max) =  $this->range; 
            for($i =  0; $i <=  $number; $i++ ) {  
                $labels[] =  $function($i /  $number, $min, $max);  
            $this->label->set($labels);  
        $labels =  $this->label->count();  
        for($i =  0; $i <  $labels; $i++ ) {  
            $this->label->draw($driver, $p, $i);  
        $angle =  $this->line->getAngle();  
        foreach($this->ticks as $name =>  $tick) {  
            $this->ticks[$name] =  $tick;  
    return $min +  ($max -  $min) *  $position;  
    return ($value -  $min) /  ($max -  $min);  
 
 
        
       |