Skip to content

Instantly share code, notes, and snippets.

@blakef
Last active August 29, 2015 14:27
Show Gist options
  • Save blakef/188cb12c8fa16fbaa927 to your computer and use it in GitHub Desktop.
Save blakef/188cb12c8fa16fbaa927 to your computer and use it in GitHub Desktop.
VLJxxO
let c = {
width: 100,
height: 100
};
var svg = d3
.select('body')
.append('svg')
.attr({
width: c.width,
height: c.height
})
;
let data = [d3.range(10), d3.range(10,50), d3.range(50, 100)];
let x = d3.scale.linear().domain([1, 100]).range([0, c.width]);
let y = d3.scale.linear().domain([1, 100]).range([0, c.height]);
let line = d3.svg.line()
.x( (d,i) => x(i) )
.y( (d,i) => y(d) )
.interpolate('linear')
;
svg
.selectAll('path')
.data(data)
.enter()
.append('path')
.attr('d', (d,i) => line(d))
.attr({
stroke: 'red',
'stroke-width': 1,
fill: 'none'
})
;
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment