2012-12-18 99 views
1

我正在使用primefaces 3.4.2。由於primefaces不提供對y2axis的支持,我使用primefaces提供的jqplot並將代碼寫入函數中。我能夠獲取y2axis,但無法檢索x軸的日期。dateaxisrenderer不在我的代碼中呈現

我也叫渲染:$ .jqplot.DateAxisRenderer,

。我甚至不有xaxis.I錯誤,也不值並查看X軸上的值時,我有一個數字。

+0

您可能希望包含更多的代碼和/或更多問題的解釋。此外,添加相關標籤到您的文章,以幫助他人找到這個問題。 – JSuar

回答

0
<ui:composition 

    <!-- Contextual Actions Menu --> 
    <h:outputScript library="components" name="sso.js" target="body"/> 

    <h:outputScript name="charts/charts.js" library="primefaces" target="head"/> 
    <h:outputScript name="jquery/jquery.js" library="primefaces" target="body"></h:outputScript> 

    <h:outputScript library="primefaces" name="plugins/jqplot.dateAxisRenderer.min.js" target="body"></h:outputScript> 
    <h:outputScript library="primefaces" name="plugins/jqplot.dateAxisRenderer.js" target="body"></h:outputScript> 

    <ui:define name="body"> 

    <!-- <p:outputPanel layout="block">--> 


    <script type="text/javascript"> 
    $(document).ready(function(){ 

      var line1= [['2008-09-30 4:00PM',10], ['2008-10-30 4:00PM',20], ['2008-11-30 4:00PM',35], ['2008-12-30 4:00PM',31], ['2009-01-30 4:00PM',50]]; 
      var line2= [['2008-09-30 4:00PM',100], ['2008-10-30 4:00PM',200], ['2008-11-30 4:00PM',300], ['2008-12-30 4:00PM',450], ['2009-01-30 4:00PM',500]]; 

      <!-- var line1=[[12,10], [18,20], [24,30], [30,40], [36,50]]; --> 
      <!-- var line2=[[14,100], [14,200], [20,300], [12,400], [30,500]]; --> 

    $.jqplot.config.enablePlugins= true; 

    plot1=$.jqplot('chart1',[line2, line1], { 

    title:'AUM vs Revenue', 

    axesDefaults: { 
     tickRenderer: $.jqplot.CanvasAxisTickRenderer, 

    }, 


    axes:{ 
    xaxis:{ 


     renderer:$.jqplot.DateAxisRenderer 

     <!--min:'2008-09-30', --> 
     <!-- tickInterval:'1 month', --> 
     <!-- tickOptions:{formatString:'%b %#d, %y'}, --> 
     <!--label: "Time Period", --> 
     <!--labelRenderer: $.jqplot.CanvasAxisLabelRenderer --> 


     <!-- min:0, --> 
     <!-- tickInterval:10 --> 

     }, 
     yaxis:{ 
      labelOptions: { 
       textColor : '#3988BD'}, 
       tickOptions:{textColor : '#3988BD'}, 
      tickInterval:100, 
      min:0, 
      label: "AUM", 
      labelRenderer: $.jqplot.CanvasAxisLabelRenderer 

     }, 
     y2axis:{labelOptions: { 
      textColor : '#E0981B'}, 
      tickOptions:{textColor : '#E0981B'}, 
      tickInterval:10, 
      min:0, 
     label:"Revenue", 
     labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
      renderOptions:{alignTicks:true} 
     } 

    }, 

    grid: { 
        borderColor: "#fff", 
        background: "#FFF", 
        drawGridlines: true, 
        shadow: true 
       }, 
    series:[ 
      {lineWidth:4}, {yaxis:'y2axis'} 
     ], 
    cursor:{ 
     show: true, 
     zoom:true, 
     showTooltip:true 
    }, 
    }); 
}); 
</script> 
+0

由於包含了嵌套複合組件,此xhtml位於ui:組合標記中,而不是html。我不知道這是否有所作爲。 – user1911538

+0

我找到了答案,爲jqplot插件創建一個庫並應用dateaxis渲染器。 – user1911538

+0

現在我個人的問題是primefaces是否支持y2axis沒有定製或與? – user1911538