Adding Multiple Axis Labels to a Google Chart

Recently I’ve been working on a project using Google Charts API and I absolutely love it. It makes pretty graphs and shows data really nicely – and it’s very painless. I did trip over a little trick today though which took me a little while to work out, so I thought I’d share it here: how to add two levels of label to an axis.

The axes in Google Charts are a bit interesting, because what they display bears absolutely no resemblance to what data is there – you label the axes separately, even if they are numbers. To label multiple things – in this example a scale and some units, you simply specify the axis more than once. To specify which axes should be shown, use chxt (CHart aXis Title) and set something like this:
&chxt=x,y,y

Then add the labels as required, for example:

http://chart.apis.google.com/chart?chxl=1:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|2:||Week+37
&chxr=0,0,20&chxs=0,676767,11.5,0,lt,676767&chxt=y,x,x&chbh=a
&chs=360x240&cht=bvg&chco=CC0057CC,3D7930&chds=0,20
&chd=t1:10.059,12.578,13.6,11.135,11.018,7.104,6.92|50,60,100,40,20,40,30

This produces a graph like this:

You can then add labels (using chxl) and ranges (uses chxr) to your axes as you wish – and even add axis labels to the top and right hand graph edges, using the t and r axes, with as many of each as you’d like, and using their list position as a parameter to the range/label settings. I hope this is useful to someone, as it took me a little bit of research to figure it out.

Make Blogging Your New Years Resolution

Do you have a New Year’s Resolution? Is it to blog (or blog more often)? If so, keep reading!

I’m coming up to my 5th anniversary of blogging and looking at my stats, I’ve written around 150 posts per year for most of that time, although in 2010 I “only” wrote 102 posts, possibly because one or two other things happened in my life. So many people tell me they want to blog, or they have a blog but can’t find the time to write, that I thought I’d try to give some pointers for those resolving to blog this New Year.

Continue reading

Launching Links in Opera from Command Line

I’m an Opera user but I use a number of applications from the command line, and often I want to launch links from those applications into my web browser. I’ve just switched over to reading my feeds using canto (web applications are becoming decreasingly accessible these days, although I’m saving that rant for another day) which is a console-based application. This, like many other applications, allows you to specify a URL handler to use when you want to visit links.

To launch a link into a new tab in an existing Opera window, I simply used this:
opera --remote 'openURL(<url>, new-page)'

Where the <url> is the address to access; the same trick works in other programs too. For example I use irssi for IRC, with the openURL plugin, and this can do the same trick. To launch the link I simply set the http handler like this:
/set openurl_app_http opera --remote 'openURL($1, new-page)'

Since I have to look these settings up every time I want them, I thought I’d blog them for next time – and of course for anyone else who finds this useful between now and then!

Speaking at DIBI

In June 2011 I’ll be speaking at a rather awesome event called DIBI at the Sage in Gateshead (if you’re a southerner, then Gateshead is near Newcastle, which is “up north”). DIBI stands for “Design It, Build It” and has two tracks, one focussing on development and one focussing on design. Last year was their first event and although I didn’t attend, I have only heard good things about both the conference and the socials!

I love it when really fantastic events happen in the north, especially because I’m based in Leeds and have ties to the North East, so I’m very excited to be speaking. Tickets go on sale in the New Year and I hope I’ll see lots of you at the Sage on 8th June!

Preparing for ZCE 5.3

Recently I have been getting to grips with the ZCE since it was updated to take account of PHP 5.3. In the last few weeks I’ve both passed the certificate myself and also taught Zend’s certification training course as a classroom course at NTI Leeds. I thought I’d share my top tips for preparing for taking the ZCE – getting to the standard, last-minute preparations, and also some tips for surviving the day itself (disclaimer: everyone sitting the ZCE signs a declaration not to disclose the contents of the exam, so I can’t actually tell you the questions, sorry!)

Continue reading

OAuth Google API for Unregistered Applications

It is pretty common when using OAuth for there to be a relationship between the provider and consumer; as a consumer you usually register with the provider to obtain a consumer key and consumer secret. Google’s APIs however do not require this. It is recommended that you register your application, however it is also possible to use OAuth without registering.

To make this work, when you sign your OAuth request Google will accept some default values for consumer key and secret – see their documentation on signing oauth requests. To do this, set both consumer key and secret to the value “anonymous”, and proceed as you normally would. The only difference so far as I can see is that the user will be shown a more cautious message when they are prompted to grant access to your application. Personally I think this is a great approach, particularly when prototyping ideas. Registering the applications though is simple and quick so I’d recommend registering for most applications once they get beyond concept stage.

ZCE 5.3: Worth Doing?

I recently took (and passed!) the ZCE 5.3 certification. I’ve been a Zend Certified Engineer (5.0) for nearly 3 years, and I know a lot more about PHP today than I did then. Today I speak and write various things related to PHP, and also teach all sorts of topics including PHP certification. I thought I’d share my thoughts on the ZCE, and I’ll write a follow-up post on how to prepare for it.

Updated Syllabus

The main thing that annoyed me about teaching people for the 5.0 exam in the last couple of years is that it had a topic on the differences between PHP 4 and PHP 5. Personally, I have never worked commercially with PHP 4, and that’s true for lots of developers that I meet. So I ended up trying to teach PHP 4 which seemed silly! Happily that is gone now from the 5.3 Syllabus.

There are some new topics and I’m pleased to see the Web Features topic being added. This brings together some HTTP concepts and overall client/server architecture stuff that really helps round out the syllabus. I consider that studying for the exam is in the interests of all PHP developers, these topics are all useful and relevant.

Continue reading

Declaring Static Methods in PHP

I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that:

  • Static functions can be called dynamically
  • Dynamic functions generate an E_STRICT error if called statically

This made a lot more sense when I thought about it a bit more and wrote some toy code:

Continue reading

Skills Analysis for Teams

When I spoke at PHPNW10 in October, I talked about teams, skills and the importance of benchmarking things in order to illustrate improvements. If you didn’t see the talk, the video and slides are linked off the conference site. In particular I talked about the importance of analysing skills in a team, then improving them, then analysing again to see how things had changed. This post is about that process, some techniques that might apply, and what to do with the results when you get them.

Continue reading