Refactor Javascript (tentative)

* Pull out code to independent classes
* Use reusable charts