Skip to content

Support class Array for UnicodePlot.barplot data: - and wherever else it may make sense #61

@rubyFeedback

Description

@rubyFeedback

I recently found this project. One can get a String via .to_s, without
colours, which is super-convenient for display on a webpage - so, no
clue who had this idea, but the project is a really good idea.

Now to my proposal here.

I just tried this:

require 'rbt'
array = RBT.statistics?
require 'unicode_plot'
UnicodePlot.barplot(
  data: array,
  title: 'RBT - increase in the number of programs over the years' 
    ).render

RBT.statistics? is a method in another project. It will return an Array
that has a simple two-entry structure like this:

[["25.10.2005", 274],

I then wanted to plot this.

However had, data: wants a Hash. If an array is given, it fails via:

 .gem/gems/unicode_plot-0.0.5/lib/unicode_plot/barplot.rb:134:in `Hash': can't convert Array into Hash (TypeError)

The simple solution is to pass a Hash e. g. via:

data: Hash[array],

Ok problem solved. But, I think it would be more convenient if an Array can be
given, and unicode_plot tries to convert it into a Hash instead automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions