Refactor charting