Need help regarding Custom Colors for Charts in Reporting Services
I need some help regarding Custom Colors implementation for Charts in the Reporting Services. What we are trying to do is to make every color for every Series(see example below) to be a customized Corporate color. For example each of the series on the Chart should be in specific Custom Color: Series 1 -"LightBlue" Series 2 - "LightYellow" Series 3 - "DarkBrown" All I found from MSDN is how to do it in the Chart Properties in a Code section (right click on the report outside the chart -> Properties -> Code tab -> paste the Custom Code ). And then to use it in the Chart color definition as: Code Snippet=Code.GetColor( Series# ) But we are trying to do it in a separate C# class that would be updated only in one place, instead of changing 30 reports each time something is changed. So that it could be generic. The C# class: Code Snippet namespace CustomColorPalette { public class CustomPalette { public CustomPalette() { } public static string GetColor(string GroupingValue) { int groupingValue = int.Parse(GroupingValue); string[] colorPalette = {"Green", "Blue", "Red"}; if (groupingValue < colorPalette.Length) { return colorPalette.GetValue(groupingValue).ToString(); } else { return "Black"; // if # of Series is more than defined - all undefined will be = Black color } } } } I tried 2 different ways: 1. Then I put a code into a Custom Code section of a report: Code Snippet Public Function GetColor(SeriesNumber as String) Return CustomColorPalette.CustomPalette.GetColor(SeriesNumber) End Function And in the Chart Custom Color settings I put: Code Snippet=Code.GetColor( Fields!SeriesNumber.Value ) And after compilation I get an error: Error303[rsCompilerErrorInCode] There is an error on line 2 of custom code: [BC30451] Name 'CustomColorPalette' is not declared.c:\development\voyagerreports\voyager convert reports.root\voyager convert reports\Report_007D.rdl00 2. Second way I tried: Then I put a code into a Custom Code section of a report: Code Snippet Dim X As CustomColorPalette.CustomPalette Protected Overrides Sub OnInit() X = new CustomColorPalette.CustomPalette() End Sub And in the Chart Custom Color I put: Code Snippet=Code.X.GetColor( Fields!SeriesNumber.Value ) And after compilation I am getting an error like this: Error 302 [rsCompilerErrorInExpression] The BackgroundColor expression for the chart chart2 contains an error: [BC30456] 'X' is not a member of 'ReportExprHostImpl.CustomCodeProxy'. c:\development\voyagerreports\voyager convert reports.root\voyager convert reports\Report_007D.rdl 0 0 Is there any workaround? Or all I can do is to make the Custom Colors manually in each report, and if something need to be changed - I will need to change it in each report separately Thanks, Alex
May 30th, 2007 6:01pm

>>> But we are trying to do it in a separate C# class that would be updated only in one place, instead of changing 30 reports each time something is changed. So that it could be generic. Yes, that is possible. However, it sounds like you didn't add a reference to your custom assembly to the report. You have to add a reference via the "Report" VS menu -> Report Properties -> References tab -> Assemblies section. More information about using and deploying custom assemblies on a report server can be found here: * http://msdn2.microsoft.com/en-us/library/ms153561.aspx Note that by default custom assemblies have execute only security permissions when running in report server (or in the report designer "stand-alone" preview which you can start by hitting F5). If the custom assembly performs file operations, etc. you will need to assert permissions inside the assembly and configure the report server's security policy accordingly (see e.g. http://support.microsoft.com/kb/842419, http://support.microsoft.com/kb/920769, http://msdn2.microsoft.com/en-us/library/ms155108.aspx). You may also be interested in this blog article which is related to what you are trying to accomplish: http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx -- Robert
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2007 8:02pm

I really didn't find this References earlier. All I did - tried to add a Dependencies for the Reports from the CustomColorPalette.dll and I saw that .dll was phisically copied into a Reporting Services folder. When I added a reference this time I have got this error message: Error8[rsErrorLoadingCodeModule] Error while loading code module: CustomColorPalette, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly 'CustomColorPalette, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.c:\development\voyagerreports\voyager convert reports.root\voyager convert reports\RESP_007D.rdl00 Should I define a Class somehow on the same References tab? Thanks, Alex
May 30th, 2007 11:50pm

Did you follow the steps in the following blog article? http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx -- Robert
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2007 6:03am

>>Did you follow the steps in the following blog article? >>http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx Yes, step by step. Everything seems to me makes sense in that article, but the error is in place... Thanks, Alex
May 31st, 2007 5:10pm

I have reported this problem in Connect. Please vote, so it will be on the agenda of the future development of Reporting Services: https://connect.microsoft.com/SQLServer/feedback/details/606496/custom-colorpalette-for-charts-ssrs
Free Windows Admin Tool Kit Click here and download it now
September 29th, 2010 11:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics