Last Updated: February 25, 2016
·
1.81K
· david morrow

Scoping D3 to your Backbone view

Recently I used D3 in combination with Backbone.js. Normally when inside a backbone view, you only access the dom elements inside the template you have rendered

var $bar = this.$el.find('.bar')

When selecting objects with D3 instead of jQuery or whatever, I needed to scope my selector to within the Backbone view's scope

var bar = d3.select(this.el).select('.bar')