Refactored Chart controller