I want to hide a Visualforce Chart if there are no data points. Since PieData is a list of data points, why can I not use the style below?

<apex:page Controller="PieChartController" rendered="{!Piedata.size() > 0}">

Example chart from Salesforce Documentation:


public class PieChartController {
public List<PieWedgeData> getPieData() {
    List<PieWedgeData> data = new List<PieWedgeData>();
    data.add(new PieWedgeData('Jan', 30));
    data.add(new PieWedgeData('Feb', 15));
    data.add(new PieWedgeData('Mar', 10));
    data.add(new PieWedgeData('Apr', 20));
    data.add(new PieWedgeData('May', 20));
    data.add(new PieWedgeData('Jun', 5));
    return data;

// Wrapper class
public class PieWedgeData {

    public String name { get; set; }
    public Integer data { get; set; }

    public PieWedgeData(String name, Integer data) {
        this.name = name;
        this.data = data;

2 Answers 2


There is a syntax issue in your code, your condition will work if you make a small change.

<apex:page ... rendered="{!Piedata.size() > 0}">

This will not work as it is not a formula as required in VF page.

Change it to. <apex:page ... rendered="{!Piedata.size > 0}">

You can also use .empty property as well <apex:page ... rendered="{!Piedata.empty}">.


Change to rendered="{!Piedata.size>0}"

You must log in to answer this question.

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