Skip to content

Instantly share code, notes, and snippets.

@wiederkehr
Last active January 17, 2020 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wiederkehr/4691995 to your computer and use it in GitHub Desktop.
Save wiederkehr/4691995 to your computer and use it in GitHub Desktop.
D3.js Template

Simple Gist template to create and publish visualizations with D3.js.

<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Title</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="script.js"></script>
</body>
</html>
(function() {
var margin = {top: 20, right: 20, bottom: 20, left: 60},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
})()
body {
font: 10px "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.axis path {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment