TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-14-2007, 05:08 PM   #1 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default Google chart extended data encoding help

Hey, I need some help with an algorithm for the GoogleChart "wrappers" that I am working with. I'm in the process of writing the extended data encoding algorithm, I've come up with something that works, but I now there is a better solution to it using math. Here is the code that I came up with, it all works and should prove to be a good reference.

php Code:
public static function convert($nValue)
    {
        // This code will be slow, and should be replaced with a mathematical algorithm
       
        assert($nValue >= 0);
                           
        $aMask = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
                        'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
                        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
                        'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                        'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
                        '8', '9', '-', '.');
       
        $iLength = count($aMask);                     
        $iCount = 0;       
           
        for ($i = 0; $i < $iLength; $i++)
        {         
            for ($j = 0; $j < $iLength; $j++)
            {
                if ($nValue == $iCount)
                {
                    return $aMask[$i] . $aMask[$j];
                }

                $iCount++;
            }
        }
                           
        return '__';
    }

Any help with this would be greatly appreciated.

Here's the link to Google's documentation on the extended encoding:
http://code.google.com/apis/chart/#extended

One last note, I'm not sure if I was on the right track, but I was thinking that the math algorithm would need to use a base64 style numbering system, replacing each of the 64 possible values with the values provided by Google and then somehow do the math (it just all got too much for me).
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design