我正在使用 mvc 助手创建一个基于员工工作时间与月份总和的条形图。我正在使用下拉列表,按员工姓名过滤这些图表。但是我遇到了一个问题,当我单击下拉列表时,正确的图表会显示,但只是图像而不是页面视图。我该如何解决?请帮忙。我在控制器中的方法。
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();
}
我的观点
<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>