Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing X and Y Axis Labels?

I am using System.Web.UI.DataVisualization.Charting to create a chart, but I can't figure out how to add axis labels to it. I want to show labels like so:

              |
              |
              |
              |
 Y-Axis Label |
              |
              |
              +----------------------------
                      X-Axis Label

I've tried this, but it doesn't work when adding a new 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 to a chart's axes?

like image 447
Alexandru Avatar asked Sep 11 '14 13:09

Alexandru


1 Answers

This can be done using the Axis.Title property:

chartArea.AxisX.Title = "X Axis";
chartArea.AxisY.Title = "Y Axis";
like image 93
admdrew Avatar answered Sep 28 '22 14:09

admdrew