title: Javascript error TypeError: Cannot read property '0' of undefined
body: <p>I'm trying to draw a chart using the Google Visualization API, by deferring the load of the api only to when I'm using the visualizations is being needed.</p>
  
  <p>The Deferring is working properly and the callback is also working properly, but I'm not being able to get the Data parameters into it the following error appears.</p>
  
  <p><a href="https://i.stack.imgur.com/Ik3xk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ik3xk.png" alt="enter image description here"></a> </p>
  
  <pre><code>    addGoogleChartScript: function () {
        var script = document.createElement("script");
        script.src = "http://www.google.com/jsapi?callback=superlist.loadGoogleChart";
        script.type = "text/javascript";
  
        document.getElementsByTagName("head")[0].appendChild(script);
      },
  
     loadGoogleChart: function () {
      google.load("visualization", "1", {"callback" : superlist.waitForGVisAndLoad, 'packages':['corechart']});
     },
  
     waitForGVisAndLoad: function (fn, params) {
      try {
          var data = params[0];
          var text = 'Waiting for Google API to display chart...';
          var h1 = $s('#suplist_item_' + data.id + ' h1');
          if (google &amp;&amp; google.visualization &amp;&amp; typeof google.visualization.arrayToDataTable == 'function') {
              if (h1.innerHTML == text) h1.innerHTML = h1.getAttribute('prev');
              fn.apply(null, params);
          }
          else {
              if (h1.innerHTML != text) {
                  h1.setAttribute('prev', h1.innerHTML.toString());
                  h1.innerHTML = text;
              }
              setTimeout(superlist.waitForGVisAndLoad.bind(null, fn, params), 500);
          }
      }
      catch (e) {
          console.error(e)
      }
    },
  </code></pre>