I'm trying to assign different elements different attribtsty. But everyone is given the same (last) attribute. What's the matter?
for (var i = 1; i < 12; i++) {
d3.select("#id_" + i)
.text(parseFloat(data[i - 1] / 1000000).toFixed(2))
.on("mouseover", function (d) {
d3.select("#tooltip")
.style("left", "200px")
.style("top", d3.event.pageY - 30 + "px")
.select("#info")
.html("<b>" + keys[i - 2] + "</b>");
d3.select("#tooltip").classed("hidden", false);
})
.on("mouseout", function () {
d3.select("#tooltip").classed("hidden", true);
});
}
Link: JSFIDDLE