Articles in this section
Category / Section

How to rotate data labels in the ASP.NET MVC Chart?

1 min 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 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.

CSHTML

@(Html.EJ().Chart("container")
    .CommonSeriesOptions(options=>
        options.Marker(marker=>
        marker.DataLabel(label=>
            label.Visible(true)
                .Offset(-40)
                .Angle(-90)
                .VerticalTextAlignment(TextAlignment.Near)
                .Font(fn => fn.Color("white").Size(“14px”)))
    )
    . . . . .
    . . . . .
)

 

The following screenshot displays the chart with rotated data labels.

The chart with rotated data labels.

Figure 1: Chart with rotated data labels

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

CSHTML

@(Html.EJ().Chart("container")
    .Series(options=>
       {
        options.Marker(marker=>
         marker.DataLabel(label=>
            label.Visible(true)
                .Offset(-40)
                .Angle(-90)
                .VerticalTextAlignment(TextAlignment.Near)
                .Font(fn => fn.Color("white").Size(“14px”)))
        ).Add();
        . . . . .
        . . . . .
       }
    )
    . . . . .
    . . . . .
)

 

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

The Chart with data labels rotated only for the first series

 

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