Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active August 29, 2015 14:03
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 vicapow/eb5d98e7478042fd4a98 to your computer and use it in GitHub Desktop.
Save vicapow/eb5d98e7478042fd4a98 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<style>
body, html{
margin: 0;
}
</style>
<body>
<script>
var w = window.innerWidth, h = window.innerHeight
var svg = d3.select('body').append('svg').attr('width', w).attr('height', h);
var data = [
['first line', 'second line'],
['second first line', 'second second line']
];
var t = svg.selectAll('text').data(data)
.enter().append('text')
.attr('y', function(_, i){ return 4 * i + 'em' } );
t.selectAll('tspan').data(function(d){ return d })
.enter().append('tspan')
.attr('x', '0.5em')
.attr('dy', '1.4em')
.text(function(d){ return d});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment