Is it possible to place the value labels over the bars so they stand centered over them?
If i set bars align: "center"
, the labels over the bars is off and not centered.
<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>
Plugins got you down? Just do it yourself, life it so much simpler then. This is the advantage of
flot
, compact code that get's out of your way...Here's how I would add those labels:
Fiddle demonstration is here.
Produces:
There seems to be no solution with the default Value Labels plugin. But there are some open issues which discuss this and here are some proposed solutions you can try.
This version of the plugin from neoDD69 does a better job at centering the labels as you can see in this fiddle (see comment below).