onsa
2/22/2017 - 10:11 AM

D3

D3

//  select element
  d3.select('css-selector')     //  returns first
    .selectAll('css-selector');     //  returns array

//  create new element
    .append('tagname');

//  apply/remove class
    .classed("classname", boolean)

//  bind data
    .data(variable);

//  enter data to the DOM
    .enter();
    //  if data.length > DOMElements.length, it creates new placeholder elements for append
    //  entered data is found on element's _data_ attribute

//  style
    .style('rule', 'value');
    .style('rule', function(data) {
      //  stuff
      return data;
    })

//  add innerHTML
    .text('...');
    .tect(function(data) { return data; });
    //  function parameter is the _data_ attribute's value