Articles in this section
Category / Section

How to rotate data labels in the JavaScript Chart?

2 mins read

Essential Chart supports rotating data labels by using the angle property of the Data Label. Data label rotation can be performed for all the series in the JavaScript Chart by using the commonSeriesOptions or for a specific series in the series collection.

The following code example illustrates the use of commonSeriesOptions to rotate Data Labels of all the series in the Chart.

JS

$("#container").ejChart({
    commonSeriesOptions: {
        marker: {
            dataLabel: {
                visible: true,
                //Rotating data label 90 degrees anti-clockwise of the Chart series. 
                angle: -90,
                offset: -40,
                verticalTextAlignment: "near",
                font: { color: "white", size: "14px" }            
           }
        }
    },
    . . . . . . . . . . . .
    . . . . . . . . . . . .
});

 

The following screenshot displays the chart with rotated data labels.

Rotated data labels in JavaScript Chart

Figure 1: Chart with rotated data labels

JS Playground sample link: Data label rotation using CommonSeriesOptions

The following code example illustrates rotating data labels of individual series in the series collection.

JS

$("#container").ejChart({
    title:{text:'Medals'},
    series: [{
        marker: {
            dataLabel: {
                visible: true,
                //Rotating data label 90 degrees anti-clockwise for the first series of the Chart.
                angle: -90,
                offset: -40,
                verticalTextAlignment: "near",
                font: { color: "white", size: "14px" }            
            }
        },
        . . . . . 
        . . . . .                    
    },
    . . . . . 
    . . . . .             
    ],
    . . . . .  
    . . . . .
});

 

The following screenshot displays the Chart with data labels only for the first series (Gold).

Rotated label for first series in JavaScript Chart

 

Figure 2: Chart with data labels only for the first series

 

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