Linking D3GL
To get started with D3GL, first download D3GL here, by right-clicking the link and choosing "Save as..." or something similar.
Alternatively, you can add the following line between
<head>and
</head>:
<script type="text/javascript" src="http://dcpos.ch/d3gl/js/d3gl.min.js"></script>
I will keep the above links updated, but keep in mind that D3GL is under heavy development, so the latest (un-minified) version lives here on Github.
Running a local server
When you are developing locally, your browser may raise something along the lines of
XMLHttpRequest cannot load the url Origin null is not allowed by Access-Control-Allow-Originwhen you try to read files out of the local file system. To avoid this, you can run a local web server. I find that a simple solution is to run Python's built-in server:
python -m SimpleHTTPServer 8888 &
... after which you can access
http://localhost:8888/.
If you are using a Mac, I find that MAMP works beautifully.
Using D3GL
Now that you have linked D3GL and run a local server, you can use
d3.gl.globein your code:
<script type="text/javascript"> $(function(){ // use d3.gl to create a beautiful visualization }); </script>
Next →
No comments:
Post a Comment