Programming Report Chart colors in RS (Reporting Services)

  • Seems like pretty general problem-have report with pie chart that uses predefined color palette but would like instead control used colors, e.g. for Product1 - always Red, for Product2- Blue, etc.

    Certainly I can create product_color_map but how to force RS to use these colors (from map)- no clue. I know that it’s possible to accomplish using Dundas Chart, but without …

    Really appreciate any tips. Thanks,

  • I believe you can "hard code" this in the Chart Properties.

    Select the Chart...

    1. Chart Properties

    2. Data TAB

    3. Select each data value

    4. Edit

    5. Appearance TAB

    6. Series Style (button)

    7. Fill TAB

    8. choose the color

    The CHART in the designer will not display your custom colors, but it should when you preview the report.

    Not sure that was what you are looking for...

  • Thanks Nick for your answer.

    Actually this is pretty close to what I am looking for but not sure I can do this "hard code". Let's assume I have 30 products, i.e. created map table (product-color) with 30 records. How these (my) colors will coexist with selected Palette colors (and probably I have no idea about colors in Palette collections)?

    Anyhow, thanks, I need to try.

  • Hi guys,

    This looks like basic problem when you tackle with some RS chart, and now I have gone into it but on SSRS 2000.

    Have you already found how to programme color of series in a chart?

    IMO there will not be a big difference between 2000 and 2005 in the syntax.

    Cheers,

    Bartek

  • Bartek,

    I followed the way Nick explained in his message.

    Additionally 1) I added new table with product (or customer) color map; 2) created function to convert rgb color to hex (SSRS does not understand rgb color directly- at least I could not teach him :-)). Use color hex value returned from SP for your product/customer color. Actually that's it.

    Yuri

  • Hi Yuri,

    Thanks for reply and additional tips.

    I followed Nick's advices and I could not find "Series Style" button, that's why I asked you.

    It seems that I have old Report Designer, I will upgrade it to SP2 later on after my work.

    Cheers,

    Bartek

  • Not sure if this helps, but it worked for a quick report.... Shouldn't be too difficult to link it to a database to retrieve what colour should appear for each data value (use hex colours rather than named colours for more variety).

    This is using VS.NET 2003 (Microsoft SQL Server Report Designer Version 8.00.1038.00) and RS 2000 (Microsoft SQL Server Reporting Services Version 8.00.1042.00, SP2).

    1. Create function under Report Properties > Code option.

    function GetBoardColour(BoardID)

    Dim BoardColour as string

    select case BoardID

    case "EMS"

    BoardColour = "LightGreen"

    case "IM"

    BoardColour = "yellow"

    case "CF"

    BoardColour = "OrangeRed"

    case "HR"

    BoardColour = "CornflowerBlue"

    case "IT"

    BoardColour = "Silver"

    case else

    BoardColour = ""

    end select

    GetBoardColour = BoardColour

    end function

    2. On the Chart, select Properties then the Data tab. In the Values section choose to Edit. In the Edit Chart Value popup window select Appearance tab and then the Series Style button then the Fill tab.

    Then enter the following for the Fill colour: =Code.GetBoardColour( Fields!Board.Value)

  • There is no way to conditionally change the pie colors basedon data. However, If what you need is to simply define colors individually for the Pie slices, you can use the "Edit-Chart In Place" feature available in the smart tags wizard. You can then right click on each slice and change the color. If you are dont know exactly how many slices your pie will have, you can set the number of points in the property grid to a high number so you can see all the slices at design time.

    Hope this helps.

    RAQ Report: Web-based Excel-like Java reporting tool[/url]

  • Thanks for tips, all were helpful!

    Cheers,

    Bartek

  • Hi, Yuri.

    As I know, you can use RAQ Report to solve your problem. Because with it, you can set the properties of chart as you like in the dialog box easily.

    I wish this would be helpful.

    Regards,

    becklery.

    RAQ Report: Web-based Excel-like Java reporting tool[/url]

  • Hi,

    I found a simple work-around for this problem. It might not be the best solution if you need to be excirsively dynamic, but it goes like this:

    Simply go to the Fill/Colour property of the series in your chart. Type in an IIF statement like this:

    =IIF(Fields!ProductName.Value="ProductA","Red",IIF(Fields!Weighting.Value="ProductB","Yellow","Green"))

    This will force SSRS to apply these colors regardless of the colour palette you have choosen.

    Hope this helps πŸ™‚

Viewing 11 posts - 1 through 10 (of 10 total)

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