Skip to content

Instantly share code, notes, and snippets.

@rickdg
Created October 28, 2014 21:21
Show Gist options
  • Save rickdg/5848b87f13ed7cb6a5c9 to your computer and use it in GitHub Desktop.
Save rickdg/5848b87f13ed7cb6a5c9 to your computer and use it in GitHub Desktop.
draw rect then move it
{"endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.6316353887399463,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"description":"draw rect then move it","fileconfigs":{"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"ajax-caching":true}
var svg = d3.select("svg");
var xscale = d3.scale.linear()
.domain([0, 1])
.range([0, 608]);
var yscale = d3.scale.linear()
.domain([0, 1])
.range([0, 682]);
var brush = d3.svg.brush()
.x(xscale)
.y(yscale);
var slider = svg.append("g")
.attr("transform", "translate(" + [100, 100] + ")");
brush.extent([0.4, 0.6]);
brush(slider);
slider.selectAll("rect.background")
.attr("height", 386)
.attr("width", 613);
.background {
visibility: visible !important;
}
.extent {
visibility: visible !important;
fill: #ffffff;
fill-opacity: 0.3;
}
.resize rect {
visibility: visible !important;
fill: #00E753;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment