[ Launch: Taller Jacathon d3.js ] 8e7f1af2e96ac0788240 by bluezio
-
-
Save agarciadom/8e7f1af2e96ac0788240 to your computer and use it in GitHub Desktop.
Taller Jacathon d3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"Taller Jacathon d3.js","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/0TfS57U.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [40, 30, 50] | |
var maxRadius = 30; | |
var padding = 10; | |
var separation = 5; | |
var colorScale = d3.scale.category10() | |
var radiusScale = d3.scale.sqrt() | |
.domain([0, d3.max(data)]) | |
.range([0, maxRadius]); | |
var svg = d3.select("svg"); | |
svg.selectAll("circle") | |
.data(data) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: maxRadius + padding, | |
cy: function (d, i) { | |
return (1 + 2 * i) * (maxRadius + separation); | |
}, | |
r: function (d) { | |
return radiusScale(d); | |
}, | |
fill: function (d, i) { | |
return colorScale(i); | |
} | |
}) | |
.on("click", function(d) { | |
d3.select(this) | |
.transition().duration(1000) | |
.attr({fill: "red", cy: 300}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment