title: D3.js attr in json not working?
body: <p>I have just started using d3.js. I am trying to use json instead of keep on chaining ".attr". Consider my following code:</p>
  
  <pre><code>const w = 300, h = 100;
  
  const padding = 2;
  const dataset = [5, 10, 15, 20, 25];
  
  const svg = d3.select("body")
    .append("svg")
    .attr("width", w)
    .attr("height", h);
  
  svg.selectAll("rect")
    .data(dataset)
    .enter()
    .append("rect")
    .attr({
      x: (d, i) =&gt; i * w / dataset.length,
      y: d =&gt; h - d * 4,
      width: w / dataset.length - padding,
      height: d =&gt; d * 4,
      fill: d =&gt; `rgb(${d * 10},0,0)`
    })
  </code></pre>
  
  <p>When I was chaining .attr the bar chart was rendering properly. But now it is not working.</p>