2👍
✅
Have you even attempted something? You didn’t show any solution. Anyway, here’s a possible implementation
var source = [
{"value": {"DE":2,"NP":20,"BD":28,"TW":1},
"end_time":"2016-07-05T07:00:00+0000"},
{"value":{"DE":5,"NP":11,"BD":22,"BE":2,"FJ":2},
"end_time":"2016-07-06T07:00:00+0000"},
{"value":{"DE":5,"NP":24,"BD":29},
"end_time":"2016-07-07T07:00:00+0000"}
]
var $scope = {};
$scope.labels = [];
$scope.data = [];
$scope.series = [];
source.forEach(function(item){
$scope.series.push(item.end_time)
var values = []
Object.keys(item.value).forEach(function(key) {
if ($scope.labels.indexOf(key) === -1) {
$scope.labels.push(key)
}
values.push(item.value[key])
})
$scope.data.push(values)
})
console.log($scope)
Source:stackexchange.com