条形图x轴,y轴值不会以rtl方向渲染

时间:2013-04-30 05:51:59

标签: jsf jsf-2 primefaces

我在展示案例中使用条形图示例: http://www.primefaces.org/showcase/ui/barChart.jsf

但是我遇到的问题是图表被正确绘制,只是没有出现x轴和y轴的值,如下图所示:

enter image description here

我唯一的区别是我在动态对话框中显示图表。

我尝试在对话框中添加onShow方法,但效果相同:

onShow="barChartWidget.plot.replot();"

我的xhtml代码如下:

1- report_panel.xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:pretty="http://ocpsoft.com/prettyfaces"
    xmlns:p="http://primefaces.org/ui"
    xmlns:sec="http://www.springframework.org/security/tags"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core">


<body>

    <ui:composition>


        <h:panelGroup layout="block"
              <p:commandLink id="show_created_report" title="Show Report Dialog"
                    action="#{myBean.generateReport}"
                    oncomplete="report_dialog_widget.show();">
                    <h:graphicImage value="/resources/images/report.png" width="50"
                        height="50" />
            </p:commandLink>
        </h:panelGroup>

        <ui:insert name="report_dialog">
            <ui:include src="/pages/compositions/report_dialog.xhtml" />
        </ui:insert>


    </ui:composition>

</body>

</html>

2- report_dialog.xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:pretty="http://ocpsoft.com/prettyfaces"
    xmlns:p="http://primefaces.org/ui"
    xmlns:sec="http://www.springframework.org/security/tags"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core">


<body>

    <ui:composition>

    <p:dialog id="report_dialog" showEffect="puff" height="500"
        width="800" resizable="false" dir="rtl"
        header="report" widgetVar="report_dialog_widget"
        dynamic="true">
        <h:panelGroup id="report_details" layout="block">
        <p:dataTable styleClass="content_font" id="report_table"
            var="record" value="#{myBean.report.tableRecords}">

            <p:column headerText="Dept Name">
                <h:outputText value="#{record.responsibleName}" />
            </p:column>

            <p:column headerText="Num Of Tasks" style="text-align:center">
                <h:outputText value="#{record.tasksCount}" />
            </p:column>

            <p:column headerText="Num Of Finished Tasks" style="text-align:center">
                <h:outputText value="#{record.finishedtasksCount}" />
            </p:column>

            <p:column headerText="Num Of Un Finished Tasks" style="text-align:center">
                <h:outputText value="#{record.unFinishedtasksCount}" />
            </p:column>
        </p:dataTable>


        <p:barChart  widgetVar="barChartWidget"  id="barChart" value="#{myBean.report.categoryModel}" legendPosition="ne" style="width:400px;height:300px;"  
            title="Tasks Chart" min="0" max="200" />

        </h:panelGroup>
        </p:dialog>


    </ui:composition>

</body>

</html>

3- managedBean:

public void generateReport(){
        report=new Report();
            //other report stuff goes here
        report.setCategoryModel(createCategoryModel());
    }

     private CartesianChartModel 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);
        return  categoryModel;  
    } 

我使用 PrimeFaces 3.5 Mojarra 2.1.20

更新:在此链接中上传了用例项目: https://docs.google.com/file/d/0B10CrX5WSm-IakNWWHEteFlfalk/edit - 可以通过文件&gt;下载下载 - 然后提取文件并使用maven构建项目。

UPDATE2:

我发现了这个问题,这与我在body标签和对话框组件上的rtl方向有关,是否有修复这个问题的想法?

1 个答案:

答案 0 :(得分:0)

问题是条形图组件从主体继承了rtl方向,所以我不得不重写条形图样式并给它指示ltr。