d3.graphScroll() .sections(d3.selectAll('#sections > div')) .on('active', function(i){ console.log(i + 'th section active') })
#sections > div{ opacity: .3 } #sections div.graph-scroll-active{ opacity: 1; }
<h1>Page Title</div> <div id='container'> <div id='sections'> <div>Section 0</div> <div>Section 1</div> <div>Section 2</div> </div> <div id='graph'></div> </div> <h1>Footer</h1>and passed to graphScroll
d3.graphScroll() .graph(d3.selectAll('#graph')) .container(d3.select('#container'))
#container{ position: relative; overflow: auto; } #sections{ width: 200px; float: left; } #graph{ width: 600px; float: left; margin-left: 40px; } #graph.graph-scroll-fixed{ position: fixed; top: 0px; margin-left: 240px; }
#graph.graph-scroll-below{ position: absolute; bottom: 0px; margin-left: 240px; }
- Simple examples
- Self explanatory graphics
- Expose scroll-to functionality