refactor chart factory