Charts and graphs: Initial cleanup up of the JavaScript code