refactored d3 directive