Create data/configuration variables

At the bottom of the <body> tag, we're referencing an app.js file. Let's create that file and add the following code to it:

var WIDTH = 360;
var HEIGHT = 360;
var radius = Math.min(WIDTH, HEIGHT) / 2;

var dataset = [
    { label: 'Bob', count: 10 },
    { label: 'Sally', count: 20 },
    { label: 'Matt', count: 30 },
    { label: 'Jane', count: 40 }
];
console.log(dataset);

To be sure that it's working and linked up properly, we've added console.log(dataset) to the bottom. Let's open index.html in Chrome and view the developer console, to make sure that everything is hooked up the way it should be:

Once we're sure that ...

Get D3.js Quick Start Guide 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.