toolkit/javascript/d3/examples/azimuthal/azimuthal.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     1 var xy = d3.geo.azimuthal().scale(240).mode("stereographic"),
       
     2     circle = d3.geo.greatCircle(),
       
     3     path = d3.geo.path().projection(xy),
       
     4     svg = d3.select("body").append("svg:svg");
       
     5 
       
     6 d3.json("../data/world-countries.json", function(collection) {
       
     7   svg.selectAll("path")
       
     8       .data(collection.features)
       
     9     .enter().append("svg:path")
       
    10       .attr("d", function(d) { return path(circle.clip(d)); })
       
    11     .append("svg:title")
       
    12       .text(function(d) { return d.properties.name; });
       
    13 });
       
    14 
       
    15 function refresh(duration) {
       
    16   var p = svg.selectAll("path");
       
    17   if (duration) p = p.transition().duration(duration);
       
    18   p.attr("d", function(d) { return path(circle.clip(d)); });
       
    19   d3.select("#lon span")
       
    20       .text(xy.origin()[0]);
       
    21   d3.select("#lat span")
       
    22       .text(xy.origin()[1]);
       
    23   d3.select("#scale span")
       
    24       .text(xy.scale());
       
    25   d3.select("#translate-x span")
       
    26       .text(xy.translate()[0]);
       
    27   d3.select("#translate-y span")
       
    28       .text(xy.translate()[1]);
       
    29 }