I am trying to use a simple $.ajax GET to retrieve data from an API, and bind it to Google Charts. My API returns this data:
This is the format that the Google documentation uses to declare the datatable in-page. However, when creating the table from downloaded data, the console shows:
Error: Not an array
Current code is:
function LoadJsonData() {
$.ajax({
type: 'GET',
url: '/api/Test',
dataType: "json",
success: function (data) {
var dt0 = new google.visualization.arrayToDataTable(data, false);
var chart0 = new google.visualization.PieChart(document.getElementById('ContentPlaceHolderBody_ctl02'));
var options0 = { title: 'Some title', width: 400, height: 300 };
chart0.draw(dt0, options0);
}
});
}
google.charts.load('current', { packages: ['corechart', 'table'] });
google.charts.setOnLoadCallback(LoadJsonData);