Nicole
Nicole

Reputation: 1416

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

I have this chart in my WinForms application:

enter image description here

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:

enter image description here

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

Here's what I need:

enter image description here

how can I do this?

Upvotes: 0

Views: 2171

Answers (1)

TaW
TaW

Reputation: 54433

You can use a TextAnnotation to show a data value :

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

Upvotes: 1

Related Questions