2014年7月13日 星期日

[RESOLVED] Pie Chart Labels


When a pie chart slice represents a small amount, the label tends to touch or over write another slice's label.


In essence they are touching.


I know I can move the label outside of the pie chart, but I prefer them inside. Is there a way to scatter the labels so they don't butt up against each other?



Hi StrangerMike,


These are a number of possibilities for keeping your labels from overlapping:



  • First try decreasing the font size, or increasing the size of your chart to allow more room for the labels.
  • Pie and Doughnut charts have the ability to collect smaller slices into one, We have samples that show how this is done: in our samples environment, go to Gallery >> ChartTypes >> Pie and Doughnut Charts, and see "Collecting Small Pie Segments" and
    "Supplemental Pie Charts" (in Windows Forms) or "Collecting Pie Slices" and "Pie Chart Small Segments" (in ASP.NET.)

  • If the above options do not work, or you would prefer not to change your chart in those ways, set the Series custom attribute PieLabelStyle to "Outside", so that point labels are positioned outside of the pie/doughnut with connecting lines. Right-click
    the Chart and choose Properties, open the properties for your series, and find the custom attributes. You can also use code like this:


[C#]
Chart1.Series[0]["PieLabelStyle"] = "Outside";

[VB.NET]
Chart1.Series(0)("PieLabelStyle") = "Outside";

However, you may still find that your labels overlap:


If your labels still overlap, you can spread them out by setting theChartArea's Area3DStyle.Enable3D property to True, and adjust theArea3DStyle.XAngle property to 0 or a low value to make the Chart look 2D. You can do this in the wizards, from our properties settings, or with code:


[C#]
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ChartAreas[0].Area3DStyle.XAngle = 10;

[VB.NET]
Chart1.ChartAreas(0).Area3DStyle.Enable3D = True
Chart1.ChartAreas(0).Area3DStyle.XAngle = 10

or else,


You can play around with following code:


Chart1.ChartAreas(0).AxisY.LabelStyle.TruncatedLabels = False

Chart1.ChartAreas(0).AxisX.LabelStyle.TruncatedLabels = False

Hope this helps.


Thanks,


Jatin





Thanks jats_ptl



Glad Mike that I could help you.. Smile


沒有留言:

張貼留言