Google Charts API Simple and Extended Encoders in PHP

Google’s charting API has been around for quite a while now, but I’ve only just needed to actually look at it. It became immediately obvious that I needed a PHP encoding function, so off to google I went. Though I found several implementations, they were all incomplete or deficient in one way or another (and it didn’t help that there was an error in google’s extended encoding docs), so I’ve written my own based on several different ones. Both simple and extended encoders support automatic scaling, inflated maximum and lower-bound truncation, so you can pretty much stuff whatever data you like in, with no particular regard for pre-scaling and you’ll get a usable result out. They have an identical interface, so you can use either encoding interchangeably according to the output resolution you need (contrary to popular belief, the encoding to use has very little to do with the range of values you need to graph). By default, the full range of possible values is used as it just seems silly not to. I deliberately omit the ‘s:’ and ‘e:’ prefixes so that you can call these functions for multiple data series, and I include a function that does just that. You still need to generate your own URLs and other formatting, but that’s a different problem. Read on for the code… Continue reading “Google Charts API Simple and Extended Encoders in PHP”

Subversion 1.5 repository upgrade on SourceForge

I’ve just had a slightly tricky time upgrading a subversion repository on sourceforge. They have recently added support for subversion 1.5 at the server end. 1.5 brings major new features for merging, but as it’s not backward compatible with older subversion clients, the upgrade is not done automatically. SF have also done a major rearrangement of their documentation while transferring everything to Trac, and it’s not always easy to get the right info. Normally to upgrade a subversion repo, you just run the ‘svnadmin upgrade /path/to/repo’, however, it’s not quite so simple on sourceforge as you don’t have direct access to the repo, and the instructions they give are slightly wrong at the time of writing. You’re likely to get an error like this (it’s not obvious that this is a fatal error) when you reload a dump file:

svnadmin: File already exists: filesystem ‘/svnroot/projectname/db’, transaction ‘443-0’, path ‘tags’
\* adding path : tags …

This is because load is intended to add files to an existing repo, not to replace those that are already there, so you need to wipe the repo and start from scratch.

So, here is a working command sequence that needs to be run from a project login shell on sourceforge (it applies to the project you’re logged in through, substitute your project’s name for projectname):

adminrepo –checkout svn
svnadmin dump /svnroot/projectname > svn.dump
rm -rf /svnroot/projectname/\*
svnadmin create /svnroot/projectname
svnadmin load /svnroot/projectname < svn.dump adminrepo --save svn

Yes, you do need to delete the whole thing and re-import it, but it’s quick and easy, and you have a backup in the dump file you take at the start. After the upgrade, make sure you get a new checkout of your project to ensure that you’re using 1.5 all the way through. Now you’ll find that commands like ‘svn merge –reintegrate’ work.