× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS
Jonathan Eunice
Dec 05, 2014
<p>When you're building a graph, table, or other visual display with <a href="http://d3js.org/">D3.js</a>, it requires a different kind of thinking. Many developers are used to very imperative styles ("Here's some data. Do X with it!") D3.js has more of a declarative or functional style ("For all of the rows in the table, here's what should be done with them.") </p><p>Declarative techniques work really well, but they can be a daunting change of pace. So, keep in mind:​ You don't iterate over data structures and do things. Instead, you select sets of items. Those items may not even yet exist in your document at the time you select them. But it doesn't matter! You're declaring a set, and then what should be done to represent that set. If the set is empty (intially), the next move is probably a <code>.enter().append("...")</code>. In other words <code>for-this-set.lets-create-some-elements().here-they-are("...")</code></p><p>Understanding this declarative/functional model goes a long way in getting your D3.js projects off the ground.</p>
comments powered by Disqus