D3 Bar Graph example not working locally

The d3.tsv method makes an AJAX request for data. On most browsers, this won’t work locally due to the Same Origin Policy, which generally prohibits AJAX requests to file:/// urls.

To get an example that uses AJAX running locally, you’ll need a local webserver. If you have Python, running

> python -m SimpleHTTPServer

from the command line in the directory with your files will do it.

and if you are using python 3

> python -m http.server 9000

If you prefer node.js, try http-server.

Leave a Comment