Archive for category Case Chart

Specify Exact Colors for Each Priority in the Microsoft Dynamics CRM 2011 Case Chart

I’ve already written one post about a short-coming of the out-of-the-box Cases By Priority Chart. That post addressed a relatively minor nuisance about how cases with the priority level “Normal”, are colored red, while the “High” priority items are blue, when the opposite seems more natural.

Orginal Chart Cases by Priority (Per Day)

Orginal Chart Cases by Priority (Per Day) in CRM 2011

However, a more pressing issue is that the CRM chart only colors the series that are available in your View. This means it would be impossible for the viewer to decode a chart without reading the Legend every single time.

Example

Case Chart CRM 2011 only showing High records, all blueCase Chart CRM 2011 only showing Low records, all blue

These two case charts look the same, but the work that will go into handling them, certainly is not. The user must carefully read the legend, every time, before they know what priority the blue color is representing.

To improve on those issues for the Case Chart in Microsoft Dynamics CRM I will do the following:

  • Ensure that the Priority levels have meaningful colors
    – High (Red)
    – Normal (Yellow)
    – Low (Green)
  • Ensure that the same color is always on the same priority level, i.e. Red is always high
  • If there’s no cases with priority high, then there’s no Red color.

The result in this scenario should be:

  • A CRM Chart that shows all Cases in the legend
  • Cases for the current week, with days along the X axis
  • Cases stacked according to Priority are always in the same order

To achieve this, we need to combine some approaches that I’ve blogged about before.

Modify the order of the colors
Order the data so the Priority series are always colored the same

We also need to make sure that the levels High, Normal and Low are always a part of the series, even if they are no Cases with that type present. This is the tricky part as it includes adding records with no or zero value to our CRM Chart.

Note: The method I am using here works by adding a set of dummy records to the dataset, but without actually counting them in the chart. However, creating a set of dummy records may not always be preferable. It is also possible to create this priority stacked column chart, without the use dummy records, and still get all values into the legend and define the exact colors for each series. That method also comes with its own set of drawbacks, but I’ll have to save that for a later blog post.

Step 1 – Set the Order of the Priorities

I have exported the default Cases By Priority (Per Day) chart. The only modification I have made to the original xml, is that I’ve replaced the “Created On” date, with the “Follow Up By” date. The only reason for this change is that it is faster to input demo data.

To sort the data I add a line with an order clause on the priorities, with descending=”true” to put the value “High” on top of the chart.

Order Chart xml code High on top

New line with the Order clause is highlighted

Let’s import the chart xml back into CRM 2011 and see what it looks like.

Case Chart Ordered by Priority - High on Top, CRM 2011

Now we got them in the right order with “High” on top.

The chart here is ordering according to the values in the Option Set and not alphabetically so some experimentation may be needed.

Note: Ordering by Option-Sets in the chart xml is not an exact science in MS CRM 2011 Charts. Particularly in situations like this, where the Option-Set is the secondary groupby clause. The date is the first groupby clause because we need that on the X axis. If we had added an extra Priority level to the system Option-Set, we would likely see some odd orders regardless of how we sort them.

Step 2 – Changing Colors in the CRM chart to match specific series

The stacked bar chart orders the colors from the bottom and up, which mean that I’ll have to insert the colors in the custom palette in order of Low, Normal, High. Remember I sorted them so I had High on top, meaning it’s the last one to get a color from the Palette.

Chart xml for the priority chart – with original colors in RGB, and what I’ve replaced them with.

Original

PaletteCustomColors - Original in the crm chart xml

Original custom color order for the case chart

With new colors

PaletteCustomColors after color changes, CRM chart xml

New color codes added to the first three colors

I use the color names. They are much easier when testing than the RGB codes. If needed, we can always adjust them afterwards to the exact color nuance using either HEX, RGB or ARGB codes.

Note: I could have just written Green Yellow Red in the xml, but those colors just looked horrendous for this CRM chart. An overview of all the colors available in CRM Charts can be found in this blog post.

Here’s the chart, after importing the chart xml, with the new colors and the desired order.

Priority with the right colors

Step 3 – Make sure the colors don’t change depending on available records

However, if we have a week where not all types of cases are present, we still get the wrong color on our chart, so we need to ensure that we always have at least one record of each priority type.

To achieve that we will:

  • Create a set of dummy records. Three records, one for each Priority type
  • Adjust our View to include the dummy records
  • Modify our CRM Chart xml to not show them, but only create them in the Legend

I’ll modify my case View to show only cases for this week, which is what I want the chart to show. Then add the specific date that I have created the dummy records on.

Here’s the Advanced Find View using the OR parameter to include the date for the dummy records.

View incl the date with dummy dates

I’ll use 1/1/1950 for the example as it is way outside our possible date range for the cases.

Here’s the CRM chart now, including the dummy records.

chart with dummy records

Now we need to modify the CRM Chart xml so the dummy records do not display in the chart.

fetchcollection before link-entity

The highlighted attribute above in the fetchcollection counts the number of Cases. (The entity name for Cases is “incident”). This is the attribute we need to change, so it only counts cases for this week.

I’ll do that by adding a self-referencing link-entity and adding a filter to the attribute.

fetch collection with link entity

I’ve replaced the count attribute with everything between the highlighted <link-entity> tags above.

What happens is that we create a self-referential link to the incident entity and add a filter with the “this-week” condition. The <link-entity> allow us to apply a filter to this attribute only. Had we just added the filter to the attribute directly, it would have applied to the entire chart, and thus excluded our dummy records completely.

Highlighted and underlined in red is the aggregate, changed from “count” to “countcolumn”. If you forget this part, the filter will not be applied and include our dummy records in the count. “countcolumn” is normally used for counting non-empty records, but when applied in this manner, it will count only the records that matches the filter following in the xml.

Let’s import the latest CRM chart xml and have a look.

chart without dummy records but with 1950

Excellent. The Jan 1 1950 day is now empty, even though we know there are three records in the dataset. The fact that we can see the date, 1/1/1950, proves that they are there.

To check if the colors stay true to their designated series, I’ll go ahead and delete all the cases, in this week, with priority “Normal”. In the old chart, we would then see all the priority “High” cases get the next color in line, which in this case would be the khaki yellow.

chart no Normal but still ordered and colored correctly w 1950

Great, we can now see that the chart Orders all the Priorities correctly, regardless of whether or not they are a part of the current record set. Another bonus is that the legend still show us all the types of priorities.

In a previous post, a commenter had a very good suggestion of perhaps even leaving out the legend to utilize the space better, since the color-coding does not change and is implicit. Alternately, if you repeat the same color scheme, you could just leave the legend on one of the charts for reference.

Ok, so what about that 1950 date for the dummy record!

Step 4 – Modify the X and Y axis

Had our chart not used a date on one of the axes, such as a pie chart or a stacked column chart by User, we would have been done now. Those charts would have nowhere to display the 1950 date of the dummy records.

The process that enabled us to include all the Priorities, also adds the extra date to the X axis.

We’ll edit the chart xml one last time and remove that date. Since we are modifying the X axis anyway, we might as well do a few other improvements at the same time.

Axis modifications

On AxisY, I added Title=”Number of cases”. “Number of cases” just seems like a much better descriptor than “Count:Non-empty (Case(Case))”.

On AxisX, I changed the TitleForeColor to “Transparent” and reduced the TitleFont to 5px. Since the chart is already writing the day date, it would be redundant for the CRM chart to also tell me that the columns are grouped by day. You cannot remove the axis title on CRM charts, but making them transparent more or less achieves the same thing.

Lastly, the most important addition is adding Minimum=”1” to the X axis. This will skip the first series and start the chart with the first day of the current week. The X axis by default starts at “0”, so setting it to start at “1” instead, will skip the first day of the series, which also happens to always be the date of our dummy records.

Final Case chart with Colors and Orders fixed

One last look at the chart. High, Normal and Low are all in the legend even though we only have records with the High and Low Priority. There are only dates for the week that we want.

The Y axis title is short and precise. No title on the X axis. We are clearly looking at days.

Now, we just might want to adjust those colors a little, but that’s a different story.

Hope you enjoyed it. Please follow my blog or on Twitter. 

, , , , ,

15 Comments

Using Custom Colors in Charts

At times it can be nice to define you own colors in charts. You may need to use a specific a corporate color scheme, make it easier to tell certain items apart or simply make the chart easier for the user to understand quickly.

It has always puzzled me how they chose the colors for some of the out-of-the-box system charts in Microsoft Dynamics CRM 2011.

Take the “Cases by Priority” chart for example.

At first glace this chart seems alright. Except when you look at how the series are colored, cases with “Normal” priority are red. In a chart like this red stands out more and most users would associate the red color with some kind of warning sign. On the other hand, the cases with priority high has the less alarming color blue.

Before we get into changing this specific chart, let’s look at some of our options for changing and modifying specific colors.

See this post for changing the complete Palette of a chart.

Export the charts xml file, open it and find the PaletteCustomColors property.

All the colors are listed as RGB colors, separated by a semicolon.

While Dynamics CRM add RGB colors to its custom palette it should be noted that Dynamics CRM accepts

  • RGB Decimal (example: 97,142,206)
  • RGB HEX (example: #4169E1)
  • Named colors (example: Blue)
  • ARGB (127,97,142,206)

The named colors could prove a lot easier to work with.

So instead of PaletteCustomColors=”97,142,206; 209,98,96; 168,203,104; etc.
we could write PaletteCustomColors=”Blue; Red; Green; etc.

Using the color names also makes it a lot easier to check if you have added them in the correct order.

This page contains an overview of the named colors available to use in charts.
http://msdn.microsoft.com/en-us/library/aa358800.aspx
Bonus: There’s one color missing from this list and that is “Transparent”. Transparent could prove very useful when you need to add data to a chart, but actually don’t want to show it. For example you may only want to display the value on a chart, but not have the bar or column visible.

Back to the example where we wanted to change the color scheme so High Priority Cases are red and Normal Priority Cases are Blue.
Since Dynamics CRM lists the series in reverse order (right to left) we know that Blue is the first color and therefore goes to the series for High Priority.

We want to change the the order of the colors so Red gets the first High Priority series. Then Blue and then Green.

To achieve that we need to edit the xml files so the first the colors of the PaletteCustomColors look like this.

Importing it back into Dynamics CRM we will get this result for the Cases By Priority Chart.

Now the High priority cases are appropriately Red and the Normal and Low priority cases have less alarming colors.

On some charts it is also possible to add specific colors to specific series, but I’ll save that for a later blog post.

Bonus: ARGB

Charts also support ARGB, which is similar to RGB, but there’s four values instead of three. The first value indicates the color’s Alpha transparency. 0 equals completely transparent. 255 is no transparency. 127 is 50% transparent etc.

Alpha transparency values are normally a percentage, but it has to be written in the RGB format which is a value between 0 and 255.

, , , , , , , ,

12 Comments