2014-06-05 136 views
0

我正在使用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

+0

'此處輸入代碼'部分是垃圾,請刪除。 –

回答

0

我從來沒有用過jqPlot,不能讓你的工作,例如,但問題是,標籤的s2系列內畫。 A,B和H的s2值都等於0.00,所以沒有繪製圖形,也沒有地方放置標籤。

要麼將​​標籤放置在酒吧外,在s1之內,確保沒有值爲0.00。

0

本期已修復。我已經使用tickInterval for x-axis來解決它。

下面是代碼:

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' 
}  

});