example code from d3 class