Created
April 25, 2011 17:11
-
-
Save steadicat/940838 to your computer and use it in GitHub Desktop.
D3 data update not working
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 chart = d3.select('body') | |
.append('svg:svg').attr('width', 800).attr('height', 200) | |
chart.selectAll('rect') | |
.data([13,8,2,0,23,29,100]) | |
.enter() | |
.append('svg:rect').attr('fill', 'steelblue') | |
.attr('width', 20) | |
.attr('height', function(d) { return d }) | |
.attr('x', function(d,i) { return 20*i }) | |
.attr('y', function(d) { return 200 - d }) | |
setTimeout(function() { | |
chart.selectAll('rect') | |
.data([2,13,7,8,4,2,0,23,29,100,38,10,30,12]) | |
.attr('height', function(d) { return d }) | |
.attr('x', function(d,i) { return 20*i }) | |
.attr('y', function(d) { return 200 - d }) | |
.enter() | |
.append('svg:rect').attr('fill', 'steelblue') | |
.attr('width', 20) | |
.attr('height', function(d) { return d }) | |
.attr('x', function(d,i) { return 20*i }) | |
.attr('y', function(d) { return 200 - d }) | |
}, 2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment