【问题标题】:PrimeFaces barChart is not shownPrimeFaces barChart 未显示
【发布时间】:2014-03-20 07:40:35
【问题描述】:

我对条形图有疑问。 我为 Primefaces 中的 barCharts 编写了一个示例,但在页面上它们不可见。

这里是 Bean 类:

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;
}
}

这里是 .xhtml 文件:

    <!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>

抱歉编辑不好,但这是我在这里的第一个问题。

因此,如果我随后启动 .xhtml 页面,barChart 的空间将保留在页面上,但没有显示任何内容。

谁能帮我解决这个问题?

【问题讨论】:

    标签: java jsf jsf-2 primefaces xhtml


    【解决方案1】:

    如果你使用 jquery 的模板,那么你应该添加这一行

    $.noConflict();

    【讨论】:

    • $.noConflict();
    【解决方案2】:
     <p:panel>
           <p:chart ......>
     </p:panel>
    

    应该可以解决它,p:panel

    【讨论】:

      【解决方案3】:

      好的 primefaces 4.0 是问题所在。

      将 primefaces 4.0 中的 jquery.js 文件与 3.5 中的 jquery.js 文件交换

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-10
        • 2013-06-28
        • 1970-01-01
        • 2023-03-03
        相关资源
        最近更新 更多