Single-Bar bar graph?
sdubinsky opened this issue · comments
Hi,
Thanks for the library! It's really great. I'm on gruff 0.18.0, ruby 2.7.3, and ubuntu 22.04. Perhaps I'm missing something obvious, but I can't figure out how to get a simple bar graph, where each line represents a single data point, and its length represents how far it goes.
I can fake this reasonably well with:
g = Gruff::Bar.new
g.hide_legend = true
data = {'A' => 1, 'B' => 2, 'C' => 3}
labels = {}
data.each_with_index do |arr, i|
values = [0] * 10
values[i] = arr[1]
labels[i] = arr[0]
g.data(arr[0], values)
end
g.labels = labels
g.write("graph1.png")
But that seems needlessly complex. Is there a better/simpler way?
Also, the staggered labels option seems broken, even looking at the expected pic: https://github.com/topfunky/gruff/blob/master/test/expected/bar_set_label_stagger_height.png.
Thanks!
Maybe, you want to do is code something like the following?
g = Gruff::Bar.new
g.hide_legend = true
g.data "", [1, 2, 3]
g.minimum_value = 0
g.labels = ["A", "B", "C"]
g.write("graph1.png")
Also, the staggered labels option seems broken
It is expected. because staggered labels was deprecated.
If you have any other questions, please feel free to reopen this ticket.