Hello everyone, I am attempting to display a chart using data obtained from an API. The output of the API is in the form of List<String>
and not in JSON format. Here is the snippet of my JS file:
google.load('visualization', '1', {
packages: ['corechart']
});
app.controller("chartController",function($scope,$http)
{
$http.get("/idcountcisco")
.success(function(data){
$scope.cisco=data
console.log($scope.cisco)
})
$http.get("/idcountlog4j")
.success(function(data){
$scope.log4j=data
console.log($scope.log4j)
})
$http.get("/idcountwin")
.success(function(data){
$scope.windows=data
console.log($scope.windows)
})
if (($scope.cisco=!undefined )&&($scope.log4j=!undefined )&&($scope.windows=!undefined ))
{
var data = google.visualization.arrayToDataTable([
['type', 'Qs' ],
['cisco', $scope.cisco],
['lo4j',$scope.log4j ],
['windows',$scope.windows],
]);
var options = {
title: 'Statistiques'
};
var chart = new google.visualization.PieChart(document.getElementById('chartdiv'));
chart.draw(data, options);
}
});
Upon checking the console log, the values retrieved are:
$scope.cisco=18
$scope.log4j=45
$scope.windows=15
However, the displayed chart does not seem to reflect the real values as all variables become equal to true after the conditional statement.
I appreciate any assistance or guidance on this matter.