Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to construct a basic line graph. I have a Visualforce page, and a Component I put inside this page. The idea is, once the search button is clicked, the section with the component becomes visible by setting a boolean variable in the controller.

In the component, I have two things: an outputText which says "hello", and an apex:chart. The weird thing is, the outputText is shown, but the apex chart is not when the button is pressed. The only way I can get the chart to show is by showing it at all times, not just when the button is pressed. Why would one element rerender and not the other? The apex:chart isn't throwing any firebug errors...

VF Page Code:

<apex:pageBlockSectionItem >
       <apex:commandButton value="Search" action="{!methodx}" rerender="container, container2, thePageBlock"/>

<apex:outputPanel id="container2">  
   <apex:pageBlock rendered="{!showChart}">
      <apex:pageBlockSection id="myChart">
        <c:myComponent param="{!param}"/> 

Component Code:

<apex:component controller="MyChartController">
    <apex:attribute name="param" type="String" assignTo="{!myparam}" description="none"/>
    <apex:outputText value="hello"/>
    <apex:chart height="400" width="700" data="{!axisData}">
         <apex:axis type="Numeric" position="left" fields="field1" 
         <apex:axis type="Category" position="bottom" fields="name"/>
         <apex:lineSeries axis="left" fill="true" xField="name" yField="field1"
             markerType="circle" markerSize="3" markerFill="#FF0000"/>
share|improve this question
Some controller code would be nice to see :) – Sergey Utko Jan 29 '13 at 20:17
If I remove the rendered="{!showChart}", the chart displays fine. So I don't think it's a problem with the controller :) – George S. Jan 30 '13 at 11:20
up vote 2 down vote accepted

I solved it by extracting the apex:chart from the Component and putting it in the VF Page in the same place. Shouldn't make a difference afaik but it did.

share|improve this answer

Try apex:chart's show/hide Javascript functions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.