12

I would like to show the value within the bar on the flot bar chart, something like this:

|
|               +----+
|               |    |
|               |    |
|               |    |
|   +----+      | 20 |
|   |    |      |    |
|   | 10 |      |    |
|   |    |      |    |
|---+----+------+----+------

data = [[1, 10], [2, 20]]

Is there a way to do this?

Sergey G
  • 243
  • 1
  • 2
  • 6

3 Answers3

16

I needed the same thing, so I quickly hacked together a plugin for it and a quick example of it in action.

dinosaurwaltz
  • 1,731
  • 1
  • 14
  • 12
  • Mine is pretty buggy. I guess it because my flot is display the bars horizontal. http://www21.speedyshare.com/nGkvr/download/barnum.jpg . Any idea what I can do to fix this? – Kasper Skov Sep 17 '12 at 10:43
  • 1
    yeah, you're right, I've fixed it to take into account the horizontal bars. – dinosaurwaltz Sep 25 '12 at 16:24
  • @dinosaurwaltz i get an error when i tried using this `Uncaught TypeError: Cannot read property 'toString' of null at formatter (jquery.flot.barnumbers.js:60) at Object. (jquery.flot.barnumbers.js:121) at Function.each (jquery-1.11.3.js:384) at draw (jquery.flot.barnumbers.js:57) at executeHooks (jquery.flot.js:717) at draw (jquery.flot.js:1886) at new Plot (jquery.flot.js:710) at Function.$.plot (jquery.flot.js:3146) at plot_graph (graphs.php:975) at Object.success (graphs.php:683)` – shorif2000 Feb 20 '17 at 16:32
1

I think your answer is here:

http://code.google.com/p/flot/issues/detail?id=218

blueberryfields
  • 45,910
  • 28
  • 89
  • 168
  • Thank you for your reply. But this is not exactly what I was looking for. this plugin shows the value on top of the bar, i would like to show it **in** the bar. – Sergey G Feb 07 '11 at 14:50
0

The plugin flot.barlabels can be used:

enter image description here

vladimir
  • 13,428
  • 2
  • 44
  • 70