SSRS : Use the same colour Palette in different charts in the same report

In the following example you have two pie charts – each chart is set to default colours – you want to make sure that the charts are coordinated, meaning they use the same fill colour for each category – so the blue always aligns with Category 1, the green always aligns with Category 2 and so on.

The following reference highlights how to do it however some additional tips.

Use the sample code below (adapted from the above technet article) but substitute your colours with either the colour name or the hex colour with the # e.g. CadetBlue or #5F9EA0.  You can use the following colour reference for help choosing  Make sure you choose enough colours to cater for the maximum number of categories in your dataset.

Once you have created code within your Report properties Code module, you just need to call the code….right click on your pie chart, select Series properties and under fill, set your expression under the Color property. Make sure your expression refers to the field value e.g. =Code.GetColor(Fields!YourCategoryField.Value)

Private colorPalette As String() = {"#5F9EA0", "Gold", "Gray"}
    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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s