Source for file MathPlot.class.php
Documentation is available at MathPlot.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__ ). "/Component.class.php";  
 * @package linea21.externals  
   * Start the drawing from this value  
   * Stop the drawing at this value  
   * @param string $f Callback function  
  function awMathFunction($f, $fromX =  NULL, $toX =  NULL) {  
    $this->color =  new awBlack;  
   * @param $color A new awcolor  
   * Get the background color or gradient of an element of the component  
   * @return Color, Gradient  
    return $this->line->getThickness();  
    return $this->line->getStyle();  
 * For mathematics functions  
 * @package linea21.externals  
   * @param int $xMin Minimum X value  
   * @param int $xMax Maximum X value  
   * @param int $yMax Maximum Y value  
   * @param int $yMin Minimum Y value  
  function awMathPlot($xMin, $xMax, $yMax, $yMin) {  
    $this->setPadding(8, 8, 8, 8);  
    $this->extremum =  new awSide($xMin, $xMax, $yMax, $yMin);  
    $this->xAxis->label->hideValue(0);  
    $this->yAxis->label->hideValue(0);  
    $axis->setLabelPrecision(1);  
    $axis->addTick('major', new awTick(0, 5));  
    $axis->addTick('minor', new awTick(0, 3));  
    $axis->addTick('micro', new awTick(0, 1));  
    $axis->setNumberByTick('minor', 'major', 1);  
    $axis->setNumberByTick('micro', 'minor', 4);  
    $axis->label->setFont(new awTuffy(7));  
   * Interval to calculate values  
    $this->interval = (float) $interval;  
   * @param string $name Name for the legend (can be NULL if you don't want to set a legend)  
   * @param int $type Type for the legend  
  function add(&$function, $name =  NULL, $type =  LEGEND_LINE) {  
      $this->legend->add($function, $name, $type);  
    list ($x1, $y1, $x2, $y2) =  $this->getPosition(); 
    $this->xAxis->line->setX($x1, $x2);  
    $this->xAxis->label->move(0, 3);  
    $this->xAxis->setRange($this->extremum->left, $this->extremum->right);  
    $this->yAxis->line->setY($y2, $y1);  
    $this->yAxis->label->move(- 6, 0);  
    $this->yAxis->reverseTickStyle();  
    $this->yAxis->setRange($this->extremum->bottom, $this->extremum->top);  
    if($this->yAxis->getLabelNumber() ===  NULL) {  
      $number =  $this->extremum->top -  $this->extremum->bottom +  1;  
      $this->yAxis->setLabelNumber($number);  
    if($this->xAxis->getLabelNumber() ===  NULL) {  
      $number =  $this->extremum->right -  $this->extremum->left +  1;  
      $this->xAxis->setLabelNumber($number);  
    $this->xAxis->ticks['major']->setNumber($this->xAxis->getLabelNumber());  
    $this->yAxis->ticks['major']->setNumber($this->yAxis->getLabelNumber());  
    for($i =  0, $count =  $this->xAxis->getLabelNumber(); $i <  $count; $i++ ) {  
    $this->xAxis->label->set($labels);  
    for($i =  0, $count =  $this->yAxis->getLabelNumber(); $i <  $count; $i++ ) {  
    $this->yAxis->label->set($labels);  
    $this->grid->draw($driver, $x1, $y1, $x2, $y2);  
    $this->xAxis->draw($driver);  
    $this->yAxis->draw($driver);  
      $fromX =  is_null($function->fromX) ?  $this->extremum->left :  $function->fromX;  
      $toX =  is_null($function->toX) ?  $this->extremum->right :  $function->toX;  
      for($i =  $fromX; $i <=  $toX; $i +=  $this->interval) {  
        if($p->y >=  $y1 and $p->y <=  $y2) {  
          $function->mark->draw($driver, $p);  
          $line->setLocation($old, $p);  
          ($line->p1->y >=  $y1 and $line->p1->y <=  $y2) or  
          ($line->p2->y >=  $y1 and $line->p2->y <=  $y2)  
      // Draw last point if needed  
      if($old !==  NULL and $i -  $this->interval !=  $toX) {  
        if($p->y >=  $y1 and $p->y <=  $y2) {  
          $function->mark->draw($driver, $p);  
        $line->setLocation($old, $p);  
        ($line->p1->y >=  $y1 and $line->p1->y <=  $y2) or  
        ($line->p2->y >=  $y1 and $line->p2->y <=  $y2)  
    // Horizontal lines of the grid  
    $major =  $this->yAxis->tick('major');  
    $interval =  $major->getInterval();  
    $number =  $this->yAxis->getLabelNumber() -  1;  
      for($i =  0; $i <=  $number; $i++ ) {  
    $major =  $this->xAxis->tick('major');  
    $interval =  $major->getInterval();  
    $number =  $this->xAxis->getLabelNumber() -  1;  
      for($i =  0; $i <=  $number; $i++ ) {  
    $this->grid->setGrid($w, $h);  
 
 
        
       |