2013-03-18 52 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