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";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.