Last active
August 29, 2015 14:16
-
-
Save pcn/a1c27022579117f106b0 to your computer and use it in GitHub Desktop.
Does this look right? Translating from javascript to clojurescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn- build-map [svg topo-obj] | |
| (let [subunits (.-subunits (.-objects topo-obj)) | |
| geo (.-geo js/d3) | |
| feature (.-feature js/topojson) | |
| mercator (.-mercator geo)] | |
| (.. svg | |
| (append "path") | |
| (datum (feature topo-obj subunits)) | |
| (attr "d" | |
| (.. geo | |
| (path) | |
| (projection (mercator))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From http://bost.ocks.org/mike/map/ | |
| d3.json("uk.json", function(error, uk) { | |
| if (error) return console.error(error); | |
| svg.append("path") | |
| .datum(topojson.feature(uk, uk.objects.subunits)) | |
| .attr("d", d3.geo.path().projection(d3.geo.mercator())); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I'm not sure this looks correct -t he calls to e.g. feature turning into feature.call with the first arg being null is unexpected. | |
| map_brazil.core.build_map = (function build_map(svg,topo_obj){ | |
| var subunits = topo_obj.objects.subunits; | |
| var geo = d3.geo; | |
| var feature = topojson.feature; | |
| var mercator = geo.mercator; | |
| return svg.append("path").datum(feature.call(null,topo_obj,subunits)).attr("d",geo.path().projection(mercator.call(null))); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment