Displaying X and Y axis labels?

I am using System.Web.UI.DataVisualization.Charting to create a chart, but I cannot figure out how to add axis labels to it. I want to show shortcuts like this:

 Y-Axis Label |
                      X-Axis Label


I tried this, but it doesn't work when adding a new one ChartArea


ChartArea chartArea = new ChartArea();
chartArea.AxisX.Name = "X Axis";
chartArea.AxisY.Name = "Y Axis";
chartArea.AxisX.Enabled = AxisEnabled.True;
chartArea.AxisX.LabelStyle.Enabled = true;
chartArea.AxisY.Enabled = AxisEnabled.True;
chartArea.AxisY.LabelStyle.Enabled = true;


So how can I add and show labels on the chart axis?


source to share

1 answer

This can be done using the property Axis.Title


chartArea.AxisX.Title = "X Axis";
chartArea.AxisY.Title = "Y Axis";




All Articles