GoogleGridedLineChart.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2009 by Denis M. Gabaidulin                             *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00015     final class GoogleGridedLineChart extends GoogleNormalizedLineChart
00016     {
00017         private $grid = null;
00018         
00022         public static function create()
00023         {
00024             return new self;
00025         }
00026         
00030         public function setGrid(GoogleChartGrid $grid)
00031         {
00032             $this->grid = $grid;
00033             
00034             return $this;
00035         }
00036         
00040         public function getGrid()
00041         {
00042             return $this->grid;
00043         }
00044         
00045         public function toString()
00046         {
00047             if (!$this->grid)
00048                 $this->createDefault();
00049             
00050             $string = parent::toString();
00051             
00052             $string .= '&'.$this->grid->toString();
00053             
00054             return $string;
00055         }
00056         
00060         private function createDefault()
00061         {
00062             $this->grid = GoogleChartGrid::create();
00063             
00064             $maxSteps = $this->getData()->getMaxSteps();
00065             
00066             if ($maxSteps > 0)
00067                 $this->grid->setVerticalStepSize(round(100 / $maxSteps, 1));
00068             
00069             if (
00070                 (
00071                     $axis = $this->axesCollection->getAxisByTypeId(
00072                         GoogleChartAxisType::X
00073                     )
00074                 ) && ($label = $axis->getLabel())
00075                 && ($label->getCount() > 1)
00076             )
00077                 $this->grid->setHorizontalStepSize(
00078                     round(100 / ($label->getCount() - 1), 2)
00079                 );
00080             
00081             return $this;
00082         }
00083     }
00084 ?>