MCPcopy Index your code
hub / github.com/csev/py4e / brush

Function brush

code/pagerank/d3.v2.js:4253–4309  ·  view source on GitHub ↗
(g)

Source from the content-addressed store, hash-verified

4251 extentDomain; // the extent in data space, lazily created
4252
4253 function brush(g) {
4254 g.each(function() {
4255 var g = d3.select(this),
4256 bg = g.selectAll(".background").data([0]),
4257 fg = g.selectAll(".extent").data([0]),
4258 tz = g.selectAll(".resize").data(resizes, String),
4259 e;
4260
4261 // Prepare the brush container for events.
4262 g
4263 .style("pointer-events", "all")
4264 .on("mousedown.brush", brushstart)
4265 .on("touchstart.brush", brushstart);
4266
4267 // An invisible, mouseable area for starting a new brush.
4268 bg.enter().append("rect")
4269 .attr("class", "background")
4270 .style("visibility", "hidden")
4271 .style("cursor", "crosshair");
4272
4273 // The visible brush extent; style this as you like!
4274 fg.enter().append("rect")
4275 .attr("class", "extent")
4276 .style("cursor", "move");
4277
4278 // More invisible rects for resizing the extent.
4279 tz.enter().append("g")
4280 .attr("class", function(d) { return "resize " + d; })
4281 .style("cursor", function(d) { return d3_svg_brushCursor[d]; })
4282 .append("rect")
4283 .attr("x", function(d) { return /[ew]$/.test(d) ? -3 : null; })
4284 .attr("y", function(d) { return /^[ns]/.test(d) ? -3 : null; })
4285 .attr("width", 6)
4286 .attr("height", 6)
4287 .style("visibility", "hidden");
4288
4289 // Show or hide the resizers.
4290 tz.style("display", brush.empty() ? "none" : null);
4291
4292 // Remove any superfluous resizers.
4293 tz.exit().remove();
4294
4295 // Initialize the background to fill the defined range.
4296 // If the range isn't defined, you can post-process.
4297 if (x) {
4298 e = d3_scaleRange(x);
4299 bg.attr("x", e[0]).attr("width", e[1] - e[0]);
4300 redrawX(g);
4301 }
4302 if (y) {
4303 e = d3_scaleRange(y);
4304 bg.attr("y", e[0]).attr("height", e[1] - e[0]);
4305 redrawY(g);
4306 }
4307 redraw(g);
4308 });
4309 }
4310

Callers

nothing calls this directly

Calls 7

d3_scaleRangeFunction · 0.70
redrawXFunction · 0.70
redrawYFunction · 0.70
redrawFunction · 0.70
selectMethod · 0.45
dataMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected