Created
December 4, 2012 14:43
-
-
Save tenntenn/4204649 to your computer and use it in GitHub Desktop.
d3binding.js
This file contains hidden or 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 = [ | |
sb.observable(10), | |
sb.observable(20), | |
sb.observable(30), | |
sb.observable(40) | |
]; | |
// Create binding | |
var b = sb.d3.binding().transition() | |
.style("width", function(d) { | |
var width = sb.observable(d() * 10 + "px"); | |
sb.binding(d).computed(width, function(){ | |
return d() * 10 + "px"; | |
}).bind(); | |
return width; | |
}) | |
.text(function(d){ | |
return d; | |
}); | |
var chart = d3.select('#chart'); | |
chart.selectAll("div").data(data).enter().append("div").call(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment