Reputation: 1416
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?
Upvotes: 0
Views: 2171
Reputation: 54433
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);
Upvotes: 1