Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :barh to Gruff #14

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@yaboojp
Copy link
Contributor

commented May 5, 2019

"p.labels" is required, therefore set nil to "p.labels".
But I'm wondering if such a solution is good??

charty = Charty::Plotter.new(:gruff)
bar = charty.barh do
  series [0,1,2,3,4], label: "sample1"
  series [0,1,2,3,4], label: "sample2"
  series [0,1,2,3,4,5,6,7,8], label: "sample3"
  range x: 0..10, y: 1..100
  xlabel 'foo'
  ylabel 'bar'
  title 'bar plot'
end
bar.render("sample_images/barh_gruff.png")

image

@284km

This comment has been minimized.

Copy link
Member

commented May 14, 2019

I examined a little and understood.
labels is required with SideBar as follows.

https://www.rubydoc.info/github/topfunky/gruff/Gruff/Base#labels-instance_method

I think that p.labels = {nil=>nil} is good as the first step. In this case, labael is not displayed like this.

graph_no_label

For example, when a label is set, it is displayed like this. I think it would be better if we could support label as well.

# e.g.

require 'gruff'
p = Gruff::SideBar.new
p.title = "sample title"
p.x_axis_label = "x label"
p.y_axis_label = "y label"
p.data(data.label, data.xs.to_a)
p.data("sample1", [0,1,2,3,4])
p.data("sample2", [0,1,2,3,4])
p.data("sample3", [0,1,2,3,4,5,6,7,8])
p.labels = {0 => "label0", 1 => "label1", 2 => "label2", 5 => "label5", 8 => "label8", 9 => "label9"}
p.write

graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.