Charts and graphs: Initial cleanup up of the JavaScript code

Cleaned up some of the formatting issues. Still more cleanup needed but it is a start.

@duboisp fyi