Skip to content

Instantly share code, notes, and snippets.

@floofydugong
Last active October 21, 2016 15:44
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 floofydugong/52adf1be04261ead2a4bd2499c2d1b5c to your computer and use it in GitHub Desktop.
Save floofydugong/52adf1be04261ead2a4bd2499c2d1b5c to your computer and use it in GitHub Desktop.
Visfest - Intro to D3.js
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<svg id="my-svg"></svg>
<div id="test"></div>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("#my-svg")
.attr("width", 960)
.attr("height", 500)
var awesomeData = [5,42,66,81,90
]
svg.selectAll("circle")
.data(awesomeData)
.enter()
.append("circle")
.attr("r",function(d,i){
return d
})
.attr("cx",200, function(d,i){
return 50 + i * 100
})
.attr("cy",200)
.attr("fill","#4747ff")
.attr("stroke","#c04fc4")
.attr("stroke-width",12)
// var div = d3.select("#test")
// .selectAll("div.bar")
// .data("awesomeData")
// .enter()
// .append("div").classed("bar",true)
// .style("position","absolute")
// .style("width","50px")
// .style("top", function(d,i){
// return 50 +i * 50
// })
// .style("left","240px")
// .style("width","50px")
// .style("height",function(d,i){
// return d
// })
// .style("background-color", "blue")
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment