[英]Pass an id value from the model into a modal form using data-url="@Url.Action"
[英]How to pass data from a model (MVC) to @url.Action() to plot a chart
我想绘制一个饼图。 图表数据位于模型/控制器中。 我有一个@Url.Action()
显示饼图。 如何在这里将图表数据从模型传递到@Url.Action()
-最终在饼图上绘制该数据?
我是MVC方法和C#的新手。 任何帮助将不胜感激。
MyHtml.cshtml
@model Project.Models.Data
<body>
<!-- Display Chart in Partial View Ctrl -->
<!-- Url.Action ( <ActionName>, <Controller Name> ) -->
<p><img src="@Url.Action("ShowChart","AssetHistory")" alt="Chart" /> </p>
</body>
Controller.cs
// Partial View for Pie Chart
public ActionResult ShowChart()
{
var ChartData = new[] { "95", "5" }; // hard coded data //
// return PartialView("Chart");
return PartialView ( "Chart", ChartData );
}
MakeChart.cshtml
@* @model Project.Models.Data *@
@model IEnumerable<string>
<!-- Model Data Inherited from Parent View ?? -->
@{
var myChart = new Chart(width: 600, height: 400)
.AddTitle("Overall Equipment Effectiveness")
.AddSeries(
chartType: "Pie",
name: "OEE",
xValue: new[] { "ON", "OFF" },
@* yValues: new[] { "25", "75" } ) *@
yValues: Model)
.Write();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.