Created
December 29, 2012 09:45
-
-
Save trtg/4405796 to your computer and use it in GitHub Desktop.
using d3 brush feature for region selection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"using d3 brush feature for region selection","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.6040622299049263,"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,"hidepanel":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this can be used to select/brush | |
//a particular region in a scatterplot | |
//like for linked plots | |
var svg = d3.select("svg"); | |
var xscale = d3.scale.linear() | |
.domain([0,1]) | |
.range([0,300]); | |
var yscale = d3.scale.linear() | |
.domain([0,1]) | |
.range([0,300]); | |
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",300); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.background { | |
visibility: visible !important; | |
} | |
.extent{ | |
visibility: visible !important; | |
fill:#C200A3; | |
} | |
.resize rect{ | |
visibility: visible !important; | |
fill: #0089e7; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment