function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cindy NormanCindy Norman 

Charts won't render in Tab unless...something silly

Is this a bug or am i missing something?

I have a tabPanel and 2 Tabs within the Panel (tabEmpty and tabChart). Unless i have the tabPanel point (eg set selectedTab="tabChart" ) to the Tab with the Chart in it, tabChart, the chart won't show up (it actually shows up but crammed way up into the left corner with just a few pixels showing.)

What am i missing? If you change the selectedTab to tabChart, you'll see it correctly.
Here's the code:

**********the page***************
<apex:page controller="PieChartController" title="Pie Chart">
    <apex:tabPanel switchType="client" selectedTab="tabEmpty" id="AccountTabPanel">
 
    <!--    **************Empty Tab *********************************-->
    <apex:tab label="Empty Tab" name="tabEmpty" id="tabEmpty">
    </apex:tab>

    <!--    **************Tab with a Chart***************************-->
    <apex:tab label="Chart Tab" name="tabChart" id="tabChart">
        <apex:chart resizable="true" height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="right"/>
        </apex:chart>
    </apex:tab>
    
    </apex:tabPanel>    
</apex:page>


**********and the PieChartController controller***************
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;
        }
    }
}
Best Answer chosen by Cindy Norman
Puru AnnamalaiPuru Annamalai
Hi Cindy,

You have mentioned the switchType="Client" in TabPanel, so it render the content on page load(this is selectedTab), if you click the next tab, it will not render the content, you have render it externally.

workaround 1 : change the switchType="Server", this will reload/render the tab content on the tab click.

if it is answers your question, kindly mark it as solved.

All Answers

Puru AnnamalaiPuru Annamalai
Hi Cindy,

You have mentioned the switchType="Client" in TabPanel, so it render the content on page load(this is selectedTab), if you click the next tab, it will not render the content, you have render it externally.

workaround 1 : change the switchType="Server", this will reload/render the tab content on the tab click.

if it is answers your question, kindly mark it as solved.
This was selected as the best answer
Cindy NormanCindy Norman
Oh, wonderful! Thank you so much! And such an easy solution...love it!