Skip to content

Instantly share code, notes, and snippets.

@steadicat
Created April 25, 2011 17:11
Show Gist options
  • Save steadicat/940838 to your computer and use it in GitHub Desktop.
Save steadicat/940838 to your computer and use it in GitHub Desktop.
D3 data update not working
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