forked from Maptime030/Leaflet-D3-Workshop
-
Notifications
You must be signed in to change notification settings - Fork 2
D3 step 2
NieneB edited this page May 3, 2017
·
13 revisions
Now we will load the vd data and visualize it as circles. (from the leaflet starter workshop)
-
Put the vd.geojson file in your js folder
-
Copy the next script
// create a new SVG group element var layerVD = svg.append('g'); d3.json("js/vd.geojson", function(data){ //Create a circle for each city layerVD.selectAll("circle") .data(data.features) .enter() .append("circle") .attr("cx", function(d) { //[0] returns the first coordinate (x) of the projected value return projection(d.geometry.coordinates)[0]; }) .attr("cy", function(d) { //[1] returns the second coordinate (y) of the projected value return projection(d.geometry.coordinates)[1]; }) .attr("r", 5) .style("fill", "blue") .style("opacity", 0.75); });
-
Change the colours and play around with the style attributes!
- Book: interactive data visualization Scott Murray. Or on-line via http://alignedleft.com/tutorials/d3/about
- follow tutorials on YouTube for example of D3.vienno