MS Chart consists of different elements (like titles, legends, chart areas, …) which all share the same space in the chart. It is easy to make a ‘perfect’ layout of these elements when you know exactly how many you will have and what size they going to be. It can be challenging when the content of these elements is dynamic and their size may change significantly. Today we will discuss how we can improve different aspects of the Chart elements layout.
Examples
First of all, let’s start by looking at several different charts before (left) and after (right) we applied our layout improvement rules.
Example 1: Legend position was changed from Bottom to Right and its’ width was truncated.
Sample 2: Title font was reduced and legend position switched from Bottom to Right.
Sample 3: Vertical axis labels were limited to 30% of the chart width.
Sample 4: Bottom axis long labels are truncated and vertical axis labels are shown in thousands.
Sample 5: Labels are shown only for the largest 7 slices in the Pie.
Legend
The most common issue with the Legend, is that it can take significant amount of chart space and can make the actual chart data difficult to read. Here are things that can improve legend layout:
Title
If chart title content depends on the dynamic data, its’ size can grow unpredictably and interfere with the data we are trying to shown in the chart. This is very similar with the Legend issues described above.
Axis Labels
A single very long label can make chart very hard to read.
Pie Labels
Pie chart type is not the best visualization if you need to display many (>10) data points. It is hard to read and if you enable data point labels, there is a high chance that they will start overlapping. If you have to us the Pie chart it makes sense to show labels only for the largest slices in the pie.
How to use?
All these rules are implemented and can be automatically applied using ChartLayoutUtilities add-on. Attached project contains ChartLayoutUtilities class and a sample Web Form. Just create an instance of this call passing reference to the chart control!
Alex.