put datas from database to chart primefaces -
i want put datas database chart primefaces. try different methods without result. try simple method dosen't display nothing: managedbean:
public class chartbean implements serializable{ private list < chartcontentbean > chartcontentbeanlist; public chartbean() { chartcontentbeanlist = new arraylist < chartcontentbean > (); chartcontentbeanlist.add(new chartcontentbean(2006, 25, 20)); chartcontentbeanlist.add(new chartcontentbean(2007, 60, 50)); chartcontentbeanlist.add(new chartcontentbean(2008, 40, 65)); chartcontentbeanlist.add(new chartcontentbean(2009, 70, 60)); } public list < chartcontentbean > getchartcontentbeanlist() { return chartcontentbeanlist; } }
chartcontentbean.xhtml
public class chartcontentbean{ private int year; private int passpercentage; private int failedpercentage; public chartcontentbean() {} public chartcontentbean(int year, int passpercentage, int failedpercentage) { this.year = year; this.passpercentage = passpercentage; this.failedpercentage = failedpercentage; } //get , set }
chart.xhtml
<xmlns:p="http://primefaces.prime.com.tr/ui"> <h:form> <p:linechart value="#{chartbean.chartcontentbeanlist}" var="chartcontentbean" xfield="#{chartcontentbean.year}"> <p:chartseries label="class a" value="#{chartcontentbean.passpercentage}" /> <p:chartseries label="class b" value="#{chartcontentbean.failedpercentage}" /> </p:linechart> </h:form>
well take @ http://www.primefaces.org/showcase/ui/barchart.jsf in primefaces showcase nice example want achieve. if follow showcase see you're missing.
Comments
Post a Comment