试图将文本标签置于FLUX下的XC轴下的条形图中。
flot的原始标记如下所示:
<div style="position: absolute; text-align: center; left: -20px; top: 185px; width: 79px;" class="tickLabel"><span class="chart-label">Lorem</span></div>
我希望生成的标签标记如下所示:
<div style="position: absolute; text-align: center; left: 0px; top: 185px; width: 79px;" class="tickLabel"><span class="chart-label">Lorem</span></div>
到目前为止,这段代码已经做到了,但我想知道是否有更好的方法来对齐标签。
$.each($('.chart-label'),function(idx,el){
var c = $(el);
var value = c.parent().css('left');
c.parent().css('left',parseInt(value)+20+'px');
});
我不能覆盖css中的位置,因为左边的属性是内联的。