red-data-tools / unicode_plot.rb

Plot your data by Unicode characters
MIT License
246 stars 12 forks source link

Ad-hoc changing the colours + document this in the README #62

Open rubyFeedback opened 1 year ago

rubyFeedback commented 1 year ago

What if all APIs, such as UnicodePlot.barplot(), also support an argument called colors?

For instance:

UnicodePlot.barplot(data: {'foo': 20, 'bar': 50}, colors: "steelblue").render

This would use steelblue rather than green (the default).

Right now this leads to an error:

.gem/gems/unicode_plot-0.0.5/lib/unicode_plot/plot.rb:10:in `initialize': unknown
 keyword: :colors (ArgumentError)

We could also fine-tune this perhaps ... if colors: is too generic, we could say main_color: or foreground_color or color1: color2: and so on. Being able to pass it in directly via a Hash is the important part here. That way we can fine-tune the APIs here, to different use cases. Perhaps even to render them as HTML "strings" (e. g. via CSS actually; my idea here is to allow for this to be used in a web-page as-is, a "drop in" replacement).