1
我正在從一個xml對象讀取數據到一個數組中,共計六個項目。圖表呈現良好,每個垂直條的所有顏色和高度都可以。當我嘗試向每個垂直條添加數據標籤時,標籤全部出現在相關條頂部的正確高度處,但它們都與左側軸對齊。flot條形圖數據標籤左偏移
o.left的下面始終返回NaN值的代碼的left屬性。
$.each(plot.getData()[0].data, function(i, el){
var o = plot.pointOffset({x: el[0], y: el[1]});
$('<div class="data-point-label">' + el[1] + '</div>').css({
position: 'absolute',
--->left: o.left + 4,<--
top: o.top - 20,
display: 'none',
color:'#000',
fontSize:'12pt'
}).appendTo(plot.getPlaceholder()).slideToggle();
});
我不知道如果我從XML到陣列中添加數據的方法是在劇情的選項不正確或東西,如下:
$(function() {
Init() //Load XML and load into array named data
plot = $.plot("#placeholder", [ data ], {
grid: {
backgroundColor: { colors: [ "#FFF", "#FFF" ] },
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0
}
},
series: {
bars: {
show: true,
lineWidth: 0, // in pixels
barWidth: 0.9, // in units of the x axis
fill: true,
fillColor: "#0000FF",
align: "center", // "left", "right", or "center"
horizontal: false,
zero: true,
}
},
xaxis: {
mode: "categories",
tickLength: 0,
autoscaleMargin: 0.1
}
});
這是可能的東西使用模式:「類別」行上面的x軸包含文本值?任何指針?
太棒了!你是明星。所有現在完美的作品。 – GrahamCFNewc 2014-09-03 15:05:55