Better Dashboards

Working with Microsoft enterprise chart, dashboard and reporting technologies.

Posts Tagged ‘Bar Charts’

Show All Skipped Labels on the X-Axis

Posted by milang on January 11, 2009

Just about everyone who has worked with category names on the Microsoft Reporting Services or .NET chart has encountered this problem: you databind categorical values from a database, but when it is displayed on the chart, it skips labels on the x-axis, like below:


How Do I Show All Labels on the X-Axis?

The short answer is, set the Interval property on the x-axis to 1:

// Show all labels on the x-axis
Chart1.ChartAreas[0].AxisX.Interval = 1;

Issues Created by Solving the X-Axis Label Issue

Showing every x-axis label produces the intended effect of matching every name to a data point, but it also causes clutter if there are too many points or the names are too long.  For example, look at what happens when I databind first and last names of each sales person:


It gets worse if I show all sales people instead of the top 10:


One satisfactory solution is to change the chart type to Bar:


This is a cleaner version of the previous chart, with the category labels more intuitively placed on the chart.  If you’re going to use this solution, make sure you change the appropriate properties for the axes, since the x-axis and y-axis are reversed on a bar chart.

The x-axis skipping label issue tends to be a catch-22 for developers.  It usually does not make sense to show every individual date along a financial chart if you are trying to graph a six-month trend of a particular stock price; in this case, you actually want the chart to skip labels.  On the other hand, if you are showing sales performance by salesperson on a chart, there is no way you want any of those people skipped to simplify the trend of the chart.

For more information on implications of skipping axis labels, see:

Also, if you are using the SSRS chart, you might want to consider implementing the really cool TableInlineCharts solution from Robert Brucker’s whitepaper:


Posted in .NET Chart, SQL Reporting Services | Tagged: , | 20 Comments »