Started refactoring graph directive