Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class GoogleChartDataSimpleEncoding
00016 extends BaseGoogleChartDataEncoding
00017 {
00018 protected $name = 's:';
00019
00020 private $encodingChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
00021 private $length = null;
00022
00026 public static function create()
00027 {
00028 return new self;
00029 }
00030
00031 public function __construct()
00032 {
00033 $this->length = strlen($this->encodingChars);
00034 }
00035
00036 public function encode(GoogleChartDataSet $set)
00037 {
00038 $encodedString = null;
00039
00040 foreach ($set->getData() as $dataElement) {
00041 if ($dataElement >= 0)
00042 $encodedString .=
00043 $this->encodingChars[
00044 round($this->length - 1)
00045 * $dataElement
00046 / $this->maxValue
00047 ];
00048 else
00049 $encodedString .= '_';
00050 }
00051
00052 return $encodedString;
00053 }
00054
00055 public function toString()
00056 {
00057 return $this->name;
00058 }
00059 }
00060 ?>