lumean / svg-graph2

SVG:::Graph is a pure Ruby library for generating charts, which are a type of graph where the values of one axis are not scalar. SVG::Graph has a verry similar API to the Perl library SVG::TT::Graph, and the resulting charts also look the same. This isn't surprising, because SVG::Graph started as a loose port of SVG::TT::Graph.
Other
50 stars 20 forks source link

Pie graph often covers key / legend #1

Closed adamalbrecht closed 7 years ago

adamalbrecht commented 8 years ago

First of all, I just wanted to say thanks to @lumean for putting some effort into this gem recently. This is really the only decent ruby graphing library I have found, but it could still use some work. And I'm happy to contribute, as well, because I've been depending on it lately.

Anyway, here is my issue: Often, when I use a key and the labels are somewhat long, they get covered by the pie graph. For example:

pie_graph_example

There are a few ways this could be fixed or partially fixed:

  1. Move the pie graph left depending on the width of the key (hardest but best option, I would think)
  2. Add an option for x_offset or something similar to specify the distance from the left so that the pie could be left-aligned
  3. Add an option to add a maximum width on the key and line break any labels that are longer
  4. Add an option to right-align the key

Let me know what you think and I'm happy to contribute a pull request. Thanks!

lumean commented 8 years ago

Hi Adam, thanks for the feedback. For now I was mainly working on line and chart graphs. I agree option 1. sounds to me the right way to go. I think in addition to moving left we should then also scale the height accordingly. Maybe we could introduce option 3 as well for all kinds of graphs such that a very long legend doesnt force the graph to become too small.

lumean commented 7 years ago

@adamalbrecht can you please try if the beta version works for you? (gem install svg-graph --pre) currently I implemented option 1. I realized that it was only a minor change (using @graph_width instead of width. Some other refactoring / doc update is ongoing, see History.txt (Note some stuff is broken in the beta - not crashing, but the scale is wrong, e.g. Plot and the :scale_integers option )

lumean commented 7 years ago

Fixed in 2.0.2

adamalbrecht commented 7 years ago

Sorry I didn't get a chance to try this out until now - yes this seems to works great!

Thanks!