The contents of i and d are reversed in handling events callback function
Tyxiang opened this issue · comments
Tyxiang commented
<!DOCTYPE html>
<html class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>about</title>
<script src="./d3.min.js"></script>
</head>
<body>
<svg id="svg" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
<script>
var data = "abc".split("");
d3.select("body").selectAll("text")
.data(data)
.enter()
.append("p")
.text(function (d) { return d; })
.on("click", function (d, i) {
console.log(i);
})
</script>
</body>
</html>
a/b/c will be output.
Philippe Rivière commented
event handlers now receive (event, datum), please see the changelog or release notes.