This blog contains tips and tricks for reporting services 2005/2008R2/2016 "This blog is provided 'AS IS' with no warranties, and confers no rights."
Monday, 25 January 2010
Custom Colours in Pie Charts
I created a number of pie charts which compared the data for a number of clients in different years. As some of the clients did not have any data in some of the years the default colours were mixed up.
To remedy this you can use the code below to specify the colours you want.
The code below is inserted in the report properties window under the code tab.
Private colorPalette As String() = { "purple","blue","darkgreen","lightgreen","pink","teal","yellow","gray","black"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
You can choose the colours you want in between the brackets the order is from let to right.
{ "purple","blue","darkgreen","lightgreen","pink","teal","yellow","gray","black"}
When you have entered the code you can use this in your pie chart.
Edit the value in the data tab of your chart properties then edit the value, appearance,series style, fill, color and then click on the expression box and enter the following expression
=Code.GetColor(Fields!.YOURFIELD.Value)
Subscribe to:
Post Comments (Atom)
Keep SSRS (SSRS2016) report manager awake
When running a report for the first time in report manager it takes a while to run, after this initial run reports run fine. There are a ...
-
Due to the fact the reporting services allows you to query the tables you can easily write SQL which will allow you to return data from the ...
-
I have recently been looking at conditional page breaks in SSRS 2008 r2 and did not know that it is possible to do via an expression. For...
-
To add alternate colors in a matrix the expression should be as follows for the row group: =IIf( RunningValue (Fields!FIELDNAME.Value, Co...
No comments:
Post a Comment