Added animated loading spinner to chart
Split off javascript into a new file