Tuesday, July 20, 2010

Report Server Pie Chart Label Positioning

One way to avoid pie chart label overlapping in Report Server is to not label sections of the chart that are under a certain percentage rating or a particular number amount.


To start name your chart by right clicking on the chart, click properties and enter a descriptive name. My chart is named CarriersChart.



In the Drop data fields portion of the chart, I have Total Carriers.



By right Clicking Total Carriers, going to properties, clicking on the Point Labels tab, I can put the following code in the Data Label as an expression. This code will call the GetLabel function in the Report Properties.

=Code.GetLabel(Sum(Fields!TotalCarriers.Value), Sum(Fields!TotalCarriers.Value,"CarriersChart"))





Next, click on Report, Report Properties, and then the Code tab. Use the following code to only label percentages above 5 percent.


Public Function GetLabel(ByVal CarriersChart As Double, ByVal totalcarriers As Double) As String
If CarriersChart / totalcarriers <>
Return ""
Else
Return Format(CarriersChart / totalcarriers, "P1")
End If
End Function
Note that the percentage under 5 percent is not labeled.


















































No comments:

Post a Comment