|
| +----+
| | |
| | |
| | |
| +----+ | 20 |
| | | | |
| | 10 | | |
| | | | |
|---+----+------+----+------
Run Code Online (Sandbox Code Playgroud)
data = [[1,10],[2,20]]
有没有办法做到这一点?
是否可以将值标签放在条形图上,使它们在它们上方居中?
如果我设置了条形align: "center",条形上的标签是关闭的而不是居中的.

<script type="text/javascript">
$(function() {
var data = [<?php echo $data; ?>];
$.plot("#<?php echo $target; ?> .chart-placeholder", data, {
series: {
color: "rgb(57,137,209)",
bars: {
show: true,
// align: "center",
barWidth: .8,
fill: 1
},
valueLabels: {
show: true,
showAsHtml: true,
align: "center"
}
},
grid: {
aboveData: true,
hoverable: true,
borderWidth: 0
},
xaxis: {
mode: "categories",
tickLength: 0,
labelAngle: -45,
showAsHtml: true
},
yaxis: {
show: false,
tickLength: 0
},
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我需要在Jquery Flot图表中添加标签.目前它只提供鼠标悬停的标签,而不是我需要在栏后显示标签.我附上了一个图像和这个问题.在hash(#)的位置我需要在那里放置条形标签.请给我一个解决方案.提前致谢.
for (i = 0; i < bardata.length; i++) {
ds.push({
label: yearArry[i],
data : bardata[i],
});
}
var options = {
colors : colorArray,
grid : {
hoverable : true,
clickable : true,
tickColor : $chrt_border_color,
borderWidth : $chrt_border_width,
borderColor : $chrt_border_color,
},
series: {
stack:true,
bars: {
show : true,
barWidth : 0.8,
horizontal: true,
align: "center"
}
},
xaxis: {
tickFormatter: function(val, axis) { return val < axis.max ? abbreviateNumber(val) : "Cost"; }
},
yaxis: { …Run Code Online (Sandbox Code Playgroud)