将StripLine的偏移量显示为Y轴上的标签

时间:2013-11-28 18:17:20

标签: c# winforms charts

我在WinForms应用程序中有这个图表:

enter image description here

我需要显示红线的参考编号(在本例中为“37”)

当我尝试将CustomLabel添加到Y轴时,所有其他数字都消失了。

我尝试将标签的RowIndex更改为2,但结果如下:

enter image description here

它只显示倒“3”而不是直“37”

这就是我需要的:

enter image description here

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以使用TextAnnotation来显示数据值:

enter image description here

  ChartArea ca = chart1.ChartAreas[0];
  TextAnnotation ta = new TextAnnotation();

  DataPoint dp0 = Series2.Points[0];  // pick a datapoint!
  ta.Text = dp0.YValues[0] + "";
  ta.ForeColor = dp0.Color;

  ta.AxisY = ca.AxisY;
  ta.Y = dp0.YValues[0];
  ta.X = 5;  // pick a value that fits with your y-axis!

  ta.Alignment = ContentAlignment.MiddleLeft;
  chart1.Annotations.Add(ta);