d3.js noob : How to pass dynamic variable as data
问题 I'm trying to change the data set via a variable passed from the clicked button. Here's an example of what I'm doing so far: http://jsfiddle.net/earlybirdtechie/qmC9E/ d3.selectAll('button.decadeBtn') .on("click", function() { var currentDecadeName = $(this).attr('data-decade'); console.log('currentDecadeName: '+ currentDecadeName); svg.selectAll("rect.bars") .data(currentDecadeName, function(d) { return d.id }) .transition() .duration(1499) .ease("bounce") .attr({ height: function(d,i) {