refactor chart.js