title: Is it possible to use rangeBand() on an ordinal scale with a dynamic domain?
body: <p>My data looks like this...</p>
  
  <pre><code>var data = [{name:'a', value : 97},
            {name:'b', value : 24},
            {name:'c', value : 10}];
  </code></pre>
  
  <p>I have an ordinal scale created like this...</p>
  
  <pre><code>var y = d3.scale.ordinal().rangeBands([0, 30 * data.length]);
  </code></pre>
  
  <p>and I am using it to create a basic graph like this...</p>
  
  <pre><code>    chart.selectAll("rect")
          .data(data)
          .enter().append("svg:rect")
          .attr("y", function(d,i){ return y(d.name);})
          .attr("width", function(d,i){ return x(d.value);})
          .attr("height", y.rangeBand());
  </code></pre>
  
  <p>According to the d3 docs (<a href="https://github.com/mbostock/d3/wiki/Ordinal-Scales#wiki-ordinal_domain" rel="noreferrer">here</a>) you dont HAVE to specify a domain for an ordinal scale, and it will get populated as you try to use it. In my situation however y(d.name) always returns 0 and y.rangeBand() raises an exception, even though when I look the domain array has been populated inside the scale object.</p>
  
  <p>So, I have worked around this by pre-defining my domain...</p>
  
  <pre><code>.domain(data.map(function (d){ return d.name;}))
  </code></pre>
  
  <p>but I would like to be able to dynamically add to this domain and right now if I do, it doesn't expand beyond the original values set on creation. Is this even possible?</p>
  
  <p>I'm very new to d3, so I may be missing something important here.</p>