Not able to display the pie chart using NVD3 with this JSON, i believe i need to tweak the code according to this JSON output

I need some pointers regarding this issue.

I believe i need to tweak this code, i tried as below, but failed to display the chart.

This output i got through a REST call.

If use the JSON output has below and with this code it displays the pie chart.

JSON:

[
{
“label”: “One”,
“value” : 29.765957771107
} ,
{
“label”: “Two”,
“value” : 0
} ,
{
“label”: “Three”,
“value” : 32.807804682612
} ,
{
“label”: “Four”,
“value” : 196.45946739256
} ,
{
“label”: “Five”,
“value” : 0.19434030906893
} ,
{
“label”: “Six”,
“value” : 98.079782601442
} ,
{
“label”: “Seven”,
“value” : 13.925743130903
} ,
{
“label”: “Eight”,
“value” : 5.1387322875705
}
]

enter code here

If i use the JSON output has below, it was not displaying.

{“pie”:[
{
“label”: “One”,
“value” : 29.765957771107
} ,
{
“label”: “Two”,
“value” : 0
} ,
{
“label”: “Three”,
“value” : 32.807804682612
} ,
{
“label”: “Four”,
“value” : 196.45946739256
} ,
{
“label”: “Five”,
“value” : 0.19434030906893
} ,
{
“label”: “Six”,
“value” : 98.079782601442
} ,
{
“label”: “Seven”,
“value” : 13.925743130903
} ,
{
“label”: “Eight”,
“value” : 5.1387322875705
}
]}

`openCAFApp.directive(‘piechart’, [‘RestServiceProvider’,
function(restService) {
return {
restrict: ‘E, A, C’,
link: function(scope, element, attrs, controller) {
restService.invoke(
REST_URLS.PIE_CHART_LOCAL_GET,
function(response,
status, headers, config) {

                    var pieChartData = response;
                    alert(response) ;
                        nv.addGraph(function() {
                          var piechart = nv.models.pieChart()
                              .x(function(d) { return d.label })
                              .y(function(d) { return d.value })
                              .showLabels(true);

                            d3.select("#"+element.attr("id"))
                              .datum(pieChartData)
                              .transition().duration(1200)
                              .call(piechart);
                          return piechart;
                    });


                },
                function(response, status, headers, config) {
                    alert(response);
                }, null, null, scope);
        }
    };
}

]);`

i try this code,but did not worked.

`openCAFApp.directive(‘piechart’, [‘RestServiceProvider’,
function(restService) {
return {
restrict: ‘E, A, C’,
link: function(scope, element, attrs, controller) {
restService.invoke(
REST_URLS.PIE_CHART_LOCAL_GET,
function(response,
status, headers, config) {

                    var pieChartData = response.pie;
                    alert(response) ;
                        nv.addGraph(function() {
                          var piechart = nv.models.pieChart()
                              .x(function(d) { return d.pie.label })
                              .y(function(d) { return d.pie.value })
                              .showLabels(true);

                            d3.select("#"+element.attr("id"))
                              .datum(pieChartData)
                              .transition().duration(1200)
                              .call(piechart);
                          return piechart;
                    });


                },
                function(response, status, headers, config) {
                    alert(response);
                }, null, null, scope);
        }
    };
}

]);`

Source: AngularJS