Refactor Javascript

* Pull out code to independent classes
* Use reusable charts