简体   繁体   中英

Show offset of StripLine as a label on the Y-Axis

I have this chart in my WinForms application:

在此处输入图片说明

and I need to show the reference number of the red line (in this case "37")

When I tried to add a CustomLabel to the Y Axis, all the other numbers disappeared.

I tried changing the RowIndex of the label to 2, but here's the result:

在此处输入图片说明

it only shows an inverted "3" instead of a straight "37"

Here's what I need:

在此处输入图片说明

how can I do this?

You can use a TextAnnotation to show a data value :

在此处输入图片说明

  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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM