Charts won't display when I use this particular object key value in addColumn

20 views
Skip to first unread message

David Koch

unread,
Feb 16, 2018, 4:10:48 PM2/16/18
to Google Visualization API
So I'm trying to create a google pie chart from an array of objects. 

Here is an example:

{title: "Robert Olson - Debate Paper 2017-18 - 489494 - Google Docs", url: "https://docs.google.com/document/d/16P-9H6iJPj4LHEJW3SVAc_k7Q6T8zCPLJCTCLwL9DqQ/edit", time: 42.812, seconds: " 43s"}

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);
Reply all
Reply to author
Forward
0 new messages