none
How can I remove the value labels of a Pie Chart?

    Question

  • Hello there, 

    I have a Pie chart with a few values, but almost all of them are way smaller compared to one or two of the values.  As a result I get a lot of pie slices grouped together in one side of the chart.  How can I:

      1. Remove the labels in the Pie Chart, so they do not collide? Notice I am showing the labels in a legend, Series.Label= " " will not work
      2. The other possible solutions is, how can I get the value labels out of the chart?

    Thanks, 
    Miguel
    Thursday, January 21, 2010 7:28 AM

Answers

  • you can either not show the label, or you can use CustomProperties like "Explode" and "PieLabelStyle"


    For i As Integer = 0 To Chart1.Series(0).Points.Count - 1
                    
                    If Chart1.Series(0).Points(i).YValues(0) < 20 Then
                        'you can explode the slice and show the value outside the pie
                        With Chart1.Series(0)
                        '.Points(i)("Exploded") = "True"
                        '.Points(i)("PieLabelStyle") = "Outside"
                        '.Points(i)("PieLineColor") = "Red"
    
                        'or you can not show the value
                        .Points(i)("PieLabelStyle") = "Disabled"
                        End With
                    End If
                Next
    • Marked as answer by Miguel Mateo Friday, January 22, 2010 6:27 AM
    Thursday, January 21, 2010 8:01 AM

All replies

  • Hi Miguel

    One way you can do this as Collect the Pie Segments to One Which e. g. Say Which are less than 5 


    series1("CollectedThreshold") = "5"
    series1("CollectedThresholdUsePercent") = "true"
    series1("CollectedLegendText") = "Other"
    series1("CollectedColor") = "Green"
    series1("CollectedToolTip") = "Other"

    Thursday, January 21, 2010 7:46 AM
  • True Sandeep, but I do want to show the labels in the Legend, not to group them as "Others".  

    I have this collection, for example (120, 20, 1, 2, 1) as you see it is just a few samples, but the labels of the last three collide on top of each other and this is what I do not want to show.

    Thanks, 
    Miguel
    Thursday, January 21, 2010 7:51 AM
  • you can either not show the label, or you can use CustomProperties like "Explode" and "PieLabelStyle"


    For i As Integer = 0 To Chart1.Series(0).Points.Count - 1
                    
                    If Chart1.Series(0).Points(i).YValues(0) < 20 Then
                        'you can explode the slice and show the value outside the pie
                        With Chart1.Series(0)
                        '.Points(i)("Exploded") = "True"
                        '.Points(i)("PieLabelStyle") = "Outside"
                        '.Points(i)("PieLineColor") = "Red"
    
                        'or you can not show the value
                        .Points(i)("PieLabelStyle") = "Disabled"
                        End With
                    End If
                Next
    • Marked as answer by Miguel Mateo Friday, January 22, 2010 6:27 AM
    Thursday, January 21, 2010 8:01 AM
  • JWavila, 

    You are a genius, thanks a lot.  Just to let you know that if I do (sorry, C#):

            for (int i = 0; i < OSVersionSeries.Points.Count; i++)
                if (OSVersionSeries.Points[i].YValues[0] < 10) {
                    //OSVersionSeries.Points[i]["Exploded"] = "True";
                    OSVersionSeries.Points[i]["PieLabelStyle"] = "Outside";
                    OSVersionSeries.Points[i]["PieLineColor"]  = "Red";
                }

    Still the values outside of the Pie chart collide, although legible this time.  So I have no choice but to disable the values as you suggested in your second option.

    Is there anyway to tell the chart not to collide the values? 

    Thanks,
    Miguel
    Thursday, January 21, 2010 8:20 AM
  • Hi Miguel You can also do one more thing the Supplement Pie Chart


    Dim pieHelper As New PieCollectedDataHelper()

    pieHelper.CollectedPercentage = 5

    pieHelper.ShowCollectedDataAsOneSlice = False

    pieHelper.SupplementedAreaSizeRatio = 0.9F

    pieHelper.ChartAreaPosition = New RectangleF(5F, 5F, 90F, 90F)

    pieHelper.ShowSmallSegmentsAsSupplementalPie("Default")




    Sandeep Sharma
    Thursday, January 21, 2010 8:26 AM