在图表.net mvc3中设置间隔

dej*_*ong 4 charts asp.net-mvc-3

我想在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");
Run Code Online (Sandbox Code Playgroud)

任何帮助都会非常感激.

谢谢.

Edi*_*ang 9

你可以用"主题"字符串来完成它.我已用它测试过了.

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

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

我的测试代码:

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");
    }
}
Run Code Online (Sandbox Code Playgroud)