Better Dashboards

Working with Microsoft enterprise chart, dashboard and reporting technologies.

Overlapping Labels on a Pie Chart

Posted by milang on January 20, 2009

When you first create a pie chart in Visual Studio, the result may look like this:

piechartlabel1

That’s not very helpful so you’re going to need to show labels outside of the pie chart.  The smart labels algorithm for the chart does not work for any type of accumulation chart (pie, doughnut, funnel or pyramid).  To show labels outside of the pie, you’ll have to set a weird set of properties:


// Set the PieLabelStyle custom attribute to the value of "Outside"
Chart1.Series[0]["PieLabelStyle"] = "Outside";

// By default, the callout lines will not be drawn unless you set a color for the series border
Chart1.Series[0].BorderWidth = 1;
Chart1.Series[0].BorderDashStyle = ChartDashStyle.Solid;
Chart1.Series[0].BorderColor = System.Drawing.Color.FromArgb(200, 26, 59, 105);

The resulting chart looks like this:

piechartlabel2

Okay not bad, but there are still some overlapping labels, because there are a few points which are very small. At this point, you can collect the small slices into one slice, or you can use a really tricky workaround – set the chart to 3D with zero inclination. That will redraw the entire chart area, and the extra space will be used to label the pie chart.

piechartlabel3


// Set the pie chart to be 3D
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;

// By setting the inclination to 0, the chart essentially goes back to being a 2D chart
Chart1.ChartAreas[0].Area3DStyle.Inclination = 0;

Of course, one of the reasons for the pie labeling issues is because I have more than five points on a pie chart, which tends to cause the pie chart to become unintelligible fairly quickly. This is one reason why there is a fair amount of controversy surrounding pie chart best practices.

Also, check out the MSDN documentation for the Reporting Services version of how to display labels outside the pie chart.

Advertisements

13 Responses to “Overlapping Labels on a Pie Chart”

  1. Rich said

    Um…wow. This is exactly what I wanted. Each time I was about to scroll down the page I thought to myself…it would be great if this covered…oh, it does!!

    Thanks ever so much.

  2. butt said

    Really helped… nice tutorial… worked like a charm

  3. ganesh said

    Awesome

  4. Jason said

    This blog post is made out of pure awesome. I’ve been (reluctantly) using SSRS for years, and I’ve never been able to get pie chart data point labels to layout without overlapping, they way I imagine they should by default, until I found this post. Well done and well explained. This is still a problem in 2008 R2 and your apporach still works.

  5. debarupa said

    Thank you soooo very much!!

    I have been trying to find how to make the lines appear from this morning (now it’s 4 pm) and did not find any solutions. This is first solution that I found that does exactly what I was looking for.

    Thanks again!

  6. qw said

    Simply Superb..:)

  7. rajeshwaran said

    Very Very Useful
    I need to Overlap the Image instead of label can anyone help me???

  8. Rick said

    You saved my day! 🙂

  9. Phuong said

    Hi,
    This was our solution for pie charts not overlapping but since we moved our ssrs reports to sharepoint 2010, the colors of the pie chart are all greyed out possibly due to the inclination being set to 0.
    Does somebody has a solution to have the pie chart color going back to normal.
    Many Thanks

    • I also have the same problem.. to work around temporarily, I have set rotation and inclination to 30% to make the colors look a bit live

    • Shv said

      Hi Phuong

      I encountered the same issue where pie chart colors turned pale on enabling 3D with 0 rotation and 0 inclination. To fix this follow the steps below:
      1. Disable 3D effect.
      2. Go to Chart Area properties — > Area3DStyle section –> Shading property. Set this to “Simple”
      3. Enable 3D effect with 0 rotation and 0 inclination.

      Your pie chart colors remain the same and do not turn pale.

      Thanks.
      Shv

  10. Raheel said

    Great Tutorial Thanks u make my life easy

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: