How to rotate data labels in the ASP.NET MVC Chart?
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.
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).
Figure 2: Chart with data labels only for the first series