Hello World – D3.js style

Now let's apply what we have learned in this chapter by stepping through an example, and see how we use D3.js to modify the DOM. The example will be the same as the one we just saw in the previous section; we'll walk through it to see how it functions.

The following is the entire entire HTML for the application:

<!DOCTYPE html>
<html>
  <head>
    <meta name="description" content="D3byEX 1.1>
  </head>
  <body>
    <script src="http://d3js.org/d3.v3.min.js" 
            charset="utf-8"></script>
    <script>
      d3.select('body')
        .append('h1')
        .text('Hello World!');
    </script>
  </body>
</html>

Note

bl.ock (1.1): http://goo.gl/7KkIuC

The code appends a level one header using an h1 tag to the body tag of the document. The h1 tag then has its content set to the ...

Get D3.js: Cutting-edge Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.