refactor JS charts