Write actual values to bar chart using Gruff within Ruby

1k views Asked by At

I am generating a bar chart with values [1,5,10,23]. Currently, I have no way of knowing those exact values when looking at the image generated by Gruff. I just know that 23 falls somewhere between the lines of 20 and 25.

Is it possible to write the exact values within the image?

2

There are 2 answers

1
usha On

I think you are looking for labels

g = Gruff::Bar.new
g.title = 'Wow!  Look at this!'
g.data = "something", [1,5,10,23]
g.labels = { 0 => '1', 1 => '5', 2 => '10', 3 => '23'}

Read the documentation for more info on labels

0
rtmex On

I think this is what you are looking for:

g.show_labels_for_bar_values = true