title: Creating a Pie Chart in a Razor View in Asp.Net Core
body: <p>I've been searching the whole internet for a guide to help me get a chart working on a Razor Page View from my Asp Net Core project. The thing is, so far I've found stuff using Angular or sites offering a .js for a certain price. Until I stumbled upon a tutorial and put together a code, only to find out that </p>
  
  <blockquote>
    <p>The type or namespace Chart could not be found</p>
  </blockquote>
  
  <p>The code looks like this:</p>
  
  <pre><code>public class DashboardController : Controller
  {
      public IConfiguration Configuration { get; }
      public DashboardController(IConfiguration configuration)
      {
          Configuration = configuration;
      }
      public ActionResult Index()
      {
          string query = "SELECT Total_Releases, Completed_Releases FROM ReleaseStats":
          string constr = Configuration["ConnectionStrings:DefaultConnection"];
          List&lt;ReleaseStatistics&gt; chartData = new List&lt;ReleaseStatistics&gt;();
  
          using (SqlConnection con = new SqlConnection(constr))
          {
              using (SqlCommand cmd = new SqlCommand(query))
              {
                  cmd.CommandType = CommandType.Text;
                  cmd.Connection = con;
                  con.Open();
                  using (SqlDataReader sdr = cmd.ExecuteReader())
                  {
                      while (sdr.Read())
                      {
                          chartData.Add(new ReleaseStatistics
                          {
                              TotalReleases = Convert.ToInt32(sdr["Total_Releases"]),
                              CompletedReleases = Convert.ToInt32(sdr["Completed_Releases"])
                          });
                      }
                  }
  
                  con.Close();
              }
          }
          return View(chartData);
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>@model List&lt;Intersection.Models.Statistics.ReleaseStatistics&gt;
  @{
      Layout = null;
  }
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      @{
          var chart = new Chart(width: 500, height: 500, theme: ChartTheme.Yellow)
         .AddTitle("Releases")
         .AddSeries("Default", chartType: "Pie",
              xValue: Model, xField: "Total Releases",
              yValues: Model, yFields: "Completed Releases")
          .Write();
      }
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Therefore - What should be done so that my View will be able to see the <code>Chart()</code> method? Is there any other way that I could easily add a chart to my view? Any links to guides, tutorials, are very welcome! Although I feel that I already consumed them all.</p>