myChartControl.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
I have encountered this problem before and got around it by setting the RotationAngle in the ASPX code. In this case however, this is not possible.
6 Answers, 1 is accepted
The problem you describe is one we're familiar with. Due to the nature of the ASP.NET framework, when you create a control from code-behind, you have to make sure that you add it to the Page.Controls collection immediately after instantiating it. The ASP.NET framework applies a viewstate to a control the moment it's added to Page.Controls and any changes to a control's state made between creating and adding it will be lost, if there's an existing viewstate for it in the web application. Therefore, I'd like to ask you to first check whether you add the RadChart before setting the RotationAngle property and if not whether doing so will solve the problem.
Kind regards,
Ivan N.
the Telerik team

The chart is being output onto a PDF. It is created as follows:
myChartControl = new RadChart();
...
myChartControl.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
...
System.Drawing.Image myChart = myChartControl.GetBitmap();
MemoryStream imageStream = new MemoryStream();
myChart.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageContent = new Byte[imageStream.Length];
imageStream.Position = 0;
imageStream.Read(imageContent, 0, (int)imageStream.Length);
Response.ContentType = "image/png";
Response.BinaryWrite(imageContent);
Thanks,
Louise
Thank you for clarifying the situation. While I was able to achieve a scenario similar to yours based on the code from your last post, I couldn't reproduce the issue. I've attached the project I was working on while trying to do so, as well as the image returned after running it.
Greetings,
Ivan N.
the Telerik team

I've reattached the project in a zip archive, as you requested.
Kind regards,
Ivan N.
the Telerik team

Thanks for the example project. The difference was in the syntax:
My code:
myChartControl.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
Your code:
myChartControl.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 45;
Your code works, the method called in mine does not seem to do anything.
One additional problem. Now that the labels rotate they do not display in full on the chart (I'm displaying dates so they are quite long). Is there a setting to change the amount of space below the chart so that the labels appear in full?
This can be demonstrated in your code by changing the following:
new ChartData { XCat = DateTime.Now.ToShortDateString(), YVal = 5 },
new ChartData { XCat = DateTime.Now.AddDays(1).ToShortDateString(), YVal = 7 },
new ChartData { XCat = DateTime.Now.AddDays(2).ToShortDateString(), YVal = 4 },
new ChartData { XCat = DateTime.Now.AddDays(3).ToShortDateString(), YVal = 3 },
new ChartData { XCat = DateTime.Now.AddDays(4).ToShortDateString(), YVal = 8 },
Thanks, Louise