在部分VIew中显示布局中的图表不起作用?

时间:2012-05-18 10:39:50

标签: c# asp.net-mvc asp.net-mvc-3 partial-views

我正在尝试在布局上显示图表。该图表位于部分视图内。但我得到这个错误:::

  

执行子请求失败。请检查一下   InnerException获取更多信息

     

找不到或未实现路径'/'的控制器   一个IController。

新错误:{“执行处理程序'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错。”}

这是我的OfficeStatisticNKIcontroller:Controller

public ActionResult Partialchart()
        {
            OfficeStatisticQueryViewModel model = new OfficeStatisticQueryViewModel();
            model.StartDate = DateTime.Now.ToShortDateString();
            model.EndDate = DateTime.Now.ToShortDateString();
            int allcompletedNKI = OfficeStatisticRepository.AllCompletedGoalCards();
            model.AllCompletedNKI = allcompletedNKI;
            var averageGrades = OfficeStatisticRepository.GetAverageGradeForAllCoreValues2();
            if (averageGrades.Count != 0)
            {
                var dataItems = (averageGrades.Select(averageGrade => averageGrade.AverageGrade).ToArray());
                Data data = new Data(
                    dataItems.Select(y => new Point { Color = GetBarColour(y), Y = y }).ToArray());

                Highcharts chart1 = new Highcharts("Chart")
                .SetXAxis(new XAxis { Categories = averageGrades.Select(averageGrade => averageGrade.CoreValue.Name).ToArray() })
                .SetYAxis(new YAxis { Min = 0, Max = 10, TickInterval = 1, Title = new YAxisTitle { Text = "Betygskalan" } })
                .SetSeries(new Series { Data = data, Name = "Snittbetyg" })
                .SetLegend(new Legend { Enabled = false })
                .SetTitle(new Title { Text = "statistic" })
                .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column });

                model.Chart = chart1;
                model.message = " ";
                return PartialView(model);
            }
            else
            {
                model.message = "error";
                return PartialView(model);
            }

        }

这是我布局中的代码:

@Html.Action("Partialchart","OfficeStatisticNKI");

我想做的就是显示这张图表我做错了什么?

提前致谢

1 个答案:

答案 0 :(得分:0)

您在此处显示的操作方法是否确定它包含在 OfficeStatisticNKI 控制器中?您的控制器是否继承自控制器类?