Take a more OO approach to handling the d3 data

My knowledge of Javascript scoping is not great, but I think the correct ``this`` might set by default?