Skip to content

Instantly share code, notes, and snippets.

@ludwigschubert
Last active January 11, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludwigschubert/d02a0250bb45f724ba2594b561ca91d1 to your computer and use it in GitHub Desktop.
Save ludwigschubert/d02a0250bb45f724ba2594b561ca91d1 to your computer and use it in GitHub Desktop.
d3-single-brush
<!DOCTYPE html>
<meta charset="utf-8">
<meta title="Minimal D3 v4 single brush example--Ludwig Schubert for Stanford CS448b">
<style>
.grid-background {
fill: #eee;
}
.grid line,
.grid path {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</style>
<body>
<script src="http://d3js.org/d3.v4.min.js"></script>
<script>
var margin = { top: 10, right: 10, bottom: 10, left: 10 },
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 + ")");
svg.append("rect")
.attr("class", "grid-background")
.attr("width", width)
.attr("height", height);
d3.brush(svg);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment