Q:

The name 'data' does not exist in the current context?

Im trying to display a sample chart with some sample data, just followed one link from satckoverflow, tried that code in my application but getting the error as 'the name data does note exist in the current context'. 
   public ActionResult Chart()
   {

   Chart chart = new Chart();
   chart.ChartAreas.Add(new ChartArea());

   chart.Series.Add(new Series("Data"));
   chart.Series["Data"].ChartType = SeriesChartType.Pie;
   chart.Series["Data"]["PieLabelStyle"] = "Outside"; 
   chart.Series["Data"]["PieLineColor"] = "Black";
   chart.Series["Data"].Points.DataBindXY(
   data.Select(data => data.Name.ToString()).ToArray(), 
   data.Select(data => data.Count).ToArray());
//Other chart formatting and data source omitted.

   MemoryStream ms = new MemoryStream();
   chart.SaveImage(ms, ChartImageFormat.Png);
   return File(ms.ToArray(), "image/png");
  }

  The view is
  <img alt="" src="@Url.Action("Chart")" />

A:

The "data" reference following all the "chart.Series["Data"]" references is not initialized to anything, and does not map to any classes in referenced namespaces, so .NET is just saying it doesn't know how to resolve it. A missing using statement or object declaration/instantiation is typically to blame. Good luck.

