JavaTheHut
JavaTheHut

Reputation: 1

PrimeFaces barChart is not shown

I have a problem with barCharts. I wrote an example for barCharts from Primefaces but on the page they are not visible.

Here the Bean class:

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;

@ManagedBean
@ViewScoped

public class InvoiceStatisticsBean implements Serializable {
private CartesianChartModel categoryModel; 

public InvoiceStatisticsBean() {
    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 here is the .xhtml file:

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Invoice Statistics</title>
    </h:head>
    <h:body>
        <ui:composition template="/templates/layout.xhtml">
            <ui:define name="header">
                <h1>Invoice Statistics</h1>
            </ui:define>

        <ui:define name="content">
            <p>There should be a barChart</p>   
            <p:barChart id="horizontal" value="#{invoiceStatisticsBean.categoryModel}" legendPosition="se" style="height:300px" title="Horizontal Bar Chart" orientation="horizontal" min="0" max="200"/>  
            <p:outputPanel>test</p:outputPanel>
        </ui:define>
    </ui:composition>
</h:body>
</html>

Sorry for the bad editing but this is my first question here.

So if i then start the .xhtml page, the space for the barChart is reserved on the page but it is nothing shown.

Can anyone help me please with this problem?

Upvotes: 0

Views: 2655

Answers (3)

raafet dhaouadi
raafet dhaouadi

Reputation: 40

if you use a template using jquery so you should add this line

$.noConflict();

Upvotes: 0

VHGV
VHGV

Reputation: 11

 <p:panel>
       <p:chart ......>
 </p:panel>

that should fix it, p:panel

Upvotes: 1

JavaTheHut
JavaTheHut

Reputation: 1

ok primefaces 4.0 was the problem.

Swapped the jquery.js file from primefaces 4.0 with the one from 3.5

Upvotes: 0

Related Questions