D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
rekaj3773
Full window
Github gist
Turkey Election
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } svg {background: gray;} </style> </head> <body> <script> var width = 700, height = 580; var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500); svg.append("text") .text("text") .attr("y", 200) .attr("x", 120) .attr("font-size", 36) .attr("font-family", "monospace"); var g = svg.append('g'); var mercatorProjection = d3.geoMercator() .scale(190000) .rotate([71.057, 0]) .center([0, 42.313]) .translate([width/2, height/2]); var geoPath = d3.geoPath() .projection(mercatorProjection); d3.json('turkeyProvinces.geojson',function(error,mapData){ console.log(mapData); g.selectAll('path') .data(mapData.features) .enter() .append('path') .attr('fill', '#ccc') .attr('d', geoPath); }); </script> </body>
https://d3js.org/d3.v4.min.js