Martina Genovese

Martina Genovese

  • NA
  • 26
  • 1.2k

Additional text on XY-Axis [DataVisualization.Charting]

Apr 3 2020 10:57 AM
In C# I am using the DataVisualization.Charting library to plot. I would like to show some additional text on the two axis of a chart in relation to the two red lines (they are a VerticalLineAnnotation and a HorizontalLineAnnotation), like show in the image below.
 
 
I tried something like this:
  • Custom labels, but it removes completely the axis interval:
Chart1.ChartAreas[0].AxisX.CustomLabels.Add(8000, 9000, "X - Red");
  • Text annotation anchored to a DataPoint, but the text stay inside the chart:
textAnnotation.SetAnchor(series.Points.ElementAt(0));
  • Axis label, but it doesn't work:
series.Points.ElementAt(0).AxisLabel = "Red";
  • AxisX2 and AxisY2, it works but the text is in the opposite axis
Chart1.ChartAreas[0].AxisX2.CustomLabels.Add(8000, 9000, "X - Red");
 
I can't get the desired result, how can I do it?