Home

D3

This all relates back to "D3 in action". Check back to the book for more info.

The power of d3

The main power of d3 comes through the ability to select document elements d3.selectAll("circle.a").style("fill", "red").attr("cx", 100);

This takes every circle on our page with the class of "a" and turns it red and moves it so that its center is 100 pixels to the right of the left side of our <svg> canvas.

Working with arrays

someNumbers = [17, 82, 9, 500, 40]; someColors = ['blue', 'red', 'chartreuse', 'orange'];

One example of a useful array function is .filter(), which returns an array whose elements satisfy a test you provide. For instance, here’s how to create an array out of someNumbers that had values greater than 40:

someNumbers.filter(function(el) {return el >= 40});

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/d3/d3

Sections


Related