Chart Optimization Tips

AID: 1644
  • Status: Published

12100 points

  • ByValentinoV
  • TypeTips/Tricks
  • Posted on2009-09-26 at 11:07:51
Awards
  • Community Pick
  • Experts Exchange Approved
Here are some optimization techniques that can be used when creating charts in SQL Server 2008 Reporting Services.  These tips will probably be already known to experienced chart developers, but freshmen charters may spent some time searching how to achieve something before actually finding it, if finding it at all.  I know because I've been there myself when I started out and I also know because I've seen questions on forums related to this.

Okay, enough vague intro-words, let's get concrete now.  In the following example I'll be creating a regular column chart.

1

X-axis: show all labels


By default, a chart in SSRS will automatically position the labels on the X-axis as it best fits.  However, one of these options includes hiding labels when the chart feels there are too many to show.  As you can guess, this is not always what we want.
 
image01.png
  • 39 KB
  • Column bar chart without any changes to its default settings
Column bar chart without any changes to its default settings

Have a look at the chart above and try to guess what you're seeing.  Difficult, huh?  Let's make some changes to it.

First we start with some basics like giving it a clear title.  This chart shows the annual revenue per state/province, split up by store specialty.  The states or provinces shown are those of the selected country.  I would call it "Annual Revenue per State/Province by Specialty for <SELECTED_COUNTRY>".  As you probably know, the chart's title can be edited by giving it a single-click.  However, this does not give you the option to build an expression so unless you want to type it all from memory, here's another option.  You can right-click on the chart's title.  This gives you a pop-up menu with Title Properties... as one of the options.
 
image02.png
  • 3 KB
  • Right-click menu on chart title
Right-click menu on chart title

Selecting that one will give you the Chart Title Properties where you have the familiar Expression Builder icon next to Title Text textbox.
 
image03.png
  • 48 KB
  • Chart Title Properties
Chart Title Properties

This is my expression:
="Annual Revenue per State/Province by Specialty for " & Parameters!Country.Value
                                    
1:

Select allOpen in new window


Also, let's move the legend to the upper middle to make extra horizontal space for all those bars.  This can be done through the Legend Properties.
 
image04.png
  • 52 KB
  • Legend Properties
Legend Properties

Lastly, now that we've freed up some space for the chart area, we'll modify the X-axis properties so that it shows all labels.

When opening up the axis properties for the X-axis on a column chart you get the Category Axis Properties screen.  Like all other property screens, this is also one with several pages.  You see that one of the pages is called Labels and as you want it to show all labels, that's were you start looking.  Well, stop looking, that's the wrong place.  The option that you need is located in the first page, the Axis Options, and its called Interval.  This is the interval between each label on the axis, and by default it is set to Auto.  As we want all labels, change it to 1.
 
image05.png
  • 85 KB
  • Category Axis Properties
Category Axis Properties

Following screenshot shows what the result looks like:
 
image06.png
  • 60 KB
  • Column chart showing all labels on category axis
Column chart showing all labels on category axis

Better, but we're not quite there yet.

2

X-axis: rotate labels in all directions


Right now the labels on the X-axis are difficult to read unless we turn our screen 90 degrees clockwise.  Let's dive again into the Category Axis Properties to put them diagonally.  On the Labels page there's an option to specify the Label Rotation Angle.   To be able to do this you need to activate the Disable auto-fit radio button.  Putting 45 as value will give the following:
 
image07.png
  • 4 KB
  • Labels rotated 45 degrees
Labels rotated 45 degrees

The labels are rotated 45 degrees.  But not in the direction that I would prefer.  It's nicer when they're positioned from bottom-left to top-right.  So you start increasing the rotation value.  However, once you're past 90 you notice that the labels stay vertically, so 135 degrees does not put them in the direction as you'd hoped.  The answer is quite simple, once you know it.  As we want the opposite of our 45 degrees, and it's not 135, try -45 :-)
 
image08.png
  • 73 KB
  • Category Axis Properties with Label rotation angle set to a negative value
Category Axis Properties with Label rotation angle set to a negative value

Indeed, that gives the following result (I've also removed the X-axis title).
 
image09.png
  • 62 KB
  • Column chart with optimized X-axis
Column chart with optimized X-axis

To finalize the X-axis optimization, I've added sorting so that the States/Provinces are sorted alphabetically.  This is a recommended design practice to keep your different charts consistent.

To get the labels sorted, you should not look into the Axis properties but in the Category Group Properties:
 
image10.png
  • 26 KB
  • Pop-up menu to get to the Category Group Properties
Pop-up menu to get to the Category Group Properties

On the Sorting page just add the field that's shown on the X-axis.
 
image11.png
  • 23 KB
  • Category Group Properties with sorting
Category Group Properties with sorting


3

Y-axis: make numbers readable


So, now that we're done with the X-axis, let's move on to the next letter of the alphabet.  Our Y-axis (also known as Value Axis on a column chart) is not very readable at the moment.  The numbers are too large and there's no formatting.  You don't even see that this is a currency value.

This time we need the Number page of the Value Axis Properties.  We want:

  • no decimals

  • a thousands separator

  • the numbers divided by 1000 (that's the "Show values in" setting)

  • a dollar sign in front of the value

To get all this, you can set the options as shown in the screenshot:
 
image12.png
  • 76 KB
  • Value Axis Properties optimized for large currencies
Value Axis Properties optimized for large currencies

And here's our chart again:
 
image13.png
  • 54 KB
  • Chart with optimized Y-axis
Chart with optimized Y-axis

Additionally, the axis title has also gotten a clear value.  It indicates how the values should be read.

4

Y-axis: move to right-hand side


To conclude this article I'll show you how to move the Y-axis to the other side of the chart.  This may seem like an odd thing to do, but sometimes the business people want to display a chart that way so you'd better have strong convincing skills or know how to do it.  Or both :-)

In fact, a chart has got two Value axes and two Category axes, a Primary and a Secondary.  The Primary axes are the ones used right now.  To move the visible axis to the other side, it's not through the Value Axis Properties as you might think (I think you're getting the hang of it now, right? ;-).  No, all you need to do is move all data series to the secondary axis.  This can be done through the Series Properties.
 
image14.png
  • 9 KB
  • Pop-up menu on data series
Pop-up menu on data series

The Axis and Chart Area page is the one you're after.
 
image15.png
  • 55 KB
  • Series Properties with Secondary Value axis activated
Series Properties with Secondary Value axis activated

That will give us the following end result:
 
image16.png
  • 59 KB
  • Column chart with Y-axis on the right-hand side
Column chart with Y-axis on the right-hand side

BTW: you will need to re-do the axis formatting when you switch to the secondary axis so better start with axis activation before formatting it.

Ow, if you found this article to be helpful, don't forget to click the "Yes" button below.

Thank you for reading my article, and happy charting!

Valentino.
    Asked On
    2009-09-26 at 11:07:51ID1644
    Tags

    SQL Server Reporting Services 2008

    ,

    chart

    ,

    SSRS

    ,

    Reporting Services

    Topic

    MS SQL Reporting

    Views
    8197

    Comments

    Expert Comment

    by: SQLNewBieUSA on 2010-12-04 at 16:01:50ID: 21855

    Great Explanation.

    How can we achive same functionality in SSS 2005 ?

    My requirment is to display X-Axis lable in Vertical Way.

    Thanks.

    Author Comment

    by: ValentinoV on 2010-12-06 at 00:34:21ID: 21892

    Out-of-the-box you can't do that in SSRS 2005.

    From http://msdn.microsoft.com/en-us/library/aa964128%28SQL.90%29.aspx:

    "Currently, built-in Reporting Services charts only allow automatic positioning in order to avoid overlapping the x-axis labels. The label direction (horizontal/vertical) of the axis labels depends on the label string sizes and the available space. X-axis labels are either shown horizontally in one line, horizontally in multiple lines with line breaks, or vertically. Showing x-axis labels at an angle, or explicit manual control over individual x-axis label positions is currently not supported. "

    Expert Comment

    by: huslayer on 2010-12-08 at 09:06:32ID: 21950

    Wonderful article, great work and effort, thanks for taking the time to put ALL OF THAT together :)

    God bless you for sharing the knowledge...

    Author Comment

    by: ValentinoV on 2010-12-09 at 06:23:05ID: 21957

    Thanks for the praise and vote :-)

    Expert Comment

    by: OneBlogger on 2011-02-19 at 06:00:15ID: 23979

    Great article and great tips, i have spent lots of hours to make some good graphical reports ...

    A high tech blog and SQL Server

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Join Experts Exchange Today

    Gain Access to all our Tech Resources

    Get personalized answers

    Ask unlimited questions

    Access Proven Solutions

    Search 3.2 million solutions

    Read In-Depth How-To Guides

    1000+ articles, demos, & tips

    Watch Step by Step Tutorials

    Learn direct from top tech pros

    And Much More!

    Your complete tech resource

    See Plans and Pricing

    30-day free trial. Register in 60 seconds.

    Loading Advertisement...

    Top SSRS SQL Reporting Svc Experts

    1. ValentinoV

      226,820

      Guru

      20 points yesterday

      Profile
      Rank: Genius
    2. huslayer

      108,772

      Master

      20 points yesterday

      Profile
      Rank: Sage
    3. TempDBA

      54,871

      Master

      0 points yesterday

      Profile
      Rank: Sage
    4. Nicobo

      37,600

      0 points yesterday

      Profile
      Rank: Wizard
    5. santhimurthyd

      36,656

      0 points yesterday

      Profile
      Rank: Wizard
    6. SThaya

      31,119

      0 points yesterday

      Profile
      Rank: Master
    7. planocz

      20,826

      0 points yesterday

      Profile
      Rank: Genius
    8. sammySeltzer

      19,700

      0 points yesterday

      Profile
      Rank: Genius
    9. harish_varghese

      18,800

      0 points yesterday

      Profile
      Rank: Master
    10. lcohan

      17,827

      0 points yesterday

      Profile
      Rank: Genius
    11. TimHumphries

      13,046

      0 points yesterday

      Profile
      Rank: Wizard
    12. EugeneZ

      12,950

      0 points yesterday

      Profile
      Rank: Genius
    13. dtodd

      11,600

      0 points yesterday

      Profile
      Rank: Genius
    14. jimhorn

      11,065

      0 points yesterday

      Profile
      Rank: Genius
    15. srikanthreddyn143

      9,900

      0 points yesterday

      Profile
      Rank: Guru
    16. jogos

      9,800

      0 points yesterday

      Profile
      Rank: Sage
    17. HainKurt

      9,732

      0 points yesterday

      Profile
      Rank: Genius
    18. mlmcc

      8,100

      0 points yesterday

      Profile
      Rank: Savant
    19. ScottPletcher

      7,500

      0 points yesterday

      Profile
      Rank: Genius
    20. mwvisa1

      6,501

      0 points yesterday

      Profile
      Rank: Genius
    21. CodeCruiser

      6,250

      0 points yesterday

      Profile
      Rank: Genius
    22. wdosanjos

      5,000

      0 points yesterday

      Profile
      Rank: Genius
    23. Emes

      4,750

      0 points yesterday

      Profile
      Rank: Wizard
    24. Buttercup1

      4,750

      0 points yesterday

      Profile
      Rank: Master
    25. mark_wills

      4,664

      0 points yesterday

      Profile
      Rank: Genius

    Hall Of Fame