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”

Why isn’t UK voting anonymous?

I voted in the European election today. I was pre-registered and had received my voting card. I went to the polling station where they looked at my card, checked it against my name on the electroal roll, crossed it out, and noted its number on a list next to the unique ID of the ballot paper. I made my choice and put the slip in the ballot box.

Much of this process is necessary in order to combat fraud and ballot rigging, however, it’s clearly not anonymous – a simple reference back from the paper’s ID to my voting card ID means that the government knows what I voted. Knowing what I voted gives no anti-fraud advantage I can see, and means that the collected data is way more sensitive than it needs to be. The simple fact that this knowledge exists is likely to distort voting patterns – people might be afraid of their political leanings being exposed. I’m not particularly worried about that personally, but those with more extreme views (like those that vote for the BNP) might not want this known, and it undermines the absolute right to freedom of association. Political affiliation is regarded as the highest form of ‘personal data’ under the data protection act, along with ethnicity, sexual preference, medical records etc, and the best way to avoid problems with this kind of data is not to keep it in the first place, as the numerous leaks/losses/exposures of government information have highlighted. So why is it done? Aren’t elections meant to be done by secret ballot? Did I miss something? Why aren’t more people disturbed by this?