在图表 .net mvc3 中设置间隔 [英] set interval in chart .net mvc3

查看:20
本文介绍了在图表 .net mvc3 中设置间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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");

任何帮助将不胜感激.

谢谢.

推荐答案

您可以使用主题"字符串来完成.我已经测试过了.

You can do it with "theme" string. I have tested OK with it.

只需在主题 xml 中添加一个 Interval=""1"".

Just add a Interval=""1"" to the theme xml.

请参阅此帖子:http://forums.asp.net/t/1807781.aspx/1见6楼回复(2012年5月27日11:23 AM)

See this post: http://forums.asp.net/t/1807781.aspx/1 see the 6th floor reply (May 27, 2012 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");
    }
}

这篇关于在图表 .net mvc3 中设置间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆