Articles in this section
Category / Section

How to rotate and position labels efficiently in Chart without overlapping?

2 mins read

 Label Rotation:               

Axis labels can be rotated by enabling LabelRotate property of chart axis and assigning an angle to LabelRotateAngle property of chart axis. 

C#

            this.chartControl1.PrimaryXAxis.LabelRotate = true;
            this.chartControl1.PrimaryXAxis.LabelRotateAngle = 270;

 Label Alignment:

 Alignment of axis labels can be customized using LabelAlignment property of chart axis. The default value of this property is Center. You can also set Near and Far as values for this property.

C#

this.ChartWebControl1.PrimaryXAxis.LabelAlignment = StringAlignment.Near;

 Rotation and Center Alignment:

Applying center alignment to axis labels will place them center to axis ticks. For example, if axis labels are rotated to 90 degrees with center alignment it appears similar to the below screenshot of labels aligned at “Center”. Appearance of labels will be good with center alignment if they are rotated to 90, 180 and 270 degrees.

C#

            //Rotating Axis labels
            this.chartControl1.PrimaryXAxis.LabelRotate = true;
            this.chartControl1.PrimaryXAxis.LabelRotateAngle = 90;
 
            //Alignment for axis labels
            this.chartControl1.PrimaryXAxis.LabelAlignment = StringAlignment.Center;
 

The following is a screenshot of a Chart with the labels in Center alignment.

 

rotate chart label

 

 

 

 Rotation and Far Alignment:

Applying Far alignment to axis labels will place them after axis ticks. For example, if axis labels are rotated to 45 degrees with Far alignment it appears similar to the following screenshot of labels aligned at Far. Appearance of labels will be good with Far alignment if they are rotated between 0 to 90 degrees and 180 to 270 degrees.

C#

            //Rotating Axis labels
            this.chartControl1.PrimaryXAxis.LabelRotate = true;
            this.chartControl1.PrimaryXAxis.LabelRotateAngle = 45;
 
            //Alignment for axis labels
            this.chartControl1.PrimaryXAxis.LabelAlignment = StringAlignment.Far;

 

The following is a screenshot of a Chart with the labels in Far alignment .

Far alignment label

  

Rotation and Near Alignment:

Applying Near alignment to axis labels will place them before axis ticks. For example, if axis labels are rotated to 135 degrees with Near alignment it appears similar to the below screenshot of labels aligned at Near. Appearance of labels will be good with near alignment if they are rotated between 90 to 180 degrees and 270 to 360 degrees.

 

[C#]
            //Rotating Axis labels
            this.chartControl1.PrimaryXAxis.LabelRotate = true;
            this.chartControl1.PrimaryXAxis.LabelRotateAngle = 135;
 
            //Alignment for axis labels
            this.chartControl1.PrimaryXAxis.LabelAlignment = StringAlignment.Near;

 

 

The following is a screenshot of a Chart with the labels in Near alignment.

Near alignment

 

 

 

 

 

 

 

 

 

 

 

 


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied