Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created September 6, 2012 05:28
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 enjalot/3651651 to your computer and use it in GitHub Desktop.
Save enjalot/3651651 to your computer and use it in GitHub Desktop.
just another inlet to tributary

No parent Inlet

{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":610,"height":608,"hide":false}}
var svg = d3.select("svg");
var data1 = [
{id: "weezy", value: 100},
{id: "yeezy", value: 40},
{id: "jeezy", value: 60}
];
var data2 = [
{id: "jeezy", value: 42},
{id: "weezy", value: 171},
{id: "yeezy", value: 129},
];
var bars = svg.selectAll("rect")
.data(data1)
.enter()
.append("rect")
.attr({
width: 30,
height: function(d,i) {
return d.value;
},
transform: function(d,i) {
var x = i * 40 + 100;
var y = 100;
return "translate(" + [x, y] + ")";
}
})
.classed("bars", true)
var button = svg.append("rect")
.attr({
width: 100,
height: 30,
x: 426,
y: 200,
fill: "#e3e3e3",
stroke: "#000"
})
.on("click", function() {
svg.selectAll("rect.bars")
.data(data2, function(d) { return d.id })
.transition()
//.delay(1000)
.duration(1499)
//.ease("linear")
//.ease("cubic")
.ease("bounce")
.attr({
height: function(d,i) {
return d.value;
}
})
})
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment