[ Launch: transition ] e4f186537d7ee77885f8 by ninestar09
-
-
Save ninestar09/e4f186537d7ee77885f8 to your computer and use it in GitHub Desktop.
transition
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":"transition","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"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} |
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 svg = d3.select("svg"); | |
var data1 = [ | |
{id:"weezy", value:100}, | |
{id:"aeezy", value:42}, | |
{id:"veezy", value:172}, | |
{id:"ceezy", value:82}, | |
{id:"qeezy", value:60}, | |
{id:"zeezy", value:132} | |
]; | |
var data2 = [ | |
{id:"weezy", value:77}, | |
{id:"aeezy", value:28}, | |
{id:"veezy", value:68}, | |
{id:"ceezy", value:147}, | |
{id:"qeezy", value:75}, | |
{id:"zeezy", value:42}]; | |
var bars = svg.selectAll("rect") | |
.data(data1) | |
.enter() | |
.append("rect") | |
.attr({ | |
width:40, | |
height: function(d, i){ | |
return d.value; | |
}, | |
transform: function(d,i){ | |
var x = i*50+246; | |
var y = 138; | |
return "translate("+[x,y]+")"; | |
} | |
}) | |
.classed("bars", true) | |
var button = svg.append("rect") | |
.attr({ | |
width:100, | |
height:30, | |
x:600, | |
y:400, | |
fill: "#e3e3e3", | |
stroke: "#000" | |
}) | |
.on("click", function() { | |
svg.selectAll("rect.bars") | |
.data(data2, function(d) {return d.id}) | |
.transition() | |
.attr({ | |
height:function(d,i){ | |
return d.value; | |
} | |
}) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment