Skip to Content
D3 for the Impatient
book

D3 for the Impatient

by Philipp K. Janert
May 2019
Intermediate to advanced
256 pages
6h 5m
English
O'Reilly Media, Inc.
Content preview from D3 for the Impatient

Appendix A. Setup, Tools, Resources

Setup

To work with D3, you need to run a web server, either locally or hosted, to serve pages, JavaScript files, and other resources (such as data files). In principle, it is possible to load a local page using the file: protocol and any JavaScript files referenced by it. But browsers may prevent your JavaScript code from loading other resources, such as data files, in this way, depending on the browser’s cross-origin resource sharing (CORS) policy. Browsers are inconsistent in this regard; it is probably best to sidestep the issue by always using a web server when working with D3.

Setting up a web server need not be a challenge: several minimal web servers can be run without further configuration from the command line,1 and many programming languages include ready-to-use web server modules as well. The D3 website recommends http-server, which is a Node.js package. If you have the Node runtime and the npm package manager installed, you can install and run a web server using:2

npm install -g http-server
http-server ./project -p 8080

Because they are part of its standard distribution, Python’s web server modules are ubiquitous, but can be quite slow, even for development work (the -d argument requires Python 3.7 or later):

python -m http.server -d ./project 8080	 # Python 3
python -m SimpleHTTPServer 8080          # Python 2: current dir

The busybox set of tools should be installed on all Debian-derived Linux distributions by default. Its built-in web ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

D3.js Quick Start Guide

D3.js Quick Start Guide

Matthew Huntington

Publisher Resources

ISBN: 9781492046783Errata Page