Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将数据从模型(MVC)传递到@url.Action()以绘制图表_C#_Html_Razor - Fatal编程技术网

C# 如何将数据从模型(MVC)传递到@url.Action()以绘制图表

C# 如何将数据从模型(MVC)传递到@url.Action()以绘制图表,c#,html,razor,C#,Html,Razor,我想画一个饼图。图表数据位于模型/控制器中。我有一个@Url.Action()来显示饼图。如何将图表数据从模型传递到此处的@Url.Action()——最终在饼图上绘制该数据 我不熟悉MVC方法和C。任何帮助都将不胜感激 MyHtml.cshtml @model Project.Models.Data <body> <!-- Display Chart in Partial View Ctrl --> <!-- Url.Action ( <A

我想画一个饼图。图表数据位于模型/控制器中。我有一个
@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>
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();
}
@*@model Project.Models.Data*@
@模型IEnumerable
@{
var myChart=新图表(宽度:600,高度:400)
.AddTitle(“整体设备有效性”)
.AddSeries(
图表类型:“馅饼”,
名称:“OEE”,
xValue:new[]{“开”,“关”},
@*Y值:新[]{“25”,“75”})*@
Y值:模型)
.Write();
}

我已经回答了一个类似的问题。请查看以下链接:


希望这有帮助

我已经回答了一个类似的问题。请查看以下链接:


希望这有帮助

你的控制器方法是什么样子的?这取决于…什么样的数据。所有的
Url.Action
都是生成一个Url,没有什么特别神奇的事情发生。你想生成什么url?我已经编辑了我的帖子并添加了controller.cs。请查看和YB952。如果您只查找set 2值或数字或整数,则可以设置路由,以便它可以处理url中的数字或整数。我的“IdentityModels.cs”中有一个变量“public double OEE_Percent;”。我需要在饼图中绘制OEE_百分比的值。你的控制器方法是什么样的?这取决于…什么样的数据。所有的
Url.Action
都是生成一个Url,没有什么特别神奇的事情发生。你想生成什么url?我已经编辑了我的帖子并添加了controller.cs。请查看和YB952。如果您只查找set 2值或数字或整数,则可以设置路由,以便它可以处理url中的数字或整数。我的“IdentityModels.cs”中有一个变量“public double OEE_Percent;”。我需要将OEE_百分比的值绘制在饼图中。
@* @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();
}