D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tyramoss
Full window
Github gist
Module 3
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Kaarten</title> <script type="text/javascript" src="https://d3js.org/d3.v3.js"></script> <style type="text/css"> body { background-color: #eeeeee; font-family: Helvetica, Arial, sans-serif; } h1 {font-family: sans-serif; font-weight: 100; font-size: 20px; color: #92CC50; padding-left: 50px; } p {font-family: sans-serif; font-weight: 100; font-size: 11px; padding-left: 50px; line-height: 15px; } a:link { text-decoration: none; color: #92CC50; } a:hover { text-decoration: underline; } a:visited { color: #92CC50; } a:active { color: #92CC50; } path:hover { fill: #ffffff; } text {font-family: sans-serif; font-size: 9px; } svg { background-color: white; } #container { width: 600px; margin-left: auto; margin-right: auto; margin-top: 25px; padding: 25px; background-color: white; box-shadow: 1px 1px 1px 1px #ccc; } path { stroke: white; stroke-width: 0.5; fill: #F4E7D3; } </style> </head> <body> <div id="container"> <h1>Kaart van Nederland</h1> <p>Dit is de kaart van Nederland gemaakt in d3.js. </p> <p>Bronnen: <a href="https://www.statsilk.com">Statsilk</a>, 2015</p> </div> <script type="text/javascript"> //Width and height var w = 500; var h = 500; //Define map projection var projection = d3.geo.mercator() .center([ 5, 53]) .translate([ w/2, 100 ]) .scale([ 6000 ]); //Define path generator var path = d3.geo.path() .projection(projection); //Create SVG var svg = d3.select("#container") .append("svg") .attr("width", w) .attr("height", h); //Load in GeoJSON data d3.json("nl3.json", function(json) { //Bind data and create one path per GeoJSON feature svg.selectAll("path") .data(json.geometries) .enter() .append("path") .attr("d", path); }); </script> </body> </html>
Modified
http://d3js.org/d3.v3.js
to a secure url
https://d3js.org/d3.v3.js