Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Google Chart Error (null or not an object)

I am trying to create a column chart and not sure why I get the following error:
Message: 'dataValues[...].0' is null or not an object
Line: 718
Char: 3
Code: 0
URI: http://isaac.issharepoint.com/Shared%20Documents/ReportDashboard.aspx


It shows up in firefox and chrome but not IE 8
Here's a snippet of my code:

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Log",
	CAMLViewFields: "<ViewFields><FieldRef Name='AssignToAnalyst'></FieldRef><FieldRef Name='Days'></FieldRef></ViewFields>",
	//CAMLRowLimit: 0,
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() { 
		  var monthProjectedIndex = fyMonthIndex($(this).attr("ows_AssignToAnalyst"));
		  dataValues[monthProjectedIndex][1]++;
		  //alert("Days: "+valSplit($(this).attr("ows_Days")));
		  
		  if (valSplit($(this).attr("ows_Days")) > 30)
		  {
			//alert("Over 30");
			 dataValues[monthProjectedIndex][2]++;
		  }
		  
      });
     }
  });
		
		
	$.each (dataValues, function(index, value) {
	//alert("Month: "+dataValues[index][0]);
	//alert("Month: "+dataValues[index][1]);
	//alert("Month: "+dataValues[index][2]);
	
		data.addRow([dataValues[index][0], Number(dataValues[index][1]), Number(dataValues[index][2])]);
});
<!-- Customize your chart using Options -->
      var options = {
          title: 'Days',
          hAxis:  {title: 'Month', titleTextStyle: {color: 'red'}}
        };	

<!-- Instantiate the Chart class -->
      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); 	

<!-- Call chart.draw() function, passing in 'data' and 'options'	-->	
        chart.draw(data, options); 	  
}

Open in new window



Any ideas?
Avatar of Amar Bardoliwala
Amar Bardoliwala
Flag of India image

Hello TheInnovator,

I am not 100% sure but IE seems to have problem with following line

data.addRow([dataValues[index][0], Number(dataValues[index][1]), Number(dataValues[index][2])]);

Following is error

SCRIPT5007: Unable to get property '0' of undefined or null reference
File: ReportDashboard.aspx, Line: 682, Column: 3

Look at following link for error description.

http://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&
k=k(VS.WebClient.Help.SCRIPT5007)

It says following



You attempted to invoke the Object.prototype.toString or Object.prototype.valueOf method on an object of a type other than Object. The object of this type of invocation must be of type Object.
To correct this error

    Only invoke the Object.prototype.toString or Object.prototype.valueOf methods on objects of type Object.



see if this helps you.

Thank you.

Amar Bardoliwala
Avatar of Isaac

ASKER

I don't think that's the issue because when I hard coded values, my chart showed.
data.addRow(['March', 5, 23]);
ASKER CERTIFIED SOLUTION
Avatar of Amar Bardoliwala
Amar Bardoliwala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial