Google News
logo
D3.js - Interview Questions
How to Data Binding work in D3.js?
The D3.js is data driven and the data () function is used to join the specified array object of data to the selected DOM elements and return updated selection.
 
The data binding methods : 

1.      data() function : This function Joins the data to the selected elements

2.      enter() function : This functions is used to creates a selection with placeholder references for missing elements

3.      exit() function : This functions is used to removes nodes and adds them to the exit selection which can be later removed from the DOM

4.      datum() function : This functions is used to injects data to the selected element without computing a join
 
The Example looks like :
var dataArray = ["Hello,  Ths is data array!"];
    
var selectData = d3.select("body").selectAll("p").data(dataArray)
      .text(function (dt) {   
    return dt;
});
Advertisement