flot-valuelabels
flot-valuelabels copied to clipboard
For bar graphs, center value label above bar
For bar graphs, is it possible to display the value label centered above the bar? Currently, there are two options: if the bar's align option is "left" (the default), the value label appears on top of the bar to the left side; or, if the bar's align option is "center", the value label appears on top of the bar to the right of center. Neither is visually appealing.
Could you show your graph setup so I can work on that?
<html>
<head>
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<script language="javascript" type="text/javascript" src="jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="jquery.flot.valuelabels.js"></script>
</head>
<body>
<div id="placeholder" style="width:800px;height:500px"></div>
<script id="source" language="javascript" type="text/javascript">
$(function () {
$.plot($("#placeholder"),
[ [ [ 0, 12345 ], [ 10, 67890 ] ] ],
{ bars: { show: true }, valueLabels: { show: true } }
);
});
</script>
</body>
</html>
I changed the line "x_pos = xx;" to "x_pos = xx-5*(val.length-1);" Seemed to work ok then.