c#改变坐标轴的标注。

来源:互联网 发布:业界良心音乐软件 编辑:程序博客网 时间:2024/05/22 16:48
I have a chart it looks like this 
http://imgur.com/XoeCnvO

I want to change Y axis numbering and label it 1% 10% 33.% etc as shown below without changing the plot.
How do I change it


Required output graph:

http://imgur.com/fJ6bQzk


1
Vulpes

Vulpes

  • 2
  • 96.8k
  • 1m
Apr 11 2014 8:49 AM
Try something like this:

CustomLabel label1 = new CustomLabel
{
   FromPosition = -3.5,
   ToPosition = -2.5,
   Text = "1%"
};

CustomLabel label2 = new CustomLabel
{
   FromPosition = -2.5,
   ToPosition = -1.5,
   Text = "10%"
};

CustomLabel label3 = new CustomLabel
{
   FromPosition = -1.5,
   ToPosition = -0.5,
   Text = "33.3%"
};

CustomLabel label4 = new CustomLabel
{
   FromPosition = -0.5,
   ToPosition = 0.5,
   Text = "50%"
};

CustomLabel label5 = new CustomLabel
{
   FromPosition = 0.5,
   ToPosition = 1.5,
   Text = "66.7%"
};

CustomLabel label6 = new CustomLabel
{
   FromPosition = 1.5,
   ToPosition = 2.5,
   Text = "90%"
};

CustomLabel label7 = new CustomLabel
{
   FromPosition = 2.5,
   ToPosition = 3.5,
   Text = "99%"
};

chart1.ChartAreas[0].AxisY.CustomLabels.Add(label1);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label2);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label3);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label4);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label5);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label6);
chart1.ChartAreas[0].AxisY.CustomLabels.Add(label7);
0 0
原创粉丝点击