I dont know if this is correct, but it seems to work. Its a PHP
version of
http://code.google.com/apis/chart/docs/data_formats.html#encoding_data
class Encode
{
public $simpleEncoding =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
public
$ExEncoding='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
function simpleEncode($valueArray,$maxValue)
{
$chartData = 's:';
foreach($valueArray as $data)
{
if ( $data >= 0)
{
$chartData .= substr ($this->simpleEncoding,
round( (strlen($this->simpleEncoding)-1) * $data / $maxValue),1);
}
else
{
$chartData .= '_';
}
}
return $chartData;
}
function extendedEncode($data, $maxVal)
{
$EXTENDED_MAP_LENGTH = strlen($this->ExEncoding);
$chartData = 'd:';
foreach($data as $dataval)
{
$scaledVal = ceil($EXTENDED_MAP_LENGTH * $EXTENDED_MAP_LENGTH *
$dataval / $maxVal);
if($scaledVal > ($EXTENDED_MAP_LENGTH * $EXTENDED_MAP_LENGTH -
1))
{
$chartData .= "..";
}
else if ($scaledVal < 0)
{
$chartData .= '__';
}
else
{
$quotient = ceil($scaledVal / $EXTENDED_MAP_LENGTH);
$remainder = $scaledVal - $EXTENDED_MAP_LENGTH *
$quotient;
$chartData .= substr($this->ExEncoding,$quotient,1) .
substr($this->ExEncoding,$remainder,1);
}
}
return $chartData;
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Chart API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-chart-api?hl=en.