Refactor chartData