I am often frustrated with SSRS's legend layout. My legend items are often wrapped or too small and my chart of graph is squeezed to make everything fit properly. The other problem is the legend item does not allow the users to click on the items to drill through to the details.
An easy solution is to make a separate legend as a tablix outside the graph which can be hidden. This gives you the added ability to create drill through links and allow the users to easily see the totals.
Below I give you two examples. 1) Using standard colors where you don't care what color the items are. 2) The color needs to reflect the data (ie Red, Yellow, Green .... Bad, Warning, Good).
1. Open the report
2. Click REPORTS under the main menu >> REPORT PROPERTIES
3. Click CODE
4. INSIDE THE CODE BOX TYPE / COPY one of the following (standard or custom)
[STANDARD COLORS]
Private colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua", "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6", "#E16C56", "#CFBA9B"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function FillColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim myColor As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, myColor)
Return myColor
End Function
[CUSTOM COLORS] Public Function FillSpecificColor(ByVal ProblemCode As Integer)
Dim ReturnColor As String = "Violet"
Select Case ProblemCode
Case 300
ReturnColor = "DarkGreen"
Case 1
ReturnColor = "Red"
Case 2
ReturnColor = "#C60000" ' Dark Red
Case 3
ReturnColor = "#FF3E3E" ' Light Red
Case 4
ReturnColor = "#930000" ' Darker Red
Case 5
ReturnColor = "#FF8484" ' Lighter Red
Case 6
ReturnColor = "#FFD5D5" ' Pink
Case 7
ReturnColor = "#3E0000" ' Brown
'---------------------------------------
Case 100
ReturnColor = "Yellow"
Case 101
ReturnColor = "#D5D500" ' Dark Red
Case 102
ReturnColor = "#FFFF48" ' Light Red
Case 103
ReturnColor = "#C6C600" ' Darker Red
Case 104
ReturnColor = "#FFFF77" ' Lighter Red
Case 105
ReturnColor = "#A8A800" ' Brown yellow
Case 106
ReturnColor = "#FFFFB9" ' Beige
'---------------------------------------
Case 200
ReturnColor = "#009100" ' Shade lighter than Dark Green (300)
Case 201
ReturnColor = "#00BB00" ' Shade lighter than above
Case 202
ReturnColor = "#00DF00" ' Shade lighter than above
Case 203
ReturnColor = "#17FF17" ' Shade lighter than above
Case 204
ReturnColor = "#48FF48" ' Shade lighter than above
Case 205
ReturnColor = "#AAFFAA" ' Shade lighter than above
Case 206
ReturnColor = "#D9FFD9" ' Shade lighter than above
End Select
Return ReturnColor
End Function
5. Now create a table on the page and add the field you used for the chart grouping as in the second column of the details row.
6. Now in the properties of the ROW GROUPINGS you just created ADD a grouping as that field
7. Now in the first column second row (where your color will go) >> Text Box Properties >> FILL
8. Fill Color Table >> Fx
a. STANDARD
i. Fill Color =Code.FillColor(Fields!Problem.Value) where problem is your grouped field
b. CUSTOM
i. Fill Color =Code.FillSpecificColor(Fields!ORDER.Value) where ORDER also serves as a color coder (ie 1 = RED 300 = Dark Green)
9. Right + Click your chart >> SERIES PROPERTIES >> FILL COLOR
10. Fill Color Table
a. STANDARD
i. Again =Code.FillColor(Fields!Problem.Value)
b. CUSTOM
i. Again =Code.FillColor(Fields!ORDER.Value)
11. Create a merged cell for the header and add your chart title
12. Now delete your title and legend and drag your new legend as close to the chart as possible.
OPTIONAL: Add a calculated column for the totals and percentages.
OPTIONAL: Use the legend title as toggle button to hide / show the legend saving space.
OPTIONAL: Split the table using two Tablix and a filter to put half the legend items on the left and half on the right.