JQPlot中的堆积条形图未显示少量堆栈条的标签

时间:2014-06-05 07:03:05

标签: javascript jqplot

我使用JQplot生成堆积条形图,其中值为十进制数。我没有获得第一个堆栈栏的堆栈标签。我附上了我的代码和屏幕截图。请告诉我我正在做的错误。

var s1 = [69.44,48.70,70.00,70.00,70.00,70.00,70.00,67.35];
        var s2 = [0.00,0.00,27.08,25.04,12.47,26.80,11.83,0.00];
        var ticks = ['A', 'B', 'C', 'D','E','F','G','H'];
         plot3 = $.jqplot('chartdiv', [s1, s2], {
    stackSeries: true,
    captureRightClick: true,
    seriesDefaults:{
      renderer:$.jqplot.BarRenderer,
      rendererOptions: {
          fillToZero: true, barDirection: 'horizontal'
      },
      pointLabels: {show: true,hideZeros:true,}
    },
    axes: {
      xaxis: {
           pad: 1.05,
           tickOptions: {formatString: '%.2f %'},
      },
      yaxis: {
         renderer: $.jqplot.CategoryAxisRenderer,
         ticks: ticks
      }
    },
    legend: {
      show: true,
      location: 'e',
      placement: 'outside'
    }     
  });

enter image description here

2 个答案:

答案 0 :(得分:0)

我从未使用过jqPlot而且无法使你的示例正常工作,但问题是标签是在s2系列中绘制的。 A,B和H的s2值均等于0.00,因此没有绘制图形,也无法放置标签。

将标签放在栏内,s1内,og确保没有值为0.00。

答案 1 :(得分:0)

此问题已得到修复。我已经使用tickInterval作为x轴来解决它。

以下是代码:

    s1 = [69.44,48.70,70.00,70.00,70.00,70.00,70.00,67.35];

    s2 = [0.00,0.00,27.08,25.04,12.47,26.80,11.83,0.00];

    ticks = ['A', 'B', 'C', 'D','E','F','G','H'];
     plot3 = $.jqplot('chartdiv', [s1, s2], {
stackSeries: true,
captureRightClick: true,
seriesDefaults:{
  renderer:$.jqplot.BarRenderer,
  rendererOptions: {
      fillToZero: true, barDirection: 'horizontal'
  },
  pointLabels: {show: true,hideZeros:true,labelsFromSeries:true,xpadding: 6}
},
axes: {
  xaxis: {
       pad: 1.05,
       tickOptions: {formatString: '%.2f %'},
       min:0.00,
       tickInterval : 10.00,
       max:100.00,
  },
  yaxis: {
     renderer: $.jqplot.CategoryAxisRenderer,
     ticks: ticks,
  }
},
legend: {
  show: true,
  location: 'e',
  placement: 'outside'
}     

});