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

apex:chart rendered=true not working properly.




I'm displaying the chart if there are values to plot on it for each year. Otherwise, a message is displayed as no data. 



Chart is re rendered properly when there are values to plot for selected year. Also, when there are no values to plot, appropriate message is displayed and chart is hidden. Now once I select the year which has values to plot, chart section is rendered to true but the chart doesn't show up in the screen. Just blank page comes up.


Below is the page code,


<apex:page controller="PaymentGraphController" sidebar="false">
<apex:form >
<apex:pageBlock id="PB" >
<apex:chart height="400" width="700" data="{!paymentDataList}" rendered="{!showData}">
<apex:legend position="right"/>
<apex:axis type="Numeric" position="left" fields="NumberOfPayments"
title="Payments(Count)" grid="true"/>
<apex:axis type="Numeric" position="right" fields="totalAmount"
title="Total Amount"/>
<apex:axis type="Category" position="bottom" fields="Calendarmonth"
title="Month of the Year">

<apex:lineSeries title="Proceeds" axis="left" xField="Calendarmonth" yField="NumberOfPayments"
markerType="cross" markerSize="4" markerFill="#FF0000"/>
<apex:lineSeries title="Closed-Lost" axis="right" xField="Calendarmonth" yField="totalAmount"
markerType="circle" markerSize="4" markerFill="#8E35EF" />

<apex:outputLabel rendered="{!(!showData)}"><b>No payment for {!year}</b></apex:outputLabel>
<apex:outputLabel value="Payment Year: "></apex:outputLabel>
<apex:selectList value="{!year}" size="1" >
<apex:selectOptions value="{!Years}"/>
<apex:actionSupport event="onchange" rerender="PB" action="{!refreshByYear}"/>



Am I missing something here? Please suggest some workaround.



Last time I had this problem, I ended up adding an ID value to the form itself, and re-rendering the entire form. Sometimes the re-render attribute can be hit-and-miss, so you might try that and see if it fixes the problem.