Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created May 20, 2013 14:28
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 enjalot/5612571 to your computer and use it in GitHub Desktop.
Save enjalot/5612571 to your computer and use it in GitHub Desktop.
Tributary inlet
{"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":"Tributary inlet","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},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"thumbnail":"http://i.imgur.com/g4krjJh.png"}
var svg = d3.select("svg");
var xscale = d3.scale.linear()
.domain([0, 1])
.range([0, 300]);
var brush = d3.svg.brush()
.x(xscale)
var slider = svg.append("g")
.attr("transform", "translate(" + [100, 100] + ")");
var move = 0.01;
d3.select('body').on("keydown", function(){
var ext = brush.extent()
var key = String.fromCharCode(d3.event.keyCode);
if(key === "%") { //left arrow key
ext[0] -= move;
if(d3.event.shiftKey) {
ext[1] -= move;
}
} else if(key === "'") { //right arrow key
ext[0] += move;
if(d3.event.shiftKey) {
ext[1] += move;
}
}
brush.extent(ext);
brush(slider)
});
brush.extent([0.4, 0.6]);
brush(slider);
slider.selectAll("rect")
.attr("height", 59);
.background {
visibility: visible !important;
fill: #949494;
}
.extent {
visibility: visible !important;
fill: #006DC2;
}
.resize rect {
visibility: visible !important;
fill: #37CECE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment