Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created February 23, 2014 18:46
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/9175424 to your computer and use it in GitHub Desktop.
Save vicapow/9175424 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var years = ["2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035", "2036", "2037", "2038", "2039", "2040"]
var svg2 = d3.select('body').append('svg')
svg2.append('text') // comment out this line, and you should notice i === 0
var yearsList = svg2.selectAll("text")
.data(years)
.enter()
.append("text")
.attr("font-size","12")
.attr("font-family","calibri")
.attr("x", 50)
.attr("y", function(d,i) {return (( i * 14)+28)})
.text((function(d,i) {return i + " : " + d }))
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment