2013-03-18 41 views
0

我已經在以下相當長一段時間了...希望有人能幫助我。jqplot:堆疊條形圖丟失的元素

我在做什麼: 使用jqplot我試圖結合水平堆積條形圖和折線圖。堆積的條形圖應該包含五個值。折線圖應該跨越堆積的條形圖。

我到目前爲止: 我已經設法構建了水平堆疊條形圖,並且該線應該如此交叉。

問題: 我的堆積條形圖現在顯示三個塊(值:1,4和16)。我應該看到五個塊(值:1,2,4,8和16)。

我使用的代碼:

<script type="text/javascript"> 

    $(document).ready(function() { 
     var x1 = [[1,1]]; 
     var x2 = [[2,1]]; 
     var x3 = [[4,1]]; 
     var x4 = [[8,1]]; 
     var x5 = [[16,1]]; 
     var x6 = [[1,0.5],[1,1.5]]; 

     var plot2 = $.jqplot('thema1chart', [x1, x2, x3, x4, x5, x6], { 
      stackSeries: true, 
      seriesDefaults: { 
       renderer: $.jqplot.BarRenderer, 
       rendererOptions: { 
        barDirection: 'horizontal' 
       }, 
       pointLabels: { 
        show: false, 
        stackedValue: true 
       } 
      }, 
      series: [{shadow: false, color:'#666666'}, 
      {shadow: false, color:'#FFFFFF'},{shadow: false, color:'#b4d2dd'},{shadow: false, color:'#FFFFFF'},{shadow: false, color:'#666666'}, 
        { 
        shadow: false, 
         disableStack : true,//otherwise it wil be added to values of previous series 
       renderer: $.jqplot.LineRenderer, 
       lineWidth: 2, 
       label:'Benchmark', 
       color:'#666666', 
       showLine:false, 
       pointLabels: { 
        show: false 
       }, 
       markerOptions: { 
        size: 7, style:"plus" 
       }}], 
      axes: { 
       xaxis: { 
        renderer: $.jqplot.CategoryAxisRenderer 
       } 
       , 
       yaxis: { 
        autoscale: true 
       } 
      } 
     }); 
    }); 
    </script> 

你可以提供任何幫助,非常感謝!

回答

0

您需要申請CategoryAxisRenderer於Y軸(不x-軸):

yaxis: { 
    renderer: $.jqplot.CategoryAxisRenderer 
} 

working example here

編輯:添加x軸:{分:0}如果要綁定到軸選項xaxis

+0

嗨安東尼,非常感謝!你的答案正是我需要的! – 2013-03-18 10:36:26