Last active
March 26, 2016 09:45
-
-
Save StevenJL/736245e96eebee2e4eef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You filter array data with a anonymous function passed to `filter` | |
| [1,2,3,4,5,6].filter(function(el) {return el >= 4}); | |
| // In this example, we make the html of the div, a function of the data | |
| // in the array. We do this using an anonymous function. | |
| d3.select(“div”).data([1,2,3,4]).enter().append("div") | |
| .html(function (d) {return d}); | |
| // In the below anonymous function, the d argument references the data bound to that div. | |
| // There is a second argument i that references the index, if needed. | |
| d3.select(“div”).data([1,2,3,4]) | |
| .enter() | |
| .append("div") | |
| .attr(“cx”, function(d, i) { return i}) | |
| // You can add interactivity through events. | |
| d3.select(“div”) | |
| .style(“background-color”, “pink”) | |
| .on(“click”, function() { console.log("You clicked a div") }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment