I'm trying to make a simple line chart following the Primefaces showcase example, but with no success. The xhtml page is rendering an empty div. I've changed the bean scope and still not working. Here is my code:
@Named(value = "chartBean")
@RequestScoped
public class ChartBean {
private CartesianChartModel categoryModel;
public ChartBean() {
createCategoryModel();
}
private void createCategoryModel() {
categoryModel = new CartesianChartModel();
ChartSeries boys = new ChartSeries();
boys.setLabel("Boys");
boys.set("2004", 120);
boys.set("2005", 100);
boys.set("2006", 44);
boys.set("2007", 150);
boys.set("2008", 25);
ChartSeries girls = new ChartSeries();
girls.setLabel("Girls");
girls.set("2004", 52);
girls.set("2005", 60);
girls.set("2006", 110);
girls.set("2007", 135);
girls.set("2008", 120);
categoryModel.addSeries(boys);
categoryModel.addSeries(girls);
}
public CartesianChartModel getCategoryModel() {
return categoryModel;
}
public void setCategoryModel(CartesianChartModel categoryModel) {
this.categoryModel = categoryModel;
}
}
And my xhtml file:
<p:lineChart id="linear" value="#{chartBean.categoryModel}" legendPosition="e"
title="Linear Chart" minY="0" maxY="10" style="height:300px">
</p:lineChart>
I was using a facelets model client and now testing a simple xhtml file it works. But I need to use the client and the chart still not appearing on it. Any suggest?
I have solved the issue. I was using a script to fadeIn the page after it loads and was having a conflict with Primefaces rendering. I removed the display:none property and solved the question!