Improve zoom and pan functionality

Added scriptable zoom and pan, and simplified the code by using d3
built-ins better.