1

我正在使用 primefaces 3.4.2。由于 primefaces 不提供对 y2axis 的支持,我正在使用 primefaces 提供的 jqplot 并在函数中编写代码。我能够获取 y2axis 但无法检索 x 轴的日期。

我还调用了渲染器:$.jqplot.DateAxisRenderer,

.我什至没有错误,也没有 xaxis 上的值。当我有数字时,我确实在 x 轴上看到了值。

4

1 回答 1

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>
于 2012-12-18T17:10:50.743 回答