D3 within an AngularJS app

BHP picture BHP · Jun 21, 2012 · Viewed 20.7k times · Source

I'm trying to create my first app with AngularJS. It looks neat, but there's a lot of abstraction, and I'm just curious if anyone has advice on the most idiomatic way to use the angular methodology to update visuals created with d3js.

Thanks, bp

Answer

Dan Doyon picture Dan Doyon · Jun 21, 2012

In order to make angular and other frameworks play nice is to wrap the "other" frameworks using directives.

http://docs.angularjs.org/guide/directive

The thing that you want to do is to tell angular when data has been updated by the "other" frameworks. If angular doesn't need to know, then your task is simpler.

Here is an example that works with SVG, its awesome

http://sullerandras.github.com/SVG-Sequence-Diagram/

Here is an example that wraps TinyMCE

http://jsfiddle.net/programmieraffe/kjsEV/