Wednesday, March 28, 2012

Having Custom Legend to Pie Charts

Hi All,

what I want is a custom Legend for the Pie Chart.

I have followed this article and have done what was written under

Custom Chart Color Palettes and Legends

http://msdn2.microsoft.com/en-us/library/aa964128.aspx#moressrscharts_topic4

But still the color of the legend is not uniform.

Basically I am using a stored procedure which returns two values : Circle, Total based on a parameter called Customer.

1. I have pasted the code asked in the Code Section of the report.

2. Have Disabled the 'Show Legend' box in Chart Properties.

3. Have included the following code in the Values->Appearance->Series Styel->Fill

=Code.GetColor(Fields!Circle.Value)

4. In the Category groups ->Group on-> this is my expression =Fields!Circle.Value (Basically I am not sure where

should I include Circle Field. I have tried this both by putting it in Category Groups and Series Groups.)

5. Dragged and dropped new table and have done the following

a.table1->Properties->Groups->Add->General->Group on Expression Fields!Circle.Value

b.Deleted Detail row.

c.Dragged and dropped rectangle in the column value and set the background value to =Code.GetColor(Fields!Circle.Value)

When I run the report for different customers the colors are not remaining constant. I have 17 values for Circles. So included three more colors in the "colorPalette " variable..

After doing all this still I am not able to get the same colors. Could someone tell me where I am going wrong?

Well, it looks like there was nothing wrong with the way I have been doing at all. My requierment was immaterial of whether certain value is present or not I wanted a color associated to that i.e. if for a given date(the input) my data returns the circles say Circle 1, Circle 2 with green and yellow colors associated with them respectively. So if those circles are not returned by the query then what was happening was green was getting applied to Circle 2 rather than sticking on to Circle 1. I changed my settings back at DB for this and now it is working fine.

For those of you whose results are static that is if you have data with all the circles say Circle 1 to Circle 5 all the time and you have to define your custom palette in it then this is the perfect method.Hope this helps some others.
Thank you

No comments:

Post a Comment