Tidied up the way the graphs load.

Moved the JS into a seperate file.
Created a method with the JSONResponse object to expose the data
Modified the JS to read the data via ajax for the graph