title: Access key/value in a paired-bar-chart - D3.js
body: <p>I'm attempting to make a Paired Bar Graph between <em>glob</em> and <em>local</em> within my JS Object/Array. I've made bar graphs in D3 previously, but haven't used objects. I'm finding it difficult to access the correct data.</p>
  
  <p>Eventually, the <em>keyword</em> data will be used in the axis. And the <em>cpc</em> will be used as a tooltip.</p>
  
  <p>Here's the code that I have so far: (<a href="http://jsfiddle.net/enigmarm/juY5E/1/" rel="nofollow">or see my JSFiddle</a>)</p>
  
  <pre><code>var w = 600;
  var h = 400;
  
  var colors = ["#377EB8", "#4DAF4A"];
  
  var dataset = {"keyword": ["payday loans", "title loans", "personal loans"],
              "glob": ["1500000", "165000", "550000"],
              "local": ["673000", "165000", "301000"],
              "cpc": ["14.11", "12.53", "6.14"]   
  };
  
  
  var series = 2; // Global &amp; Local
  
  var x0Scale = d3.scale.ordinal()
              .domain(d3.range(dataset.glob.length))
              .rangeRoundBands([0, w], 0.05); 
  
  
  var yScale = d3.scale.linear()
              .domain([0, d3.max(dataset, function(d) {return d.glob;})]) 
              .range([0, h]);
  
  var glob = function(d) {
      return d.glob;
  };
  
  //SVG element
  var svg = d3.select("#searchVolume")
          .append("svg")
          .attr("width", w)
          .attr("height", h);     
  
  // Graph Bars
  svg.selectAll("rect") 
      .data(dataset, glob) //access the series here?
      .enter()
      .append("rect")
      .attr("x", function(d, i){
          return x0Scale(i);
      })
      .attr("y", function(d) {
          return h - yScale(d.glob);
      })
      .attr("width", x0Scale.rangeBand())
      .attr("height", function(d) {
          return yScale(d.glob); // ***************
      })
      .attr("fill", colors[1]);   
  </code></pre>
  
  <p>Currently, the chart doesn't get populated. I assume I am not accessing values correctly. I'm simply trying to get data from <em>glob</em> to make sure I'm accessing things correctly - and then from there I was going to populate both series, etc. Is my issue not accessing key/values correctly?</p>