I have a simple chart, and I'd like the labels on the x-axis to be rotated 45 degrees. What am I doing wrong?
Chart c = new Chart(); c.ChartAreas.Add(new ChartArea()); c.Width = 200; c.Height = 200; Series mySeries = new Series(); mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 }); mySeries.LabelAngle = 45; // why doesn't this work? c.Series.Add(mySeries);
The output is:
I'm using the charting stuff from System.Web.UI.DataVisualization.Charting.
The documentation says that Series.LabelAngle sets data point label angle, which (I think) is a label above the chart's column.
To set an angle of axis labels try this one:
var c = Chart1; c.ChartAreas.Add(new ChartArea()); c.Width = 200; c.Height = 200; Series mySeries = new Series(); mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 }); //mySeries.LabelAngle = -45; // why doesn't this work? c.Series.Add(mySeries); c.ChartAreas[0].AxisX.LabelStyle.Angle = 45; // this works
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