refactor graphs directive