加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 07:23:19 所属栏目:asp.Net 来源:网络整理
导读:我想在mvc3 .net c#中将我的图表上的间隔设置为1(使用System.Web.Helpers). 我无法找到图表属性来设置间隔,以便x / yValues显示所有标签. 这里的代码: Chart key = new Chart(width: 600,height: 400) .AddSeries( chartType: "bar",legend: "Rainfall",xVa
我想在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");

任何帮助都会非常感激.

谢谢.

解决方法

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

只需在主题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"" 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");
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读