GoogleChartLegend.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2008 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 GoogleChartLegend extends BaseGoogleChartParameter
00016     {
00017         protected $name = 'chdl';
00018         
00019         private $items = array();
00020         private $position = null;
00021         
00025         public static function create()
00026         {
00027             return new self;
00028         }
00029         
00030         public function __construct()
00031         {
00032             $this->position =
00033                 GoogleChartLegendPositionType::create(
00034                     GoogleChartLegendPositionType::LEFT
00035                 );
00036         }
00037         
00041         public function setPosition(GoogleChartLegendPositionType $type)
00042         {
00043             $this->position = $type;
00044             
00045             return $this;
00046         }
00047         
00051         public function addItem($item)
00052         {
00053             $this->items[] = $item;
00054             
00055             return $this;
00056         }
00057         
00058         public function toString()
00059         {
00060             $items = implode('|', $this->items);
00061             
00062             return $this->name.'='.$items.'&'.$this->position->toString();
00063         }
00064     }
00065 ?>