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?
This can be done using the Axis.Title
property:
chartArea.AxisX.Title = "X Axis";
chartArea.AxisY.Title = "Y Axis";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With