Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle charts error:Cannot read property 'length' of undefined; Debugging error in Google Charts
    primarykey
    data
    text
    <p>The following code works fine as a independant page as itself. But if incorporated into my PHP web app, it throws error. How to debug if the error happens in the google chart JS? Any suggestions will be helpful</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt; &lt;title&gt; Google Visualization API Sample &lt;/title&gt; &lt;/head&gt; &lt;body style="font-family: Arial;border: 0 none;"&gt; &lt;div id="myGraphLabel" onclick="drawColumnChart();"&gt; My Column Chart &lt;/div&gt; &lt;div id="myColumnChart" style="width: 600px; height: 400px;"&gt;&lt;/div&gt; &lt;/body&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; google.load('visualization', '1', {packages: ['corechart']}); function drawColumnChart() { // Create and populate the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Task'); data.addColumn('number', 'Hours per Day'); data.addRows(2); data.setValue(0, 0, 'Work'); data.setValue(0, 1, 11); data.setValue(1, 0, 'Eat'); data.setValue(1, 1, 2); // Create and draw the visualization. new google.visualization.PieChart(document.getElementById('myColumnChart')). draw(data, {title:"So, how was your day?"}); } &lt;/script&gt; &lt;/html&gt; </code></pre> <p><strong>Error in Chrome:</strong> It displays "Cannot read property 'length' of undefined", With a red background in the container</p> <p><strong>Error in Firefox:</strong> Throws error in Firebug console as: b[c] is undefined <a href="http://www.google.com/uds/api/visualization/1.0/97e6275dc5c50efe5944ddda289e59d2/format+en,default,corechart.I.js" rel="nofollow noreferrer">http://www.google.com/uds/api/visualization/1.0/97e6275dc5c50efe5944ddda289e59d2/format+en,default,corechart.I.js</a> Line 785</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload