2016-10-26 2 views
0

Content.JSON 아래주어진 AngularJS와 dxChart에 변수

[{ 
status: "Allocated", 
count: 45 
}, { 
status: "Bench", 
count: 89 
}, { 
status: "Mobile", 
count: 12 
}, { 
status: "Project", 
count: 1 
}, { 
status: "SAP", 
count: 18 
}, { 
status: "Testing", 
count: 68 
}, { 
status: "vvvv", 
count: 70 
}]; 

를 JSON의 URL 데이터를 분석 할 수 어떻게 JSON URL이 데이터를 가져 오기 위해 노력하고 있지만, 콘솔 내가 오류

아래에 무엇입니까 내 AngularJS와 모듈이다

dxChart.js : 9 E2001 - 유효하지 않은 데이터 소스. 참조 : http://js.devexpress.com/error/15_2/E2001

angular.module('myApp') 
.controller('valueController', ['$scope', '$http', '$window', function ($scope, $http, $window) {  

var mainInfo = null;  

    $http({ 
    method : "GET", 
    url : "/JSON/Content.json", 
    dataType: 'json', 
    }).then(function mySucces(response) {   

    mainInfo = response.data; 

    }, function myError(response) 
    { 
     $window.alert(response.statusText); 
    }); 

$scope.chartOptions = { 

      dataSource: mainInfo,  

      series: { 
       argumentField: "status", 
       valueField: "count", 
       name: "SIDG Java", 
       type: "bar", 
       color: '#1899dd' 
      } 
     }; 
}]); 

답변

0

내가 생각

입력이 잘못 포맷 당신이 제공하는 JSON 데이터입니다. https://jsonformatter.curiousconcept.com/

JSON 끝 부분에 세미콜론을 사용하지 마십시오. 여기에 올바른 형식은 다음과 같습니다

[{ 
"status": "Allocated", 
"count": 45 
}, { 
"status": "Bench", 
"count": 89 
}, { 
"status": "Mobile", 
"count": 12 
}, { 
"status": "Project", 
"count": 1 
}, { 
"status": "SAP", 
"count": 18 
}, { 
"status": "Testing", 
"count": 68 
}, { 
"status": "vvvv", 
"count": 70 
}] 

는 또한 구문 분석 예외

try { 
    mainInfo = JSON.parse(response); 
} catch (err) { 
    console.log(err); 
} 
을 처리하기 위해 시도의 catch 블록의 사용을