This video is available to students only

Creating our workspace

We create our wrapper and learn about d3 selection objects.

Now we're set up and ready to start updating our webpage!

To add elements to our page, we'll need to specify an existing element that we want to append to.

Remember the #wrapper element already populated in index.html? One of d3's modules, d3-selection, has helper functions to select from and modify the DOM.

We can use d3.select() , which accepts a CSS-selector-like string and returns the first matching DOM element (if any). If you're unfamiliar with CSS selector syntax, there are three main types of selectors:

  • you can select all elements with a class name (.class)

  • you can select all elements with an id (#id), or

  • you can select all elements of a specific node type (type).

 

This page is a preview of Fullstack D3 Masterclass

Start a new discussion. All notification go to the author.