Refactored repeated chart code into separate js file