March 2018
Beginner to intermediate
514 pages
13h 11m
English
This is where the magic happens around binding data. In D3.js, once you have selected elements, with the enter() method you are creating nodes (referenced as d in function(d)) for incoming data and with exit() you remove those nodes if they are no longer needed. Taking the following example, all paragraphs are selected and an array of data is entered into the selection. Once the data has been entered, a node is created for each single array element which allows it to loop through each node and apply some logic to it as shown in the following code:
<html><body></body><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.js"></script><script>d3.select("body") .selectAll("p") .data([4, 8, 15, 16, 23, 42]) .enter().append("p") ...Read now
Unlock full access