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.
colourpalette

The following reference highlights how to do it http://technet.microsoft.com/en-us/library/dd239350.aspx 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 http://msdn.microsoft.com/en-US/library/aa358802.aspx.  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

About AussieBICG

Connect with me here https://au.linkedin.com/in/aussiebicg

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s