Charts – Pie Charts

In this post I will continue my series looking at how charts layouts can be customized using XML. If you are new to amending the chart XML please refer to my post on adding percentages on pie charts, as this describes the process to export, edit and re-import chart XML.

This time I am going to be looking at pie charts.

Label Positions

You can control the position of the labels on the pie chart using the PieLabelStyle option. Valid options are Inside, Outside and none. The default being Inside.

An example of Outside is shown below.

CustomProperties="PieLabelStyle=Outside, PieDrawingStyle=default" ChartType="pie"

Drawing Style

The “PieDrawingStyle” option in the custom properties of a chart allows you to control the style of the pie charts.

<Series>
<Series ShadowOffset="0" IsValueShownAsLabel="true" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="pie">
<SmartLabelStyle Enabled="True" />
</Series>
</Series>

The options include;

PieDrawingStyle=Default

PieDrawingStyle=SoftEdge

PieDrawingStyle=Concave

Or you can change the style to be 3d.

<ChartArea>
<Area3DStyle Enable3D="true" />
</ChartArea>

Doughnut
You can also set the chart type to be doughnut

CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="Doughnut"

Giving a chart which looks like this;

pie1

Or you can go for combinations, my personal favourite combines doughnut and SoftEdge.

<Series ShadowOffset="0" IsValueShownAsLabel="true" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=SoftEdge" ChartType="Doughnut">

pie2

Labels

Changing the ValueShownAsLabel to false (as shown below) will result in a chart that looks like this. Notice how the legend names are displayed as a label.

<Series>
<Series ShadowOffset="0" IsValueShownAsLabel="false" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Outside, PieDrawingStyle=default" ChartType="pie">
<SmartLabelStyle Enabled="True" />
</Series>


Once you’ve set IsValueShownAsLabel to false you can continue to make furthers changes to the label and legends. See below.

<Series>
<Series ShadowOffset="0" IsValueShownAsLabel="false" Label="#VAL(#PERCENT)" Font="{0}, 15px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Outside, PieDrawingStyle=default" ChartType="pie">
<SmartLabelStyle Enabled="True" />
</Series>

Here you can see that I made the label font larger and also included the value and percentage in the label.

Adding something like this …. Would also give the ability to have a customized tooltip on the chart.

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

The Label and LegendToolTip properties can include any combination of;

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

One thought on “Charts – Pie Charts

  1. Pingback: Charts – Collection | Microsoft Dynamics CRM and Unified Service Desk

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s