Creating new Charts in Dynamics CRM has been quite easy for a few versions now. It’s a visual process, very intuitive. But how is all this configuration stored?
To have a quick look at this information, we can start by selecting a chart to analyze. Let’s navigate to Sales > Accounts. Expand the chart in the My Active Accounts view on the right side.
Then click on the ellipsis (More Commands) and on Export Chart.
The output is an xml definition file. Let’s look at some of the elements.
Wrapper – the entire customization is wrapped in a <visualization> tag.
Inside, the specific chart ID is defined in a <visualizationid> tag. This recognizes if this is a new chart or n update to an existing one. Do note that you can not override the OOTB charts.
Next we have the respective <name> and <description> tags which are pretty self-explanatory.
The <primaryentitytypecode> tag defines the entity for which this chart is available. In our case it will be for account.
All the way at the bottom of the file we have the <isdefault> tag which simply defines the Chart as the default or non-default chart for this entity. Values are true or false.
The <datadescription> tag contain the <datadefinition> tag, which in turn contains the <fetchcollection> and <categorycollection> tags.
The <fetchcollection> contains the <fetch> tag which describes the query used to retrieve the data. This uses standard FetchXML to retrieve data for the chart. The <entity> tag defines the entity queries, while the <attribute> tags define the properties.
The <categorycollection> tag defines the category and series. These are basically the horizontal and vertical axes of the chart. The <category> sub-tag contains for each defined category a <measurecollection> which maps to a series element. For a single series chart we will only find a single <measurecollection> tag, while a multi-series chart will have more than one. The <measure> tag inside the <measurecollection> is just referencing the vertical axis value (series) which correspond to each element on the horizontal axis.
The next important tag is the <presentationdescription> tag. It contains the <chart> tag that wraps the following definitions:
The <series> tag which defines the chart type, labels visibility, colors and font size.
The <chartareas> tag which defines the chart border properties and the X and Y axis properties.
The <titles> tag which defines the title font, alignment and color.
The xml of the <chart> tag is a serialization of the Microsoft Chart Controls Chart class. For the standard features of the Chart Controls see this article on MSDN.
For the sake of this example, let’s modify the highlighted items:
Basically we define the BorderColor to be Red, the TitleForeColor to Red and the ForeColor to Green. Now, the modified chart, once re-imported, looks like this:
Not the most visually appealing, but proves the point. Now you can go ahead and “brand” your Charts.
When modifying colors, use the RGB notation.