2013-04-04 68 views
0

我试图绘制100个输入的1个系列的直方图。但是,当我将它指定为渲染条形图时,jqPlot会将我的数据呈现为折线图。我的代码是条形图示例的修改版本。jqPlot BarRenderer呈现线条图而不是条形图

<script type="text/javascript" src="dist/jquery.min.js"></script> 
<script type="text/javascript" src="dist/jquery.jqplot.js"></script> 
<script type="text/javascript" src="dist/src/plugins/jqplot.barRenderer.min.js"></script> 
<script type="text/javascript" src="dist/src/plugins/jqplot.categoryAxisRenderer.min.js"></script> 
<script type="text/javascript" src="dist/src/plugins/jqplot.pointLabels.min.js"></script> 

$(document).ready(function(){ 
      var hits = [123, 54, 897, ...] 

      var plot1 = $.jqplot('chart1', [hits], { 
        seriesDefaults:{ 
        renderer:$.jqplot.BarRenderer 
        }, 
         series:[ {label:'Hits'} ], 

      legend: { 
        show: true, 
          placement: 'outsideGrid' 
          }, 
         axes: { 
           xaxis: { 
         autoscale: true, 
         renderer: $.jqplot.CategoryAxisRenderer, 
           numberTicks: 4, 
           tickInterval: 25 
           }, 
          yaxis: { 
         autoscale: true 
         } 
        } 
       }); 
       }); 

有人知道我在做什么错吗?

+1

您是否尝试过使用Firebug的控制台来了解你的所有jqplot来源以及进口?因为你的代码正在工作find:[here](http://jsfiddle.net/AnthonyLeGovic/uSuU5/) – AnthonyLeGovic 2013-04-08 06:15:36

回答

0

添加seriesDefaults选项,您jqplot选项:

seriesDefaults: { 
    renderer: $.jqplot.BarRenderer, 
    rendererOptions: {fillToZero: true} 
} 
+0

我已经在上面的源代码中设置了seriesDefaults。我也添加了fillToZero选项,但它根本没有改变图形。 – David 2013-04-05 18:50:48

+0

根据您对我的OP的评论,这是一个包含问题。感谢您的支持! – David 2013-04-08 19:13:29