Commit 7a67b00b authored by Mike Bostock's avatar Mike Bostock
Browse files

Remove brush examples.

parent 36876f17
<!DOCTYPE html>
<meta charset="utf-8">
<title>Brush</title>
<script src="../../d3.js"></script>
<style>
svg {
font: 10px sans-serif;
}
circle {
-webkit-transition: fill-opacity 250ms linear;
}
.selecting circle {
fill-opacity: .2;
}
.selecting circle.selected {
stroke: #f00;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.brush .extent {
stroke: #fff;
fill-opacity: .125;
shape-rendering: crispEdges;
}
</style>
<body>
<script>
var data = d3.range(800).map(Math.random);
var margin = {top: 10, right: 10, bottom: 20, left: 10},
width = 960 - margin.right - margin.left,
height = 100 - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width]);
var y = d3.random.normal(height / 2, height / 8);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
var circle = svg.append("g").selectAll("circle")
.data(data)
.enter().append("circle")
.attr("transform", function(d) { return "translate(" + x(d) + "," + y() + ")"; })
.attr("r", 3.5);
svg.append("g")
.attr("class", "brush")
.call(d3.svg.brush().x(x)
.on("brushstart", brushstart)
.on("brush", brushmove)
.on("brushend", brushend))
.selectAll("rect")
.attr("height", height);
function brushstart() {
svg.classed("selecting", true);
}
function brushmove() {
var s = d3.event.target.extent();
circle.classed("selected", function(d) { return s[0] <= d && d <= s[1]; });
}
function brushend() {
svg.classed("selecting", !d3.event.target.empty());
}
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Brush</title>
<script src="../../d3.js"></script>
<style>
svg {
font: 10px sans-serif;
}
circle {
-webkit-transition: fill-opacity 250ms linear;
}
.selecting circle {
fill-opacity: .2;
}
.selecting circle.selected {
stroke: #f00;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.brush .extent {
stroke: #fff;
fill-opacity: .125;
shape-rendering: crispEdges;
}
</style>
<body>
<script>
var data = d3.range(800).map(Math.random);
var margin = {top: 10, right: 10, bottom: 10, left: 40},
width = 120 - margin.right - margin.left,
height = 960 - margin.top - margin.bottom;
var x = d3.random.normal(width / 2, width / 8);
var y = d3.scale.linear()
.range([height, 0]);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var circle = svg.append("g").selectAll("circle")
.data(data)
.enter().append("circle")
.attr("transform", function(d) { return "translate(" + x() + "," + y(d) + ")"; })
.attr("r", 3.5);
svg.append("g")
.attr("class", "brush")
.call(d3.svg.brush().y(y)
.on("brushstart", brushstart)
.on("brush", brushmove)
.on("brushend", brushend))
.selectAll("rect")
.attr("width", width);
function brushstart() {
svg.classed("selecting", true);
}
function brushmove() {
var e = d3.event.target.extent();
circle.classed("selected", function(d) { return e[0] <= d && d <= e[1]; });
}
function brushend() {
svg.classed("selecting", !d3.event.target.empty());
}
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Brush</title>
<script src="../../d3.js"></script>
<style>
svg {
font: 10px sans-serif;
}
circle {
-webkit-transition: fill-opacity 250ms linear;
}
.selecting circle {
fill-opacity: .2;
}
.selecting circle.selected {
stroke: #f00;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.brush .extent {
stroke: #fff;
fill-opacity: .125;
shape-rendering: crispEdges;
}
</style>
<body>
<script>
var random = d3.random.normal(.5, .1),
data = d3.range(800).map(function() { return [random(), random()]; });
var margin = {top: 10, right: 10, bottom: 20, left: 40},
width = 960 - margin.right - margin.left,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var circle = svg.append("g").selectAll("circle")
.data(data)
.enter().append("circle")
.attr("transform", function(d) { return "translate(" + x(d[0]) + "," + y(d[1]) + ")"; })
.attr("r", 3.5);
svg.append("g")
.attr("class", "brush")
.call(d3.svg.brush().x(x).y(y)
.on("brushstart", brushstart)
.on("brush", brushmove)
.on("brushend", brushend));
function brushstart() {
svg.classed("selecting", true);
}
function brushmove() {
var e = d3.event.target.extent();
circle.classed("selected", function(d) {
return e[0][0] <= d[0] && d[0] <= e[1][0]
&& e[0][1] <= d[1] && d[1] <= e[1][1];
});
}
function brushend() {
svg.classed("selecting", !d3.event.target.empty());
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment