Wednesday, May 20, 2015

JavaScript D3 - example how the function(d, i) works

http://jsfiddle.net/M8nK8/

==HTML==
<script src="http://d3js.org/d3.v3.min.js"></script>
<section></section>


===JS D3==

var data=[10,20,30,40];

var lis = d3.select("section")
          .append("ul")
            .selectAll("li")
            .data(data)

lis.enter()
 .append("li")
 .text(function(d,i){ return "item n° "+i+" has value: "+d})

No comments: