One of the projects I worked on at Forge Development needed a dynamic graph to show number of clicks on banners over time. The class I wrote draws the graph from data taken from the database.

Features

  • Easy to add multiple plots on the same graph (e.g. banner impressions compared to clicks on banners)
  • Automatically calculates intervals and maximum values on the Y axis
  • Automatically determines angle of labels on the X axis and how many to show to maximise legibility

There is a working example available at http://static.beingmrkenny.co.uk/portfolio/graph.

View the source for the graph class itself here, and the script which configures and outputs the graph image here.