Axes modifications – Part 1

The axes in the charts are usually fitted properly, but there are situations where it is needed to modify them to bring out a certain point in the data or improve the chart. Luckily we can do a lot with the Axes properties in the xml file, such as changing titles, colors, intervals, axes crossings etc.

A list of the Axes properties can be found here http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.axis_properties, but I’ll go through some of them here.

When looking at the exported chart in an xml file you need to locate the axis you want to modify. The Axis section is a part of the ChartArea in the presentationdescription of the xml file.

A standard Y axis section can look like this

In order to apply any of the properties from the referenced list, we will have to insert them between the opening and closing AxisY tags. Had we been working with a secondary Y-axis, we would also have tags for AxisY2. The Microsoft Dynamics 2011 online charts support 2 X axes and 2 Y axes (AxisY1, AxisY2, AxisX1 and AxisX2). I will leave the use of multiple axes to a later blog post.

Notice in the example above that some properties, like LineColor, are defined directly, while some, such as LabelStyle, have their own set of properties. In this blog post I will only look at properties that can be defined directly. These are the most simple to work with.

In my first example I will use the property ArrowStyle. The xml file should look like this with the ArrowStyle property added.

When I list the properties, the values in parenthesis are the options for which the property can be set.

ArrowStyle (None, Triangle, SharpTriangle, Lines)

sample from end of X axis

  • None (default)
  • Triangle
  • SharpTriangle
    (chart seems to cut the graphic short so it’s a blunt arrowhead)
  • Lines

Crossing (double)

The value indicates where you want the axis to cross. If you want the X axis to cross the Y axis at a certain value, you would insert the Crossing property on the Y axis. A “double” is a numeric value for where the axis is ti be crossed.

Note: Some additional values are available on the Axis property, but these dot seem to work MS CRM Dynamics 2011 Online. Those values are “MinValue” and “MaxValue“.

Example. If I have a chart displaying the average survey result per day and the results are based on a scale from 1-6, the standard chart would look like this.

But to make it easier to get an understanding of the results I can change the crossing of the Y axis to the neutral point of my scale, which is 3.5. (Since the survey scale is from 1-6, the midpoint is 3.5)

Hence I’ll add

Crossing=”3.5″

to my Y axis properties, which after import would result in this chart.
Note: On Bar Charts the Y axis is horizontal.

Now it is easier to evaluate the results, just by the direction the bar goes. Good feedback is on the right and the poor is on the left.

Unfortunately the dates are also displayed in the middle of the chart cluttering the information and making some of the data unreadable, but we can fix that.

IsMarksNextToAxis (True, False) – part of Crossing property

Luckily the Crossing property has a related property called “IsMarksNextToAxis“.
IsMarksNextToAxis is a True or False property. This one is a little tricky. I applied the crossing to the Y axis, and by doing that I moved the X axis. That means it is now the marks on the X axis that I want to move.

So between the AxisX tags I will add

IsMarksNextToAxis=”False”

and after import I’ll have this chart.

I can still do some tweaking of the axes here, but we will get to that later in the property list.

The IsMarksNextToAxis will only work on a chart where the “Crossing” property has been added. And remember, “Crossing on X axis, move Marks on Y axis and vice versa”.

Enabled (Auto, True, False)

“Enabled” refers to  whether or not the axis is enabled. Charts will by default always show the axis if it has data and is part of the chart, but if you wish can turn it off entirely by setting

Enabled=”False”.

It basically toggles visibility. Sample of an X axis with Enabled=”False”.

Not sure when exactly when this would be used, but you can if you need to.

IsInterlaced (False, True) and InterlacedColor

The IsInterlaced and InterlacedColor is a simplifed version of StripLines, but will probably cover most basic needs. IsInterlaced is by default set to False and you only need to add it if you want to turn on the function. Setting

IsInterlaced=”True”

will shade every other background banner on the chosen axis in gray.

If you want ot change the color, use the

InterlacedColor=”insert color”

property. Note that you are only changing the color of every other interval. The other one will remain white.
Read more about using colors here.

Also note the height of the interlace banners are based on the interval on the Y axis. This interval can be modified too, but more on that later.

IsLogarithmic (False, True) and LogarithmBase (double)

Charts support a logarithmic scale in case you need. By default IsLogarithmic is turned off, but you can add the property and set its value to “True”.

IsLogarithmic=”True”

The logarithmic scale is by default set to “10”, just like a typical scientific calculator. Should you need to change add

LogarithmBase=”insert value”

and insert the number you need. Not sure when this would be needed in CRM, but good to know 🙂
If you have a good example, please leave a comment!

IsMarginVisible (True, False)

All charts have their margin visible (true) by default. The setting determines if the chart should leave some extra space around the highest datapoints of the series.

Standard
IsMarginVisible=”True”

IsMarginVisible=”False”

Notice that the columns get much closer to all the edges without the margin. There’s aso more space between the columns. This could prove more useful in situations where you don’t have much room to display the chart.

These examples show the same chart, but generated on a narrower space.

IsMarginVisible=”True”                       IsMarginVisible=”False”       
These two chart have been generated on a window with the exact same size, but the one without the margins seems to utilize the space better.

IsReversed (False, True)

In case you need to reverse an axis, you can set the IsReversed=”True”. This creates some significantly different looking charts. This feature could come in handy too on other chart types such as Radar.

IsReversed=”True”

on the Y axis

IsStartedFromZero (False, True)

In case you have some series that have similar high values, you can set the IsStartedFromZero=”False”, so instead of having a set of columns of almost the same height, you can emphasize the difference by starting at a different value. Its an automatic setting so the chart will decide which value to start at. Often very close to the lowest value. A little too close to my taste.

Default setting

IsStartedFromZero=”True”

IsStartedFromZero=”False”

Notice the lowest value on the Y axis is now 110,000.

LineColor (color)

LineColor seems obvious, but exactly what line is it referring to?
In this example I’ve inserted the

LineColor=”Red”

on the Y axis.

Notice that it is only the line itself that is being colored, as well as the ArrowStyle if one is applied. The default line color is black, but Dynamics CRM 2011 seems to always set the line color to this grayish setting LineColor=”165, 172, 181″.

More on setting colors here.

LineDashStyle (Dash, DashDot, DashDotDot, Dot, Solid, NotSet)

Note that in these examples the the line color has been set to black.

  • NotSet – there is no line
  • Dash
  • DashDot  
  • DashDotDot
  • Dot
  • Solid  (used as standard)

LineWidth (integer)

LineWidth specifies the width of the axis line. Just the line and none of the markers. The default is LineWidth=”1″. Note that any setting here also have an impact on the ArrowStyle property if used.

Minimum, Maximum (doubles)

The Mininum property is always set to 0 unless your data contains negative values. Then the lowest value will used. Use

Minimum=”10″

, if for example you want to start your axis at the value 10.

The Maximum property works in the same manner, and these can be useful particularly with charts that handle surveys or other evaluations where you use a scale. I.e. from 1-10. Depending on your responses your axis may go to 5 or 12, but would probably rarely end at 10 specifically.

An example may look like this.

If my survey was using the 1-10 scale, I would want that displayed on my Y-axis (on bar charts the Y axis is horizontal. Get used to it). In this case I would set the Minimum value to 1, as that is my lowest value, and the maximum value to 10. I want to see how far the responses are from the top.

Same chart, but the axis change clearly paints a different picture.

IsLabelAutoFit (True, False)

The IsLabelAutoFit property is True by default and controls how the auto-adjustments handles the labes when your chart is being resized in the window.

The property refers only to the values and series names that are on the axes. It does not handle the axis titles.

With the

IsLabelAutoFit=”True”

property on the axis, three other properties can be applied as well. Note that you do not have add the IsLabelAutoFit=”True”. If it is not present, the chart engine will assume the value is true. The first 2 handles the minimum and maximum font sizes.

  • LabelAutoFitMaxFontSize (integer – minimum value is “5”)
  • LabelAutoFitMinFontSize (integer)

If you use both Min and Max auto fit sizes, then also minimum size must be 5 or higher. It can be lower if used alone.

  • LabelAutoFitStyle
    (None, IncreaseFont, DecreaseFont, StaggeredLabels, LabelsAngleStep30, LabelsAngleStep45, LabelsAngleStep90, WordWrap)

Now LabelAutoFitStyle gives us some more options on how the labels are written.

  • LabelAutoFitStyle=”None” – the default option and this is how the charts usually work
  • LabelAutoFitStyle=”IncreaseFont” – bumps up the font a little.
  • LabelAutoFitStyle=”DecreaseFont” – bumbs down the font size a little. Both font setting have a subtle, but noticeable change. Is useful when wanting to control font sizes, but still want them to scale nice according to the chart.
  • LabelAutoFitStyle=”StaggeredLabels”

    Layers the labels in rows making room for all of them.
  • LabelAutoFitStyle=”LabelsAngleStep30″

  • LabelAutoFitStyle=”LabelsAngleStep45″

  • LabelAutoFitStyle=”LabelsAngleStep90″

  • LabelAutoFitStyle=”WordWrap”

Common for staggered, angled and wrapped labels is that the property only applies if there isn’t enough room on the axis to display it normally. Since charts out of the box chooses the auto style that seems to fit the best between wordwrap and staggered, these properties should primarily be used if you want to dictate which one should be used, or if you want to force the use the angled labels instead.

These are all autostyles, meaning we can only control so much. If you want full control over how the labels are presented, you should use the LabelStyle property, instead of of the LabelAutoFitStyle property, but more on that one in part 2 of this blog post.

ToolTip (string)

ToolTips can be very helpful as they allow you to elaborate or comment on the axis. The text (string) added to the

ToolTip=”insert text string here”

will be shown to the Dynamics CRM user when the hover their mouse anywhere over the axis area. The tooltip can be added to each axis as necessary.

If the ToolTip property is not used, the chart will display the Title of the axis instead. Unfortunately there doesn’t seem to be a way to disable the ToolTip. If you do not want the ToolTip repeating the Axis title when hovering over it, you either have to set a different ToolTip or just insert “.” or some other small character.

Title (string)

Dynamics CRM always names the axes something like “Sum (Est. Revenue) ($)” or “Territory Name(Territory)”. To replace with something shorter and perhaps more appropriate and easier for the user to understand, use the Title property.

So if we wanted the X axis to just say “Territory” rather than “Territory Name(Territory)” we would set

Title=”Territory”

on the AxisX.



Much better.

TitleAlignment (Near, Center, Far)

The TitleAlignment property determines how far from the axes crossing that the title is displayed. By default it is set as

TitleAlignment=”Center”

  • TitleAlignment=”Near”
  • TitleAlignment=”Center”  (default)
  • TitleAlignment=”Far”

TitleForeColor (color)

This property sets the text color of the title. The default is black, but CRM usually overrides it with a very dark gray (59, 59, 59). The property is using the same color properties as the rest of the chart, so you can enter RGB, hex and the color names. More on colors here.

Hiding the title (not really a property)

There’s no property for not displaying the axis name, so if you want to hide it, set the color as TitleForeColor=”Transparent” and make the font as little as possible to take up less space.

Also note that if there are two series displayed on the same axis, then the system generated sometimes leave out the title on the chart. In this case you have to use the Title property in order to display the Title.

TitleFont (font)


The TitleFont always seems to be a part of the xml schema when you export. If you want to adjust the size of the font, change the font size from 10.5px as needed. It is possible to use point sizes rather pixel height instead. Just replace “px” with “pt“.

TextOrientation (Auto, Horizontal, Rotated90, Rotated270, Stacked) – for axis title only

The TextOrientation property is only for the axis title even though it is not mentioned in the property name.

For the Y axis they look like this (same order as listed above)

Auto and Rotated270 are similar on a standard Y axis. Rotated90 displays the title in the other direction. Horizontal makes it more easy to read, but also uses a lot more space on the axis. The last, stacked, seems like it would only be useful for a very very short title or individual numbers that needs to be listed.

For the X axis they look like this


Auto and Horizontal settings are identical and seems to make the most sense for a horizontal X axis.

Particularly I can’t seem to think of any good use scenario for Rotated90, Rotated270 and Stacked on the X axis since they come out like this.

It is worth noting that the Rotated90 and Rotated270 are degrees of clockwise rotation from a horizontal starting point, even if the chart by default displays the title vertically.

Interval

The interval between the labels on the axes have an auto setting, adjusting the interval to the current size of the chart. If you need to display a specific interval on an axis, use the interval property to adjust it. If you want to display every single value use Interval=”1″, assuming that your axes is based on a whole number. Note that this interval is also used by the IsInterlaced property and can therefore be used to control the height of the interlacing lines. Particularly useful if you are trying to emphasize certain intervals.

Y Axis with Interval=”1″ and Interval=”10″
 
The Interval property will override the IntervalAutoMode property if used.

There’s also an IntervalType property, which is to indicate if the axis is numbers or a date grouping (Days, Weeks, Months, etc.). However, this property does not seem to help as the auto settings always match the data set made in the fetch collection. Setting the IntervalType will not help, but only cause problems if it does not match the series that is beign presented. So my advice is to not use IntervalType.

IntervalAutoMode (FixedCount, VariableCount)

This property is supposed to control whether or not the chart dynamically calculates the interval on axis. However, the charts do that even if the axis has been set to FixedCount. Since the Interval property mentioned above will override this property regardless, it seem a bit of a moot point to be using it in Dynamics CRM charts.

IntervalOffset (double) 0 is same as Auto

Use the IntervalOffset property when you want you skip a certain amount of label points. The value used in the property is the same as the first label you want to displayed. Inserting zero will give you the same result as Auto.

If

IntervalOffset=”5″

when the first label on the axis is 5.

If you are working with dates, you have to add the IntervalOffsetType property to your axis as well. The IntervalOffsetType property has to be the same type as your dategrouping the fetch part of hte xml. (Days, Weeks, Months, etc.) Note: The date types here are plural, but in the dategrouping they are singular.

If we set IntervalOffSetType=”Days” and Interval=”3″, then the first label on the axis will be the third day in the series.

Next chapter

That was it for the simple axis properties. Look back for part 2 in this blog series where I will focus on the axis modification that comes with their own set of extra properties. They are, LabelStyle, MajorGrid, MajorTickMark, MinorGrid, MinorTickMark, ScaleBreakStyle, ScaleView and StripLines.

  1. #1 by Diogo Fortes on February 19, 2013 - 10:49 am

    hi charts guy, great post, very complete. But i have a question that maybe you can help with. In a Date and Time format when we are grouping by month, it’s possible to show only the month instead of month/year???

    • #2 by crmchartguy on February 19, 2013 - 4:33 pm

      Thanks Diogo. Unfortunately Date and Time format on the axes seems to be controlled by the Users personal Date Format settings in the Option menu, rather than what LabelFormat you throw at it in the xml file. So pretty much all you can control through the Options Menu, is whether or not it’s Month/Year or Year/Month. If I ever find a solution I’ll be sure to write about it 🙂

      • #3 by Diogo Fortes on February 20, 2013 - 4:35 am

        It’s really a pity. Anyway thank you so much for the reply 😀

  2. #4 by Ryan on February 19, 2013 - 11:15 am

    This is simply and outstanding list of chart customizations all located in one spot. Thank you so much for putting the time and effort into this.

  3. #5 by Gaby on April 24, 2013 - 10:54 am

    Hi charts guy, I need to make a chart and put in the x-axis the Organizer of the appointment, can you tell me how to use one field that do not appear on the basic options.?

    • #6 by CRM Chart Guy on April 25, 2013 - 8:23 am

      You probably can’t unfortunately. Organizer is a “Party List” type field, which can contain several values, so you can’t chart on it. Although Organizer never have more than one record, it’s still limited by its field type.

  4. #7 by schoppej on May 17, 2013 - 10:22 am

    I can’t tell you how much you’ve already helped me build better charts in Dynamics! Without this resource I would definitely be stuck. I apprecaite it greatly! I’m now running into a couple things that I hope you can help with.. First I’m trying to show numbers currently set up as 1,450,000,000 in this format.. 1.45B. You’ve helped be with a similar issue before, but I can’t get this to format correctly. The second problem I’m having with this same chart is aligning the legend with the chart. I have a stacked bar chart that shows Production and Assets in that order. Production is in blue and Assets in Red. My problem is the legend is reversed. It shows Assets first and production second. I just want them to align to make it easier to read. The users I’m designing this for are pretty particular. Thanks again. You’re a huge help.

  5. #9 by Bernie Lipka on December 5, 2013 - 4:34 am

    Chart guy – this has been a very valuable tool. It would be much better if I had a schema that worked. I recieve errors loading the CRM visualizationdatadescription.xsd schema. (from SDK) What do I need to do to fix it?

  6. #10 by Martin on January 31, 2014 - 7:22 am

    Again another great post! Any chance of looking into LabelToolTip for the next Axis modification 2 post? This is set by CRM and is dynamic so that it shows the value for that specific series and datapoint. Like [Month (Start) : Jul 2013, Sum (Time) : 178] Can you change the syntax to i.e. [Series Name, DataPointYValue]? I guess, the question is if there is a syntax for this as there is to LabelFormat?

  7. #12 by Jeremy on April 14, 2014 - 8:09 am

    Am i able to have multiple labels formats on an axis? I.E. If the # is in the thousands, i want it like this ($#,0,K), when it gets to millions ($#,0,,M), i want it like this. Is that possible? I want 350,000 to look like 350k, then when it gets to 1,300,000, i want it to look like 1.3m.

  8. #14 by Oscar on September 11, 2014 - 2:02 pm

    Great article!! Can I use multiple colors per series? Please let me know if this possible, even if i have to create the chart with code.

  9. #15 by Mike Denovellis on November 14, 2014 - 7:14 am

    Hi, could you advise whether it’s possible to achieve this? http://i57.tinypic.com/w2hzq1.png

    Essentially what I want is the horizontal axis grouping the ‘method of closure’ i.e whether a case has been resolved by remote control, by telephone, or from an on-site visit, but for each month of the year. I’ve spent hours trying to get this working, to no avail…I guess i just want to know whether it’s actually possible to do so?

  10. #16 by Greg Deckler on January 19, 2015 - 9:06 am

    Fantastic article. I read through the whole thing and was not able to find an answer to this question. Is it possible to add information to the “hover” action over a data point maker on the chart. So, these by default display the X and Y labels for the data point but I would also like to add the “group by” information as well.

  11. #18 by Anders Loken on March 20, 2015 - 6:02 am

    I’ve been using your posts a lot, and been able to do quite a lot of cool and useful charts for our company. But I am wondering if it is possible to get decimals on averages? I have a scale from 1-5 and want to use a chart getting the real average per issue. But they round up in the charts to the nearest full number. It is a big difference from an average of 3,51 and 4,49, but they all come out as 4. I have edited both the format of the Y axis and the Labelformat, but to no prevail. Any help would be appreciated.

    • #19 by CRM Chart Guy on March 20, 2015 - 10:09 am

      Hi Anders. Thanks for reading.
      It’s probably because your field is a whole number rather than a decimal number. For whole numbers use the keyword Label=”#AVG” instead of the format on the relevant series and set the IsValueShownAsLabel to false. You can’t format the keyword either and it is giving you quite a lot of decimals, so it is either or. Alternately you can replace the whole number with a decimal number field if that is an option. That will give you more flexible formatting options. There’s more about using keywords in the Pie chart post.

      • #20 by Anders Loken on March 22, 2015 - 5:58 am

        Thank you. Mot helpful. Seems we should investigate including a value field with decimals instead, to make it work properly. But a “half-fix”. Thanks, and keep up the good work.

  12. #21 by Nithin Paul on August 19, 2015 - 11:28 pm

    Hello i need to show min and max values in my range bar on each end, how do i do it?

  13. #22 by Florian Schwarzer on June 13, 2016 - 7:54 am

    Hello CRM Chart Guy,

    I have a Line diagram and want to swap the x axis with the y axis. How can I accomplish it?
    I have made a post at stackoverflow and Microsoft Dynamics community but don’t get any answers. Here is a link with detailed information:

    http://stackoverflow.com/questions/37791703/microsoft-crm-2016-chart-swap-x-and-y-axis

    Thank you,

    Florian

  1. Removing Axis Titles, Legend and Axis Labels in CRM Charts for MS CRM 2011 | crm chart guy
  2. Everything ScaleBreak in MS CRM 2011 Charts | crm chart guy

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

%d bloggers like this: