Reputation: 1057
In the following code how do I get the number for the index/row that is 'd'?
var docs = svg.selectAll("g")
.data(dataset)
.enter()
.append("g")
.attr("id", function(d) { return d["Identifier"]})
.attr("num", function(d) { return d}) // this
.attr("x", function(d) { return xScale(d3.time.format.iso.parse(d["UserDate"]))})
.attr("y", function(d) { return xScale(d3.time.format.iso.parse(d["UserDate"]))});
Upvotes: 3
Views: 6327
Reputation: 873
simply use :
function(d,i){ ... }
e.g.
.attr('id', function(d,i){return 'item'+i;})
Upvotes: 6