2010-03-11 2 views
6

아래 차트를 참조하십시오. 프로그래밍 방식으로 차트를 작성하므로 아무런 asp.net 컨트롤 구문도 사용하지 마십시오.Microsoft 차트 컨트롤 (세로 막 대형 차트)에서 축 구분선 색을 변경하는 방법

bar chart example

는 어떻게 감옥에 수평 및 수직으로 교차 그리드 선 색상을 변경합니까? 보시다시피 실제 축 색상을 변경하는 방법을 알아 냈지만 그리드 색상은 검정색으로 유지됩니다.

public ActionResult RenderChart() 
{ 
    var chart = new Chart(); 
    double[] yValues = { 65.62, 75.54, 60.45, 55.73, 70.42 }; 
    string[] xValues = { "Michelle", "Sarah", "Aliece", "Belinda", "Amanda" }; 
    var series = new Series 
    { 
     Name = "Default", 
     ChartType = SeriesChartType.Column, 
     CustomProperties = "DrawingStyle=Cylinder" 
    }; 
    series.Points.DataBindXY(xValues, yValues); 

    chart.BorderlineColor = Color.Silver; 
    var area = new ChartArea("Test"); 
    area.AxisX.LineColor = Color.DarkGray; 
    area.AxisY.LineColor = Color.DarkGray; 

    chart.ChartAreas.Add(area); 
    chart.Series.Add(series); 
    series.IsValueShownAsLabel = true; 

    series.Font = new Font(series.Font, FontStyle.Bold); 
    chart.Width = 400; 
    chart.Height = 300; 

    using(var ms = new MemoryStream()) 
    { 
     chart.SaveImage(ms, ChartImageFormat.Png); 
     Response.ContentType = "image/png"; 
     Response.BinaryWrite(ms.ToArray()); 
     return new EmptyResult(); 
    } 
} 

답변

15

결코 마음이 대답 발견

area.Axes[n].MajorGrid.LineColor = Color.Whatever; 
3

또한 MS 차트이

<asp:Chart ID="chartOutstandingOrders" runat="server" Width="500" Palette="Bright"> 

      <Series> 
       <asp:Series ChartType="Line" Name="seriesBackorder"> 
       </asp:Series> 
      </Series> 

      <ChartAreas> 
       <asp:ChartArea Name="ChartArea1" BorderColor="#339966"> 
        <AxisX LineColor="Gray"> 
         <MajorGrid LineColor="LightGray" /> 
        </AxisX> 
        <AxisY LineColor="Gray"> 
         <MajorGrid LineColor="LightGray" /> 
        </AxisY> 
       </asp:ChartArea> 
      </ChartAreas> 

     </asp:Chart> 
0

처럼 HTML에 그것을 할 수 있습니다, 배경 눈금의 색상에 따라 변경 될 수 있습니다 성명서.

myChart.ChartAreas["xSeries"].AxisX.MajorGrid.LineColor = Color.Blue; 
관련 문제