i am using mvc helpers to create a bar graph based on the sum of the hours an employee has worked vs the months. I am using a dropdown list, to filter these charts by the employees name. But i am having a problem, when i click on the dropdownlist the correct chart displays but just the image and not in the page view. How do i fix this? Please help. My method in the controller.
public ActionResult CharterColumn(string Status)
{
var results = (from c in db.Clockcards select c);
var groupedByMonth = results
.Where(a => a.Name == Status)
.OrderByDescending(x => x.Date)
.GroupBy(x => new {x.Date.Year, x.Date.Month}).ToList();
List<string> monthNames = groupedByMonth
.Select(a => a.FirstOrDefault().Date.ToString("MMMM"))
.ToList();
List<double> hoursPerMonth = groupedByMonth
.Select(a => a.Sum(p => p.Hours))
.ToList();
ArrayList xValue = new ArrayList(monthNames);
ArrayList yValue = new ArrayList(hoursPerMonth);
new Chart(width: 800, height: 400, theme: ChartTheme.Blue)
.AddTitle("Chart")
.AddSeries("Default", chartType: "Column", xValue: xValue, yValues: yValue)
.Write("bmp");
return null;
}
public ActionResult Index()
{
ViewBag.Status = (from r in db.Clockcards
select r.Name).Distinct();
return View();
}
My view
<p>
@using (Html.BeginForm("CharterColumn", "Chart", FormMethod.Get))
{
<b>Search by Full Name:</b><font color="black">@Html.DropDownList("Status", new SelectList(ViewBag.Status), new { onchange = "this.form.submit()" })</font>
}
</p>