How to change the direction of the X-axis label in ms diagrams

Hi, I am using the Ms chart control in a winforms application to display values ​​according to dates

I need to change the direction of the label label (Dates) on the x axis, horizontal to vertical

I searched for so many properties, but I did not find a solution for this.

Help me on this issue

enter image description here

Many thanks....

+6
source share
2 answers

As I understand your question - you are asking how to rotate the chart label to display vertically.

You can rotate the X axis label as follows:

chart1.ChartAreas[0].AxisX.LabelStyle.Angle = -90; 

It is assumed that you linked your series to the first area of ​​the chart, which by default does not change when using the Winforms constructor.

The following figures show how the diagram will look before the code above is applied, the second image shows how it appears after applying the code.

Let me know if this is not what you are trying to do and I will post an updated answer.

Before the turn
Before rotation

After turning
enter image description here

Edit: another answer added after posts were mentioned in my previous posts, it may be important to set chartArea1.AxisX.IsLabelAutoFit = false;

+23
source

If you have not already done so, get sample diagrams from microsoft:
http://archive.msdn.microsoft.com/mschart

Then check the Labels section Chart Features> Labels

To answer your question directly, set the angle in LabelStyle and don't forget to turn off autorun

 chartArea1.AxisX.IsLabelAutoFit = false; chartArea1.AxisX.LabelStyle.Angle = 90; 
+15
source

Source: https://habr.com/ru/post/893013/


All Articles