Define colors for a series for multiple charts

  • I've a requirement where I need to design a dashboard with 6 pie charts. Each pie chart will have drill down / drill through capabilities.

    All charts have same series meaning, Chart-1 is TotalSales vs Region, Chart-2 is Profit vs Region and so on.

    I need to have a single table displaying legends (Region in this case). I'll build expressions to have uniform color for a region across all 6 charts.

    Restriction is: I'm not supposed to create any new objects (table, stored procedure) in database. All the logic/ code is handled in report.

    Now to have color defined against each region, what options I would have?

    I had thought of Shared Dataset but Shared Dataset is not supported in SSRS 2005.

    Using a dataset within a dataset is also not feasible, as far as I've explored.

    At present, I've an option of creating a temp table to hold region & color. Then join this table with main query. But for 6 charts, I'll have to repeat it 6 times. In case I need to change color for a region, it would be prone to mistakes.

    Do I have any other options?

  • Just came to know that Lookup can be another option. It works in SSRS 2008. Not sure if it's available in 2005. Let me check.

  • There are a couple of approaches to solving this. Here's a link to an entire series devoted to custom/conditional colors in SSRS by Dave Lean:

    http://blogs.msdn.com/b/davidlean/archive/2009/02/17/sql-reporting-how-to-conditional-color-1-4-the-basics-report-expressions-custom-code.aspx

    Below is a technique mentioned in Dave's series that is quite useful:

    Basically, you create custom code to handle the region; place a function call to the custom code in the relevant field property while passing the region value to the function.

    Step 1: Paste this into the Custom Code window.

    Public Function ColorRegion(ByVal RegionName As String) As String

    Select Case RegionName

    Case"Africa"

    Return"Brown"

    Case"Americas"

    Return"Blue"

    Case"ANZ"

    Return"GoldenRod"

    Case"Asia"

    Return"Olive"

    Case"Europe"

    Return"MediumTurquoise"

    Case Else

    Return"Red"

    End Select

    End Function

    Step 2: Use it in a report Expression to assign a value to a color property.

    =code.ColorRegion(Fields!Region.Value)

    Lastly, although you are creating pie charts, you may want to reconsider or persuade the person requesting them. Pie charts are generally not an effective visualization compared to bar charts when comparing values. Stephen Few (data visualization expert) has a website (www.perceptualedge.com) that should be required reading for anyone creating charts/graphs -- really great stuff. Here's a direct link to an article he wrote explaining the limitations of pie charts: http://www.perceptualedge.com/articles/visual_business_intelligence/save_the_pies_for_dessert.pdf

  • Thanks peterzeke! Appreciate your detailed suggestions. I'll go through the links and re-analyze the requirement of pie charts.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply