just move 

```js
d3.select('.query-plan').each(function() {
    element = d3.select(this);
    graph(element, queryPlan);
});
```

into the html template for the query vis. The rest can stay.