在图表.NET MVC3设定的时间间隔 [英] set interval in chart .net mvc3
本文介绍了在图表.NET MVC3设定的时间间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要在图表上(使用System.Web.Helpers)在MVC3 .NET C#中设置的时间间隔为1。
我找不到图表属性来设置时间间隔,使得X / yValues显示所有的标签。
在这里,code:
I want to set interval to 1 on my chart (using System.Web.Helpers) in mvc3 .net c#. i cant find chart property to set the interval so that the x/yValues show all the labels. Here the code:
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");
任何帮助将是非常美联社preciate。
Any help would be much appreciate.
感谢。
推荐答案
您可以使用主题字符串做到这一点。我已经测试OK吧。
You can do it with "theme" string. I have tested OK with it.
只需添加一个时间间隔=1的主题XML。
Just add a Interval=""1"" to the theme xml.
请参阅这篇文章: http://forums.asp.net/t/1807781.aspx/1看到6楼的回复(2012年5月27日上午11:23)
See this post: http://forums.asp.net/t/1807781.aspx/1 see the 6th floor reply (May 27, 2012 11:23 AM)
我的测试code:
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");
}
}
这篇关于在图表.NET MVC3设定的时间间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文