Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active January 17, 2021 00:57
Show Gist options
  • Select an option

  • Save d3indepth/f28e1c3a99ea6d84986f35ac8646fac7 to your computer and use it in GitHub Desktop.

Select an option

Save d3indepth/f28e1c3a99ea6d84986f35ac8646fac7 to your computer and use it in GitHub Desktop.

Revisions

  1. @animateddata animateddata revised this gist Aug 2, 2017. 2 changed files with 0 additions and 0 deletions.
    Binary file added preview.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  2. @animateddata animateddata revised this gist Jul 21, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -61,7 +61,7 @@


    // REQUEST DATA
    d3.json('ne_110m_land.json', function(err, json) {
    d3.json('https://gist.github.com/d3indepth/f28e1c3a99ea6d84986f35ac8646fac7/raw/c58cede8dab4673c91a3db702d50f7447b373d98/ne_110m_land.json', function(err, json) {
    geojson = json;
    window.setInterval(update, 100);
    })
  3. @animateddata animateddata created this gist Jul 21, 2017.
    3 changes: 3 additions & 0 deletions .block
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    license: gpl-3.0
    height: 440
    border: no
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Spinning globe.

    From [D3 in Depth](http://d3indepth.com) book by [Peter Cook](http://animateddata.co.uk).
    71 changes: 71 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    <!DOCTYPE html>
    <meta charset="utf-8">
    <head>
    <title>Geo (spinning))</title>
    </head>

    <style>
    body {
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    font-size: 14px;
    color: #333;
    }
    </style>

    <body>
    <div id="content">
    <canvas width="800" height="400"></canvas>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>

    <script>
    var geojson = {}

    var context = d3.select('#content canvas')
    .node()
    .getContext('2d');

    var projection = d3.geoOrthographic()
    .scale(300);

    var geoGenerator = d3.geoPath()
    .projection(projection)
    .pointRadius(4)
    .context(context);

    var yaw = 300;

    function update() {
    projection.rotate([yaw, -45])

    context.clearRect(0, 0, 800, 600);

    context.lineWidth = 0.5;
    context.strokeStyle = '#333';

    context.beginPath();
    geoGenerator({type: 'FeatureCollection', features: geojson.features})
    context.stroke();

    // Graticule
    var graticule = d3.geoGraticule();
    context.beginPath();
    context.strokeStyle = '#ccc';
    geoGenerator(graticule());
    context.stroke();

    yaw -= 0.2
    }



    // REQUEST DATA
    d3.json('ne_110m_land.json', function(err, json) {
    geojson = json;
    window.setInterval(update, 100);
    })

    </script>
    </body>
    </html>
    129 changes: 129 additions & 0 deletions ne_110m_land.json
    129 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.