Pie chart in report viewer 2010 (RDLC)

So you want a pie chart in your report? Well here are a few gotchas that are hard (at least to some of us :)) to understand how they work. Image illustrates 3 things that may catch you out – smart label line between pie slice and the label, percentage to be displayed as label and legend name as parameter or whatever else you need.

sample layout of a pie chart in VS2010 RDLC
Sample latyout of a pie chart VS2010 RDLC

Smart label refusing to show up

The key here is that the chart is made up numerous objects and as they all seem to contain the same names it becomes hard to know which one controls what.
The answer here lies in the chart object itself. Click on pie chart. Your current selection should now appear to be the first series of the pie chart. In the current property list find the “CustomAttributes” group. In here there are two values that you need to set the “PieLabelStyle” needs to be set to “Outside” and the “PieLineColor” needs to be set to whatever you need – just not default or auto (did not work for us until we set a specific color here). Lastly set the value of “Visible” to “True” and you’re done.

Percentage display on the label

This one is a little bit easier to find – for each series you display on the pie chart find the “Label” group and in here is a “Label” sub property which must be set to “#PERCENTAGE”. After this the number show will be in the format in the image above.

Legend text from parameter

Next we will discuss here is the label shown in the legend of the chart. This one is one of the gotchas of too many identically named fields – if you edit the “Legend” property “Text” nothing seems to happen. If that’s the case then select “DataPoint” next its “Legend” and lastly its “Text” property. Set it to say a parameter you’re passing e.g. “=Parameters!NameSeries1.Value”

The "right" Legend Text property
The “right” Legend Text property

RDLC Report – Divide by Zero  problem

Recently I came across a problem with one of the reports where under some rare circumstance the report would produce an “Error#” in the table. Upon inspection I have found that the expression used in the textbox was using a test IIF to determine if it could go ahead with a divide or not as in is the value 0 or not. The code was written intuitively as:

=IIf(Sum(Fields!Val4.Value) = 0, 0, Sum(Fields!Val3.Value)/Sum(Fields!Val4.Value))

Logically this should work but of course this doesn’t work for one simple reason – the interpreter of the report control takes all paramaters and evaluates them regardless of whether it will use them/needs or not. So how to solve this? It appears that doing a double IIF call will “shield” this operation hence the solution is to do the following:

=IIf(Sum(Fields!Val4.Value) = 0, "0%", Sum(Fields!Val3.Value) / IIf(Sum(Fields!Val4.Value) = 0, 1,Sum(Fields!Val4.Value)))

Since then I have found others who have come up with this issue back in 2006 – go figure that such a simple thing still exists and has not been fixed up in the later revisions of the report control.


That’s it for now!


Print Friendly, PDF & Email

IE 9 Search plugin download – where is Google and others?

I am sure lots of people have come across this issue but alas one more post may help some poor lost soul. IE9 has some nice features and some bad ones. One of the “victims” of company wars are things like default values or difficult access to alter settings. IE9 is no exception with Microsoft choosing to default everything to BING. For those who want another search provider have to use the manage add-ons options to find alterntive search providers.

This is where a problem can appear. If you happen to use Windows that use non US settings eg. AU you may not see alternative searchprovider on the list. Heck the Australian list of search providers offers Bing like in the image captured even today:

default search non US

So to solve this problem and see many, many more search provider options for IE9 we must either change settings to tell IE9 we want US or simply change the URL we show up so that instead of http://www.iegallery.com/au/addons/?feature=searchproviders we go to http://www.iegallery.com/us/addons/?feature=searchproviders (note the country changed from au to us). And now you can pick from a “slightly large list of options!



Print Friendly, PDF & Email