More refactoring to get to a reusable chart design

Javascript code refactoring made to have all the code needed to
draw/update chart in a single function that can be reused as explained
in:
http://bost.ocks.org/mike/chart/time-series-chart.js