Move chart displaying logic to controller