looking for a brokerage account or IRA... click here Add To Favorites
return to index 

SQL Server Reporting Services- Custom Chart Colors

Add the following code at the bottom of your report XML


<Code>    
	Private colorPalette As String() = {"#4169e1","#2f4f4f","#ffa500","#a52a2a","#dda0dd","#b3ee3a"}
    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
</Code>
 

Add the following to the ChartSeries style attributes. Set the value to be that of the legend elements.

<Style> <BorderColor> <Default>=Code.GetColor(Fields!Period.Value)</Default> </BorderColor> </Style>

Additional Interesting Articles

t-SQL Cursor
SQL Server Database Recovery Mode
SQL Difference Between IS NULL and =NULL
VB.net Regex Example In SSIS
C# MailMessage Example
PHP Cookie And Authentication

©2008 AndrewKimball.com