Your code isn't inside a callback from the google loader, so the code is 
executing like this:

start loading API -> try to create DataTable (code fails, because API isn't 
loaded yet) -> finish loading API

You need to wrap that code in a function that is called from the google 
loader callback:

function myCallback {
    // chart code here
}
google.load('visualization', '1', {packages: ['corechart'], callback: 
myCallback});

On Wednesday, May 21, 2014 3:57:41 PM UTC-4, TheInnovator wrote:
>
> I am trying to create a line chart but I get the following error 
> *'google.visualization.DataTable' is null or not an object*
>
> Why is the line chart different from others?
>
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script> 
>
> <script type="text/javascript">
>  google.load('visualization', '1', {packages: ['corechart']});
> //Line Chart
> var dataValues = [
> ['Oct', 0, 0],
> ['Nov', 0, 0],
> ['Dec', 0, 0],
> ['Jan', 0, 0], 
> ['Feb', 0, 0],
> ['Mar', 0, 0],
> ['Apr', 0, 0],
> ['May', 0, 0],
> ['Jun', 0, 0],
> ['Jul', 0, 0], 
> ['Aug', 0, 0], 
> ['Sep', 0, 0]
> ];
>  var data = new google.visualization.DataTable();
> data.addColumn('string', 'Month');
> data.addColumn('Number', 'Webpages');
> data.addColumn('Number', 'Documents');
> var monthIndex=0;
> $().SPServices({
> operation: "GetListItems", 
> async: false,
> listName: "508 Monthly Score",
> CAMLViewFields: "<ViewFields><FieldRef Name='Title'></FieldRef><FieldRef 
> Name='Year'></FieldRef><FieldRef Name='Month'></FieldRef><FieldRef 
> Name='Score'></FieldRef></ViewFields>",
> CAMLQuery: "<Query><OrderBy><FieldRef 
> Name=Month></FieldRef></OrderBy></Query>",
> completefunc: function (xData, Status) {
> alert(xData.responseXML.xml);
>   $(xData.responseXML).SPFilterNode("z:row").each(function() { 
>    monthIndex = getMonthIndex($(this).attr("ows_Month"));
> if ($(this).attr("ows_Title") = "Webpages")
> {
> dataValues[monthIndex][1] = $(this).attr("ows_Score");
> }
> else
> {
> dataValues[monthIndex][2] = $(this).attr("ows_Score");
> }
>   });
>  }
>   }); 
>
>   //Data for table chart
>   $.each(dataValues, function (index, value) { 
>         data.addRow([dataValues[index][0], dataValues[index][1], 
> dataValues[index][2]]); 
> }); 
>
>         var options = {
>           title: 'Overall 508 Compliance Monthly Score Trend Analysis'
>         };
>
>         var chart = new 
> google.visualization.LineChart(document.getElementById('chart_div'));
>         chart.draw(data, options);
> </script> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to