Once the user clicks on the last chart, values are reset and the initial chart is re-rendered.
My problem is that I use an extender function to render the charts legend, which works when it renders initially on page load, but the legend of the top bar chart fails to render subsequently after the user has clicked through all 3 charts and returns to the first chart.
It worked perfectly when I used the p:barChart tag up to primeface 5.0 and specified the extender in the tag. I had to change it to p:chart as part of the upgrade to 5.1 and now I have this regression.
Code examples:
Code: Select all
<p:column rowspan="6" style="text-align:center;" styleClass="headingMedium">
<p:outputPanel id="UseChartPanel">
<p:chart type="bar" id="usageStackChart" model="#{costFlowBean.barModelUsage}" style="height:220px;width:420px"
rendered="#{empty costFlowBean.pieTopMercs and empty costFlowBean.pieTopRegs}">
<p:ajax event="itemSelect" listener="#{costFlowBean.itemSelectUse}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel" />
</p:chart>
</p:outputPanel>
<p:outputPanel id="MercChartPanel">
<p:chart id="topMercsPieChart" type="pie" model="#{costFlowBean.pieTopMercs}" style="height:260px;width:420px"
rendered="#{not empty costFlowBean.pieTopMercs and empty costFlowBean.pieTopRegs}">
<p:ajax event="itemSelect" listener="#{costFlowBean.itemSelectMerc}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel" />
</p:chart>
</p:outputPanel>
<p:outputPanel id="RegChartPanel">
<p:chart id="topRegsPieChart" type="pie" model="#{costFlowBean.pieTopRegs}" style="height:260px;width:420px"
rendered="#{not empty costFlowBean.pieTopMercs and not empty costFlowBean.pieTopRegs}">
<p:ajax event="itemSelect" listener="#{costFlowBean.resetToTop}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel"/>
</p:chart>
</p:outputPanel>
</p:column>
Code: Select all
<script>
function extLegend()
{
this.cfg.legend= {
show: true,
location: 'ne',
placement: 'outsideGrid'
};
}
</script>
Extender is set in the model
Code: Select all
getBarModelUsage().setTitle("Usage");
getBarModelUsage().setLegendPosition("ne");
getBarModelUsage().setStacked(true);
getBarModelUsage().setShowDatatip(true);
getBarModelUsage().setExtender("extLegend");
Code: Select all
public void resetToTop(ItemSelectEvent event) {
setPieTopMercs(null);
setPieTopRegs(null);
setDrilldownCatDesc(null);
setDrilldownCats(null);
setDrilldownMerc(0);
setDrilldownPeriod(null);
setDrilldownReg(null);
setDrilldownMercDesc(null);
}
Code: Select all
<p:column rowspan="6" style="text-align:center;" styleClass="headingMedium">
<p:outputPanel id="UseChartPanel">
<p:barChart id="usageStackChart" value="#{costFlowBean.barModelUsage}" style="height:220px;width:420px" stacked="true"
rendered="#{empty costFlowBean.pieTopMercs and empty costFlowBean.pieTopRegs}" extender="extLegend" showDatatip="true" title="Usage">
<p:ajax event="itemSelect" listener="#{costFlowBean.itemSelectUse}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel" />
</p:barChart>
</p:outputPanel>
<p:outputPanel id="MercChartPanel">
<p:chart id="topMercsPieChart" type="pie" model="#{costFlowBean.pieTopMercs}" style="height:260px;width:420px"
rendered="#{not empty costFlowBean.pieTopMercs and empty costFlowBean.pieTopRegs}">
<p:ajax event="itemSelect" listener="#{costFlowBean.itemSelectMerc}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel" />
</p:chart>
</p:outputPanel>
<p:outputPanel id="RegChartPanel">
<p:chart id="topRegsPieChart" type="pie" model="#{costFlowBean.pieTopRegs}" style="height:260px;width:420px"
rendered="#{not empty costFlowBean.pieTopMercs and not empty costFlowBean.pieTopRegs}">
<p:ajax event="itemSelect" listener="#{costFlowBean.resetToTop}" update=":costFlowForm:UseChartPanel :costFlowForm:MercChartPanel :costFlowForm:RegChartPanel" />
</p:chart>
</p:outputPanel>
</p:column>