Archive for March, 2014

All things Pie Chart in Dynamics CRM

Somehow I have managed not to write about the Pie Chart in Microsoft Dynamics CRM. What you can do with the pie chart is fairly limited since only one series is supported.

However, there are a number of custom properties we can use to tweak the appearance of the pie chart.

Custom properties can be found at the end of the series properties. Note that unlike standard properties, custom properties are all added within the quotations of the CustomProperties.

CustomProperties in Pie Chart XML for Dynamics CRM

The custom properties we can use on a pie chart in Dynamics CRM are:

  • PieDrawingStyle
  • PieStartAngle
  • PieLabelStyle
  • LabelsHorizontalLineSize
  • LabelsRadialLineSize
  • PieLineColor
  • MinimumRelativePieSize
  • CollectedThreshold
  • CollectedThresholdUserPercent
  • CollectedColor
  • CollectedSliceExploded
  • CollectedLabel
  • CollectedLegendText
  • CollectedToolTip

I’ll go through each of these properties and add some notes along the way. There’s an XML sample of a series at the bottom of the post with all the custom properties added.

PieDrawingStyle

  • Default (Default)
  • SoftEdge
  • Concave

Changes the appearance of the pie chart. Yes, the default value is called Default.

Dynamics CRM chart. Chart type Pie. PieDrawingStyle Default

PieDrawingStyle=Default

Dynamics CRM chart. Chart type Pie. PieDrawingStyle SoftEdge

PieDrawingStyle=SoftEdge

Dynamics CRM chart. Chart type Pie. PieDrawingStyle Concave

PieDrawingStyle=Concave

For simply changing the appearance, another option is to change the Area3DStyle to true. Although this is not a custom property.

Dynamics CRM chart. Chart type Pie. 3D enabled

3D Enabled

PieStartAngle

The PieStartAngle is a value between 0 and 360 degrees depending on where you want the first value to start. Microsoft Dynamics CRM pie charts by default start in the 3 o’clock position. That means the 3 o’clock position is 0 degrees and any changes have to take that into account.

Dynamics CRM chart. Chart type Pie. PieStartAngle 270 degrees Custom Property

PieStartAngle=270 start the first slice in the 12 o’clock position

PieLabelStyle

  • Inside (Default)
  • Outside
  • Disabled

PieLabelStyle moves the label inside, outside or disables them completely.

Dynamics CRM chart. Chart type Pie. PieLabelStyle Inside Default

PieLabelStyle=Inside

Dynamics CRM chart. Chart type Pie. PieLabelStyle Outside

PieLabelStyle=Outside

The following four custom properties only apply to pie charts where the PieLabelStyle is set to outside.

LabelsHorizontalLineSize
Specifies the size of the horizontal segment of the callout line, as a percentage of the chart area.
Value range 0-100. Default is 1. Set to 0 to hide it.

LabelRadialLineSize
Specifies the size of the radial segment of the callout line, as a percentage of the chart area.
Value range 0-100. Default is 1. Set to 0 to hide it.

PieLineColor
Any named color, RGB, ARGB or HEX value can be used. See more about colors in MS Dynamics CRM charts here. Default is Black.

MinimumRelativePieSize
Specifies the minimum pie size. Value range 10 – 70. Default is 30. This property has no effect unless the outside label style is used.

Labels and Keywords

When creating a pie chart, the IsValueShownAsLabel=”True” is already added to the chart XML by default. This is what shows the values inside the chart. These values can be formatted by adding the LabelFormat property to the series. Go here for formatting of values in CRM charts.

If you want to customize the content of the label, IsValueShownAsLabel must be set to “False”.

The two properties on a standard pie charts that can hold custom text and keywords are Label and LegendToolTip. Both of these properties must be added in the series. This is included in the sample XML series at the bottom of post.

Here are the keywords that can be used in pie charts. They should be rather self-explanatory. While the last three work, they are not very useful on a pie chart.

  • #LEGENDTEXT
  • #VAL
  • #PERCENT
  • #TOTAL
  • #MIN
  • #MAX
  • #FIRST
  • #LAST
  • #INDEX

Here’s a sample of what the Label and LegendToolTip could look like with keywords added. You can combine both text and keywords as needed.

Label="#LEGENDTEXT #PERCENT  -  #VAL out of #TOTAL total" 
LegendToolTip="#LEGENDTEXT #PERCENT  -  #VAL out of #TOTAL total"

And here is how the pie chart looks with the Label.

Label with Keywords. Dynamics CRM chart. Chart type Pie.

Label=”#LEGENDTEXT #PERCENT – #VAL out of #TOTAL total”

And with the LegendToolTip.

LegendToolTip with Keywords. Dynamics CRM chart. Chart type Pie.

LegendToolTip=”#LEGENDTEXT #PERCENT – #VAL out of #TOTAL total

The LegendToolTip only appears when the mouse hovers over the legend item. Unless changed, the tool tip will show the percentage by default. It’s redundant to show the legend text here, but the option is there.

Label, LegendText, and keywords can be used in the series of other chart types too.

CollectedThreshold

A lot of the pie chart’s custom properties are associated with the CollectedThreshold. The feature combines smaller values into one larger pie slice. This can be useful especially when you have a lot of smaller values  that you can’t tell apart anyway.

When using the CollectedThreshold, you must set IsValueShownAsLabel to False. Otherwise an incorrect value will be shown for the collected slice. Only the value of the first collected item will then be shown.

CollectedThreshold
Any value lower than the CollectedThreshold will be be in the collected slice.

CollectedThresholdUsePercent
If set to true, CollectedThreshold must be between 0-100 and is then defined as a percentage.

CollectedColor
Can be any named color, RGB, ARGB or HEX value. More on colors in CRM charts here.

CollectedSliceExploded
If true, then the collected slice is exploded.

CollectedLabel
Your label for the collected slice. Supports keywords.

CollectedLegendText
The text in the legend. Supports keywords. Customized legend text is only supported for the collected item.

CollectedToolTip
Text in the tool tip for the collected slice. Supports keywords.

Dynamics CRM chart. Chart type Pie. Collected Options used in custom properties

Using collected properties.

Notes on collected

Keyword #MIN is now the collected value, so it cannot be used to show what the minimum value inside the CollectedThreshold is.

Add keyword #TOTAL only to the CollectedLegendText and the total value will appear only once on the chart.

Include a description of how the CollectedThreshold is defined in the either the CollectedLabel or the CollectedLegendText. That way, the user can better decode the information..

Stuff we unfortunately cannot do with Pie Charts in Dynamics CRM

  • LegendText – can’t be changed. Except for collected
  • ToolTip – have no effect
  • LabelToolTip – have no effect
  • Exploded – custom property, have no effect.
  • Keyword values cannot be formatted

Yes, you cannot add formatting to keywords, even though the documentation says you can. You’ll get a chart rendering error in Microsoft Dynamics CRM if you try to add it. This makes keywords pretty useless when dealing with large numbers. I have reported the issue to Microsoft, so if you have a minute, please go vote for the case here, and hopefully we can soon unlock even more chart features.

Note that with IsValueShownAsLabel=”True” label formatting in Dynamics CRM charts can still be used.

The documentation for all the pie chart properties can be found here. http://msdn.microsoft.com/en-us/library/dd456674(v=vs.110).aspx

Sample XML of a Pie Chart series with all custom properties.

<Series	ChartType="pie" ShadowOffset="0" IsValueShownAsLabel="False" 
	Font="{0}, 9.5px" LabelForeColor="59, 59, 59" 
	Label="#LEGENDTEXT #PERCENT  -  #VAL out of #TOTAL total" 
	LegendToolTip="#PERCENT  -  #VAL out of #TOTAL total"
	CustomProperties="PieDrawingStyle=Concave,
			  PieStartAngle=270,
			  PieLabelStyle=Inside, 
			  PieLineColor=Black,
			  LabelsHorizontalLineSize=1,
			  LabelsRadialLineSize=1,
			  MinimumRelativePieSize=10,
			  CollectedThresholdUsePercent=True,
			  CollectedThreshold=10,
			  CollectedColor=Tan,
			  CollectedSliceExploded=True,
			  CollectedLabel=Collected #VAL - #PERCENT,
			  CollectedLegendText=Collected - #VAL out of #TOTAL total,
			  CollectedToolTip=#VAL out of #TOTAL total">
  <SmartLabelStyle Enabled="True" />
</Series>

The sample series can be used to replace the standard series generated by the chart editor.

Thanks for reading. If you have a tip or trick for pie charts that I haven’t found, please include them in the comments. And of course, please sign up for the newsletter to be up to date on new blog posts and follow me on Twitter 

, , , , ,

19 Comments