set interval in chart .net mvc3

前端 未结 1 401
忘了有多久
忘了有多久 2021-01-06 09:46

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.

相关标签:
1条回答
  • 2021-01-06 10:03

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

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

    See this post: http://forums.asp.net/t/1807781.aspx/1 see the 6th floor reply (May 27, 2012 11:23 AM)

    my test 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");
        }
    }
    
    0 讨论(0)
提交回复
热议问题