title: Passing SQL results from controller to chart.js
body: <p><strong>Situation</strong>
  I would like to pass the count of X from my SQL database from my controller to my view where a chart picks up this data and renders it.</p>
  
  <p><strong>What I have done so far</strong></p>
  
  <p>So far I have the controller code. which gets the count from the table and I am trying to pass this figure back to the chart. </p>
  
  <pre><code>public ActionResult currentPopulation()
  {            
      var dests = db.personal_info.Count();
     // return Json(dests, JsonRequestBehavior.AllowGet);
      return Content(JsonConvert.SerializeObject(dests), "application/json");
  }
  </code></pre>
  
  <p>I also have the chart (code below) from the view </p>
  
  <pre><code>&lt;script&gt;
  
          var barChartData = {
                      url: '/Home/currentPopulation',//Local
                    type: "GET",
                   dataType: "JSON",
  
              labels: ["A", "B", "C"],
              datasets: [
  
              {
               //   url: '/Home/currentPopulation',//Local
                 //  type: "GET",
                 //  dataType: "JSON",
  
                  fillColor: "#26B99A", //rgba(220,220,220,0.5)
                  strokeColor: "#26B99A", //rgba(220,220,220,0.8)
                  highlightFill: "#36CAAB", //rgba(220,220,220,0.75)
                  highlightStroke: "#36CAAB", //rgba(220,220,220,1)
                  data: [51, 30, 40], //this is the hard coded values which the chart loads 
                                      //
              },
  
              ],
          }
  
  
          $(document).ready(function () {
  
    //  new Chart($("#canvas_bar").get(0).getContext("2d")).Bar()
  
  new Chart($("#canvas_bar").get(0).getContext("2d")).Bar(barChartData, {
  tooltipFillColor: "rgba(51, 51, 51, 0.55)",
  responsive: true,
  barDatasetSpacing: 6,
  barValueSpacing: 5
  });
  
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>The problem I have is that, I cannot replace the [51,30,40] for the A,B,C values 
  which is supposed to come from my controller. I am a bit confused as my action "currentPopulation" is not getting called, and i cannot move the link cause according to the code, the data is picked up from barChartData and assign when the new chart is called.</p>
  
  <pre><code>new Chart($("#canvas_bar").get(0).getContext("2d")).Bar(barChartData, {
  </code></pre>
  
  <p>Any help would be appreciated.</p>