factored out visualization js code into separate file