refactored chart.js file