1

enter image description here I have created a VF pie chart which is displaying the data dynamically. I need to remove the labels on pie chart which are being highlighted on the attached image as the data with large text is getting overlapped. Here is the code.

Page-

 <apex:pageBlock id="PositionData" >                        
        <apex:chart height="450" width="550" data="{!PieData}" > 
            <apex:pieSeries tips="true" dataField="pdata" labelField="name"/> 
            <apex:legend position="right"/>
        </apex:chart>        
        </apex:pageBlock>

Controller-

 public List<PieWedgeData> getPieData() 
{  
    List<PieWedgeData> pdat = new List<PieWedgeData>();![enter image description here][2]       
    List<Position__c> post = [SELECT ID, Product_New__c, Product__c, Quantity__c, Contact__c FROM Position__c  WHERE Contact__c = :selectedName];       
    for(Position__c temp : post)
    { 
        if(temp.Product_New__c !=null && temp.Quantity__c !=null)
        {
            pdat.add(new PieWedgeData(temp.Product_New__c, temp.Quantity__c));
        }
    }        
    return pdat;  
} 

// Wrapper class  
public class PieWedgeData 
{  
    public String name { get; set; }  
    public Decimal pdata { get; set; }  

    public PieWedgeData(String name, Decimal pdata) 
    {  
        this.name = name;  
        this.pdata = pdata;  
    }  
}
1
  • Can you add the image?
    – Keith C
    Commented Oct 14, 2014 at 8:47

1 Answer 1

3

Try this:

<apex:pieSeries tips="true" dataField="pdata" labelField="name">
   <apex:chartLabel display="none" />
</apex:pieSeries>
2
  • 1
    It worked. Thanks :) Can we also change the chart label to a 3rd field other than Product_New__c and Quantity__c so that instead of Microsoft Common Stock, it should display value of another field. Commented Oct 15, 2014 at 8:58
  • 1
    @SalesforceLearner Check "field" attribute of "<apex:chartLabel>" attribute. From the documentation: The field in each record provided in the chart data from which to retrieve the label for each data point in the series. This field must exist in every record in the chart data. If not specified, this value defaults to "name".
    – Aditi Jain
    Commented Oct 15, 2014 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .