title: how to use google chart using dynamic data from json
body: <p>iam using mvc, i want to connect my data to google pie chart. so i used json to get list of names and their count using the following code</p>
  
  <pre><code>public JsonResult list()
          {
       var result= list.GroupBy(i =&gt; i.Name).Select(i =&gt; new { word = i.Key, count = i.Count() 
  return Json(result.ToList(), JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>Using the google chart API  </p>
  
  <pre><code> google.load("visualization", "1", { packages: ["corechart"] });
      google.setOnLoadCallback(drawChart);
      function drawChart() {
  
          var jsonData = $.ajax({
              url: "list",
              dataType: "json",
              async: false
          }).responseText;
          var data = google.visualization.DataTable(jsonData);
  
          var options = {
              title: 'Certificate details',
              is3D: true,
          };    
          var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
          chart.draw(data, options);
      }
  </code></pre>
  
  <p>i want to know how to get list of key value pairs of my data into pie chart.
  i have googled for long time, everybody is giving code example with php.
  Thankyou.</p>