angular nvd3 piechart不会从后端渲染数据

时间:2014-12-12 04:52:12

标签: javascript angularjs d3.js nvd3.js

我使用angular d3指令从后端数据渲染饼图。 饼图适用于静态数据:

$http({
    method : 'GET',
    url : piechart_url,
    headers:{
    'Content-Type' :'application/json'
}})
.success(function(resp,status,headers,config) {
    //try hard coded here
    $scope.exampleData = [
           { key: "One", y: 5 },
           { key: "Two", y: 2 },
           { key: "Seven", y: 9 }
    ];
})

但它不适用于后端API的数据。 *它仅在饼图中呈现第一个键。 *

$http({
   method : 'GET',
   url : piechart_url,
   headers:{
     'Content-Type' :'application/json'
   }})
   .success(function(resp,status,headers,config) {
      $scope.exampleData = resp.items;
   })

resp.items包含

   [{"key":"ONE","y":10000},{"key":"TWO","y":10}]

我尝试过添加/删除引号。

0 个答案:

没有答案