flot-valuelabels icon indicating copy to clipboard operation
flot-valuelabels copied to clipboard

For bar graphs, center value label above bar

Open newacct opened this issue 14 years ago • 3 comments

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.

newacct avatar Aug 24 '10 08:08 newacct

Could you show your graph setup so I can work on that?

leonardoeloy avatar Aug 24 '10 09:08 leonardoeloy

<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>

newacct avatar Aug 24 '10 18:08 newacct

I changed the line "x_pos = xx;" to "x_pos = xx-5*(val.length-1);" Seemed to work ok then.

fizgig10 avatar Apr 26 '11 11:04 fizgig10