简体   繁体   English

在PartialVIew中显示图表时布局不起作用?

[英]Display a chart in PartialVIew on layout not working?

I am trying to display a chart on my layout. 我正在尝试在布局上显示图表。 The chart is inside a partialview. 图表位于局部视图中。 But I get this error::: 但是我得到这个错误:::

Execution of the child request failed. 子请求的执行失败。 Please examine the InnerException for more information 请检查InnerException以获取更多信息

The controller for path '/' was not found or does not implement IController. 找不到路径“ /”的控制器或未实现IController。

new error: {"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."} 新错误:{“执行处理程序'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'的子请求出错。”}

This is my OfficeStatisticNKIcontroller : Controller 这是我的OfficeStatisticNKIcontroller:控制器

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);
            }

        }

and this is my code in my layout: 这是我在布局中的代码:

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

All I want to do is to display this chart what am I doing wrong? 我要做的就是显示此图表,这是我做错了什么?

Thanks in advance 提前致谢

The action method you've displayed here are you sure it is contained within the OfficeStatisticNKI controller? 您在此处显示的操作方法是否确定包含在OfficeStatisticNKI控制器中? Does your controller inherit from the Controller class? 您的控制器是否继承自Controller类?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM