title: Working with JSON and Angular NVD3
body: <p>My HTML code: </p>
  
  <p>Here I am retrieving fields(<code>key</code>) from <code>JSON</code> file and displaying it in the options. Whichever option I am selecting from selection's dropdown section , I am sending that option to my angular script js file , through nvd3 directive data option( <code>data="drawData(data.repeatSelect1)"</code> ).</p>
  
  <pre><code>&lt;div ng-controller="chartCtrl"&gt;
  
  &lt;label for="repeatSelect1"&gt; Field 1: &lt;/label&gt;
  &lt;select name="repeatSelect1" id="repeatSelect1" ng-model="data.repeatSelect1"&gt;
    &lt;option ng-repeat="(key, val) in jsondata[0]"&gt;{{key}}&lt;/option&gt;
  &lt;/select&gt;
  &lt;br /&gt;
  &lt;strong&gt;Selected Field:&lt;/strong&gt; {{data.repeatSelect1}}&lt;br /&gt;
      &lt;div class="col-md-6"&gt;
          &lt;div class="well well-lg"&gt;
                  &lt;h2&gt;&lt;kbd&gt;Chart 1&lt;/kbd&gt;&lt;/h2&gt;
                  &lt;nvd3-pie-chart
                        data="drawData(data.repeatSelect1)"
                        showLabels="true"
                        labelType="percent"
                        showValues="false"
                        tooltips="true"
                        x="xFunction()"
                        y="yFunction()"
                        donut="true"
                        donutRatio=".5"
                        labelThreshold = "0.05"
                        showLegend="true"
                        donutLabelsOutside="false"
                        transitionDuration = "500"&gt;
                  &lt;/nvd3-pie-chart&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my angular script code : </p>
  
  <pre><code>    angular.module('myapp').factory("test",['$http',function($http){
      var obj = {};
  
      obj.fetchdata=function(){
          return $http.get('http://localhost:8080/data/my_json_file.json');
      }
  
      return obj;
  }]) .controller('chartCtrl',function($scope,test){
          test.fetchdata().success(function(data){
              $scope.jsondata = data;
  
  
              $scope.drawData = function(tobeselected){
                                          d3.nest()
                                          .key(function(d)
                                              {
                                                  console.log(tobeselected);
                                                  return d.tobeselected;
                                              })
                                          .rollup(function(v){return v.length;})
                                          .entries(data)
              }
  
              $scope.xFunction = function() {
                return function(d) {
                  return d.key;
                };
              }
              $scope.yFunction = function() {
                return function(d) {
                  return d.values;
                };
              }
          });
  })
  </code></pre>
  
  <p>And here is my_json_file.json</p>
  
  <pre><code>[{"Serial":"ARTUCALA","Location":null,"Date":"2014-10-02T00:00:00","Count":1,"Preset":null},{"Serial":"ZAKDJSJS","Location":null,"Date":"2014-10-02T00:00:00","Count":1,"Preset":null},{"Serial":"ARTUCALA","Location":null,"Date":"2014-10-02T00:00:00","Count":1,"Preset":null},{"Serial":"ARTUCALA","Location":null,"Date":"2014-10-02T00:00:00","Count":1,"Preset":null},{"Serial":"ZAKDJSJS","Location":null,"Date":"2014-10-02T00:00:00","Count":1,"Preset":null},{..}...]}
  </code></pre>
  
  <p>Code is working fine without any error. </p>
  
  <p>For Example : If I select "Serial" field in drop down,it is selected properly and displayed in angularjs script file also ( using console.log(tobeselected);), but my d3.nest option is not working properly. </p>
  
  <p>If I give normally like </p>
  
  <p><code>d3.nest()
  .key(function(d){return d.Serial;}
  .rollup(function(v){return v.length;})</code></p>
  
  <p>I am getting the chart properly. PLease help me to solve this problem . </p>