You need to sign in to do that
Don't have an account?
Chart disappears after rerender
I have a commandButton to reprocess a set of filters and on clicking Go, the page redraws the charts and tables. When the page first loads I process and display the charts on the page with no problem. When I click Go, all the charts and tables display except the bar chart.
I get this error in my browser console:
Visualforce Chart: Error loading configuration for chart 'jid0jid29jid55jid56jid57jid64': Did not find required field 'ftRev,tgtRev' in data for chart 'jid0jid29jid55jid56jid57jid64'. Make sure field was queried and/or provided and has a value.
Here are extracts from the page code:
...
<apex:commandButton action="{!updatePage}" value="Go" id="theButtonCM"/>
...
<apex:outputPanel id="barchart">
<apex:pageBlock >
<apex:pageBlockTable value="{!perfSummList}" var="d" align="center">
<apex:column value="{!d.ftRev}" headerValue="FT"/>
<apex:column value="{!d.tgtRev}" headerValue="tgt"/>
<apex:column value="{!d.monthYYYYMM}" headerValue="mth"/>
<apex:column value="{!d.monthStr}" headerValue="mth"/>
</apex:pageBlockTable>
<b>ft revenue vs target</b><br/>
<apex:chart data="{!perfSummList}" height="300" width="500">
<apex:legend position="bottom" spacing="10" padding="2" font="10px Helvetica"/>
<apex:axis type="Category" position="bottom" fields="monthStr">
<apex:chartLabel />
</apex:axis>
<apex:axis type="Numeric" position="left" fields="tgtRev,ftRev" minimum="0" >
<apex:chartLabel />
</apex:axis>
<apex:barSeries axis="left" orientation="vertical" xField="monthStr" yField="ftRev,tgtRev" title="F+T,Target">
<apex:chartLabel />
</apex:barSeries>
</apex:chart>
</apex:pageBlock>
</apex:outputPanel>
The data in the table is from the same list and shows up just fine - the fields reported have values as surely the table would show if they did not. Something is going on under the hood for the charts and I can find out the issue here.
Any ideas?
You've found a bug! The source was helpful.
As a workaround, please remove your barSeries's <apex:chartLabel /> element. Currently VF charting doesn't support labels on barSeries having >1 bar (data point). Notice on initial render that the data value is not displayed along w/ the bar. On re-render, charting doesn't handle multiple yFields well.
If you feel strongly that this needs to be fixed soon, please create a support case.
Thanks again for uncovering.
All Answers
To help debug, output the chart's data to the page. Eg, place the following w/ the re-rended element. On re-render, you should see updated data. Make sure that is expected.
Also, use Firebug or similar to review the re-rendered response. The postback response should contain a load() call having the updated data. Make sure that's present and the referenced fields exist.
PS: In your code snippet, I don't see that commandButton.reRender is defined.
Thanks, but no solution yet. I put in a rerender but no effect - I assumed that without it it just refreshes the whole page, which is what I want anway.
This is the output, but no chart is displayed.
I checked the console for the 'load()' output. I found this...
Here is the code that shows the error after Go is clicked.
You've found a bug! The source was helpful.
As a workaround, please remove your barSeries's <apex:chartLabel /> element. Currently VF charting doesn't support labels on barSeries having >1 bar (data point). Notice on initial render that the data value is not displayed along w/ the bar. On re-render, charting doesn't handle multiple yFields well.
If you feel strongly that this needs to be fixed soon, please create a support case.
Thanks again for uncovering.
Thank you so much!
It would be embarassing to explain to my boss why the chart does not appear. The label they can probably live without.
The other workaround with the axis minimum="0" attribute is another gotcha to look out for, without this only one from the bar series yField appears.
It appears visulaforce charting has some issues - I really hope they get sorted soon.
Thanks for the feedback. Your noted issue(s) will be resolved in the next release.
Please continue to provide feedback and post questions and issues w/ Visualforce charting.
<div style="display: {!IF([your field here]==[your criteria here], 'always', 'none')};">