title: d3 choropleth: changing data without reloading map
body: <p>I'm using d3 (more like learning to use) to create a choropleth map.  I've managed load my data and geojson object and get a map to display, but I would like to add some transitions and the ability for the user to choose their data.</p>
  
  <p>Here's an example of what I have so far (thanks to github and Mike Bostock's nice gist viewer):</p>
  
  <p><a href="http://bl.ocks.org/4131166" rel="nofollow">http://bl.ocks.org/4131166</a>; and
  <a href="http://gist.github.com/4131166" rel="nofollow">http://gist.github.com/4131166</a></p>
  
  <p>I had managed to get the colours to change by changing the associated class to the  group, but I swapped this to the js version of Cynthia Brewer's colours as I wanted to transition between them.  I also want the colours to change when a different 'band' is selected.</p>
  
  <p>I think my problem lies in the updateValues function - it's doing too much.  It's loading the data, drawing the polygons and populating the colour all in one go.</p>
  
  <p>Is it possible to draw the polygons, and then associate the colour in a separate function?</p>
  
  <p>I had toyed with the idea of adding a:</p>
  
  <p>.attr("id", function(d) { return d.id; })</p>
  
  <p>line to the statement which draws the paths, and then somehow using that to link to the data in a separate statement, but I'm not quite sure how I would achieve this - I guess somehow retrieving each path's id and linking to the data...?</p>
  
  <p>Any help would be gratefully appreciated.  Even if that is suggestions on how to improve my code.  I'm always happy observe best practice where relevant.</p>