gpt4 book ai didi

asp.net-mvc-3 - 在图表.net mvc3中设置间隔

转载 作者:行者123 更新时间:2023-12-02 09:18:18 25 4
gpt4 key购买 nike

我想在 mvc3 .net c# 中将图表上的间隔设置为 1(使用 System.Web.Helpers)。我找不到图表属性来设置间隔,以便 x/yValues 显示所有标签。代码如下:

Chart key = new Chart(width: 600, height: 400)
.AddSeries(
chartType: "bar",
legend: "Rainfall",
xValue: xVal, //new[] { "Jan", "Feb", "Mar", "Apr", "May" },
yValues: yVal
) //new[] { "20", "20", "40", "30", "10" })
.AddTitle("Chart Success Rate")
.Write("png");

任何帮助将不胜感激。

谢谢。

最佳答案

您可以使用“主题”字符串来完成此操作。我已经测试过了。

只需将 Interval=""1""添加到主题 xml 即可。

查看这篇文章:http://forums.asp.net/t/1807781.aspx/1参见6楼回复(2012年5月27日 11:23 AM)

我的测试代码:

public ActionResult GetChartCategoryCountList1()
{
string temp = @"<Chart>
<ChartAreas>
<ChartArea Name=""Default"" _Template_=""All"">
<AxisY>
<LabelStyle Font=""Verdana, 12px"" />
</AxisY>
<AxisX LineColor=""64, 64, 64, 64"" Interval=""1"">
<LabelStyle Font=""Verdana, 12px"" />
</AxisX>
</ChartArea>
</ChartAreas>
</Chart>";

using (var context = new EdiBlogEntities())
{
var catCountList = context.GetCategoryCountList().ToList();

var bytes = new Chart(width: 850, height: 400, theme: temp)
.AddSeries(
xValue: catCountList.Select(p => p.DisplayName).ToArray(),
yValues: catCountList.Select(p => p.PostCount).ToArray()
)
.GetBytes("png");

return File(bytes, "image/png");
}
}

关于asp.net-mvc-3 - 在图表.net mvc3中设置间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8703049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com