Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Created August 1, 2015 13:34
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 aaizemberg/b076dffdb37495a26387 to your computer and use it in GitHub Desktop.
Save aaizemberg/b076dffdb37495a26387 to your computer and use it in GitHub Desktop.
4 círculos (lie factor = 1)
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>4 circulos</title>
</head>
<body>
<script>
var h = 200, w = 500;
var data = [10,25,50,100];
var svg = d3.select("body")
.append("svg")
.attr("width",w)
.attr("height",h);
var area = d3.scale.sqrt().domain([0, 100]).range([0, 50]);
var px = d3.scale.linear().domain([0, data.length-1]).range([w/(data.length+1), w - (w/(data.length+1)) ]);
svg.selectAll("circle").data(data).enter()
.append("circle")
.attr("cx", function(d,i) {return px(i);} )
.attr("cy", h / 2)
// .attr("r", function(d) {return 6*Math.sqrt(d);});
.attr("r", area );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment