Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3 + Backbone: updating elements for which data has changed

I'm using d3 with Backbone.js models. When the model attributes change, an event is fired and the model is marked with a hasChanged() flag and it returns a changedAttributes() hash. I understand how to use d3's enter() and exit() to handle models that have either been created or removed. What I am having trouble figuring out is how I can modify the respective DOM elements based on model attributes changing. I can use the Backbone helpers to figure out what to modify, but what is the next step with d3?

like image 984
Drew Dara-Abrams Avatar asked Oct 01 '11 04:10

Drew Dara-Abrams


1 Answers

I got some helpful responses on the d3 mailing list: http://groups.google.com/group/d3-js/browse_thread/thread/65c4c8ffb5515ab2 And my solution, based on that advice, is at: https://gist.github.com/1257765

like image 117
Drew Dara-Abrams Avatar answered Sep 20 '22 14:09

Drew Dara-Abrams