2012-03-09 3 views
5

나는 Y 축에 다른 카테고리를 보여주는 막 대형 차트를 가지고 있습니다.MS Chart : 막 대형 차트의 축에있는 각 레이블의 색을 어떻게 바꿀 수 있습니까?

내가 사용하여 동시에 축에 그들 모두의 색상을 변경할 수 있습니다

chart.ChartAreas["MyChart"].AxisY.LabelStyle.ForeColor = "Red"; 

을 그것은 나를 그들 각각의 색상을 설정하는 것을 허용하지 않습니다하지만.

도움이 될 것입니다.

답변

2

가 좋아 내가 찾은 유일한 해결책은 사용자 지정 레이블을 만들고 색을 설정하는 것입니다 방법 :

this._chart.ChartAreas[0].AxisX.CustomLabels.Add(new CustomLabel(position - 1, position + 1, point.AxisLabel, 0, LabelMarkStyle.None)); 

this._chart.ChartAreas[0].AxisX.CustomLabels[position - 1].ForeColor = GetColor(point.AxisLabel); 
4

차트에 사용자 지정 레이블을 추가하면 각 요소를 개별적으로 수정할 수 있습니다.

private void AddCustomLabelAtYValue(double YValue, string Text, Color ForeColor) 
{ 
    double scale = chart.ChartAreas["MyChart"].AxisY.Maximum - 
     chart.ChartAreas["MyChart"].AxisY.Minimum; 
    double offset = scale * 0.5; 
    CustomLabel customLabel = new CustomLabel(YValue - offset, 
     YValue + offset, Text, 0, LabelMarkStyle.None); 
    customLabel.ForeColor = ForeColor; 
    chart.ChartAreas["MyChart"].AxisY.CustomLabels.Add(customLabel); 
} 
관련 문제