title: Creating Google Pie Chart based on JSON data using CodeIgniter
body: <p>I tried to create a pie chart based on example <a href="https://developers.google.com/chart/interactive/docs/php_example" rel="nofollow">here</a></p>
  
  <p>In my controller (mycontroller/json) i have the following code:</p>
  
  <pre><code>public function json(){
  
  $whatever = '{
  "cols": [
      {"id":"","label":"Topping","pattern":"","type":"string"},
      {"id":"","label":"Slices","pattern":"","type":"number"}
    ],
  "rows": [
      {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
      {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
      {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
      {"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
      {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
    ]
  }';
  echo $whatever;
  }
  </code></pre>
  
  <p>In my view i have the following code (partial code is shown)</p>
  
  <pre><code>var jsonData = $.ajax({
      url: "&lt;?= base_url()?&gt;index.php/bunker/json",
      dataType:"json",
      async: false
      }).responseText;
  
  // Create and populate the data table.
  var popularCategory = google.visualization.DataTable(jsonData);
  new google.visualization.PieChart(document.getElementById('category')).draw(popularCategory,
      {title:"Popularity by Category"});
  </code></pre>
  
  <p>And lastly i have a div with an id called 'category'. However, i always get a message saying data is not defined.</p>
  
  <p>A quick debug using firebug, i receive no error, the $whatever variable is also treated as a proper JSON format. What mistakes have i made here?</p>
  
  <p>cheers,</p>