January 2013
Intermediate to advanced
328 pages
7h 14m
English
It's possible to update the chart in a timely manner with the help of the <p:poll> component.
The following definition updates the pie chart every 3 seconds:
<p:poll interval="3" update="live" />
<p:pieChart id="live" value="#{pieChartController.livePieModel}" style="height:250px" />The data model definition with the getter method, which will randomly create chart data, is given as follows:
PieChartModel liveChartModel = new PieChartModel(); liveChartModel.set("Candidate 1", 500); liveChartModel.set("Candidate 2", 300); public PieChartModel getLivePieModel() { int random1 = (int)(Math.random() * 1000); int random2 = (int)(Math.random() * 1000); liveChartModel.getData().put("Candidate 1", ...Read now
Unlock full access