So I'm trying to create a google pie chart from an array of objects.
Here is an example:
whenever i make a column from the time key/value pair, the chart appears and works fine. Like this:
data.addColumn('number', 'Time');
However when I used the seconds, the chart doesn't show. Any help would be appreciated.
Here is my code:
google.charts.load('current', {'packages':['corechart', 'timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Create the data table
var data = new google.visualization.DataTable();
data.addColumn('string', 'Title');
data.addColumn('string', 'Time');
for(var i=0;i<sitesData.length;i+=1){
data.addRow([sitesData[i].title, sitesData[i].seconds]);
}
// Set chart options
var options = {'title':'What links I looked At',
'width':1000,
'height':600,
pieHole: 0.3
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);