How to give custom labels to x axis of chart control?

来源:互联网 发布:上市公司高管薪酬数据 编辑:程序博客网 时间:2024/05/21 14:58

I am creating a windows project in which there is a requirement to plot a graph, for that i am using chart control.

The X-Axis of chart control has label from 0 to 100 with following code.



down voteaccepted

Following is the solution of my question.

string[] monthNames = { "100", "75" , "50" , "25" ,"0"};int startOffset = -2;int endOffset = 2;foreach (string monthName in monthNames){ CustomLabel monthLabel = new CustomLabel(startOffset, endOffset, monthName, 0, LabelMarkStyle.None);                         chart1.ChartAreas[0].AxisX.CustomLabels.Add(monthLabel); startOffset = startOffset + 25; endOffset = endOffset + 25;}

down voteaccepted

Following is the solution of my question.

string[] monthNames = { "100", "75" , "50" , "25" ,"0"};int startOffset = -2;int endOffset = 2;foreach (string monthName in monthNames){ CustomLabel monthLabel = new CustomLabel(startOffset, endOffset, monthName, 0, LabelMarkStyle.None);                         chart1.ChartAreas[0].AxisX.CustomLabels.Add(monthLabel); startOffset = startOffset + 25; endOffset = endOffset + 25;}
0 0