May 2015
Beginner to intermediate
412 pages
8h 44m
English
The chart component nicely integrates with the <p:poll> component to update itself with an ever-changing data model.
A basic definition for a chart with live data is given here:
<p:poll interval="2" update="live" />
<p:chart id="live" type="pie" model="#{chartBean.livePieModel}"
style="height:250px" />The randomly generated model for the chart is implemented here:
public PieChartModel getLivePieModel() { int random1 = (int)(Math.random() * 1000); int random2 = (int)(Math.random() * 1000); liveChartModel.getData().put("Candidate 1", random1); liveChartModel.getData().put("Candidate 2", random2); liveChartModel.setLegendPosition("w"); liveChartModel.setShowDataLabels(true); return liveChartModel; ...Read now
Unlock full access