Show value within bar on flot bar chart
Asked Answered
W

3

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?

Weapon answered 3/2, 2011 at 21:54 Comment(0)
D
16

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

Duhon answered 2/8, 2011 at 16:14 Comment(3)
Mine is pretty buggy. I guess it because my flot is display the bars horizontal. www21.speedyshare.com/nGkvr/download/barnum.jpg . Any idea what I can do to fix this?Experimental
yeah, you're right, I've fixed it to take into account the horizontal bars.Duhon
@Duhon 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.<anonymous> (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)Appassionato
U
1

I think your answer is here:

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

Unless answered 4/2, 2011 at 2:2 Comment(1)
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.Weapon
V
1

The plugin flot.barlabels can be used:

enter image description here

Villiers answered 16/2, 2019 at 22:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.