Today's guest blogger is Jacob Cynamon-Murphy, a Technical Specialist at Sonoma Partners
Barney Stinson is not the only person who cares about things being legendary. I was building out a demo of Microsoft Dynamics CRM 2011 (CRM) and I created what I considered a pretty cool chart. Much to my chagrin, the legend was showing in the reverse order (see Before image, below).
I scoured the internet for guidance, but found that there was no documentation going this deep into customizing the legend of a chart in CRM. Ultimately, my past developer experience helped me dig up the way to do this (see After image, below). By adding one attribute to the Legend element, I was able to reverse the order.
Technical explanation: Behind the scenes, CRM is mapping a declarative model (XML) to an imperative model (.NET). The XML appears to reflect the structure of the Chart class in the System.Web.UI.DataVisualization namespace. As a result, we can discover additional elements and attributes that we can use in the chart XML to control the presentation of the chart elements. Empowered with this knowledge, I now know exactly where to go for more control over my CRM charts. For example, with the Legend change I made, I found the Legend class had a property called LegendItemOrder, with three options: Auto, SameAsSeriesOrder and ReversedSeriesOrder. Knowing that I wanted to reverse the order that CRM was using, I defined LegendItemOrder as an attribute with a value of "ReversedSeriesOrder". Legend… wait for it… dary!