2012-01-02 4 views
4

mvc3 .net C#의 내 차트 (System.Web.Helpers 사용)에서 간격을 1로 설정하고 싶습니다. x/yValues가 모든 레이블을 표시하도록 간격을 설정하는 차트 속성을 찾을 수 없습니다. 다음 코드 :차트의 간격 설정 .net mvc3

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

어떤 도움을 많이 감사 할 것이다.

감사합니다.

답변

8

"테마"문자열로 지정할 수 있습니다. 나는 그것으로 OK를 테스트했다.

테마 xml에 간격 = ""1 ""을 추가하십시오. http://forums.asp.net/t/1807781.aspx/1 (2012년 5월 27일 11:23 AM)을 6 층 응답을 참조

내 테스트 코드 :

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

이 게시물을 참조