title: Using data from model in Chart.js MVC c#
body: <p>I am trying to make a Chart with Chart.js but i cant get the data from my model into the chart... can someone help me with this?</p>
  
  <pre><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"&gt;&lt;/script&gt;
  
  &lt;canvas id="myChart" width="400" height="400"&gt;&lt;/canvas&gt;
  &lt;script &gt;
  var ctx = document.getElementById('myChart').getContext('2d');
  @{ 
      List&lt;String&gt; listKeys = new List&lt;string&gt;();
      List&lt;int&gt; listValues = new List&lt;int&gt;();
      foreach(var x in Model.PageViews)
      {
          listKeys.Add(x.Key + "");
          listValues.Add(x.Value);
      }
  }
  
  var chart = new Chart(ctx, {
      type: 'line',
      data: {
          labels: @listKeys,
          datasets: [{
              label: "My First dataset",
              backgroundColor: 'rgb(255, 99, 132)',
              borderColor: 'rgb(255, 99, 132)',
              data: @listValues
          }]
      },
      options: {}
  });
  </code></pre>
  
  <p>
  I've tried multiple things but nothing seems to work...</p>