Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.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
Asp.net mvc 如何在mvc中使用图表控件_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 如何在mvc中使用图表控件

Asp.net mvc 如何在mvc中使用图表控件,asp.net-mvc,Asp.net Mvc,我想在MVC仪表板表单中使用图表 我使用了以下代码 @{ var key = new Chart(width: 300, height: 300) .AddTitle("Employee Chart") .AddSeries( chartType: "Bubble", name: "Employee", xValue: new[] { "Peter", "A

我想在MVC仪表板表单中使用图表

我使用了以下代码

@{
        var key = new Chart(width: 300, height: 300)
          .AddTitle("Employee Chart")
          .AddSeries(
              chartType: "Bubble",
              name: "Employee",
              xValue: new[] { "Peter", "Andrew", "Julie", "Dave" },
              yValues: new[] { "2", "7", "5", "3" });     
    }
    <!DOCTYPE html>
    <html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <div> 
            <div>
                @key.Write()
            </div>
        </div>
    </body>
    </html>
@{
var键=新图表(宽度:300,高度:300)
.AddTitle(“员工图表”)
.AddSeries(
图表类型:“气泡”,
姓名:“员工”,
xValue:new[]{“彼得”、“安德鲁”、“朱莉”、“戴夫”},
Y值:新[]{“2”、“7”、“5”、“3”});
}
试验
@key.Write()
但是
@key.Write()
在整个页面中写入图表,但我希望它是部分形式的,而不是在仪表板页面中包含其他内容的完整形式。
有人能帮我吗。

将图表代码移动到控制器操作,如下所示:

    public ActionResult GetChartImage()
    {
        var key = new Chart(width: 300, height: 300)
            .AddTitle("Employee Chart")
            .AddSeries(
            chartType: "Bubble",
            name: "Employee",
            xValue: new[] { "Peter", "Andrew", "Julie", "Dave" },
            yValues: new[] { "2", "7", "5", "3" });

        return File(key.ToWebImage().GetBytes(), "image/jpeg");
    }
(包括使用System.Web.Helpers命名空间)并修改视图:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>
    <div> 
        <div>
            <img src="@Url.Action("GetChartImage")" />
        </div>
    </div>
</body>
</html>

试验

如何在此图表中设置Y轴间隔值?您不能这样做,至少不太容易。您可能有一些运气设置主题,但考虑使用一些更好的图表库,图表类简单但非常有限。