Class: RubyCharts::Builder
- Inherits:
-
Object
- Object
- RubyCharts::Builder
- Defined in:
- lib/ruby_charts/builder.rb
Instance Method Summary collapse
- #colors(*color_array) ⇒ Object
-
#initialize(data) ⇒ Builder
constructor
A new instance of Builder.
- #legend(position: :right) ⇒ Object
- #save(filename) ⇒ Object
- #subtitle(text) ⇒ Object
- #title(text) ⇒ Object
- #type(chart_type) ⇒ Object
Constructor Details
#initialize(data) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 9 10 11 12 |
# File 'lib/ruby_charts/builder.rb', line 5 def initialize(data) @data = data @chart_type = :bar @title = 'Chart' @subtitle = nil @colors = nil @legend = nil end |
Instance Method Details
#colors(*color_array) ⇒ Object
29 30 31 32 |
# File 'lib/ruby_charts/builder.rb', line 29 def colors(*color_array) @colors = color_array.flatten self end |
#legend(position: :right) ⇒ Object
34 35 36 37 |
# File 'lib/ruby_charts/builder.rb', line 34 def legend(position: :right) @legend = position self end |
#save(filename) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/ruby_charts/builder.rb', line 39 def save(filename) chart = build_chart chart.title(@title) chart.subtitle(@subtitle) chart.colors(*@colors) if @colors chart.legend(position: @legend) if @legend chart.save(filename) end |
#subtitle(text) ⇒ Object
24 25 26 27 |
# File 'lib/ruby_charts/builder.rb', line 24 def subtitle(text) @subtitle = text self end |
#title(text) ⇒ Object
19 20 21 22 |
# File 'lib/ruby_charts/builder.rb', line 19 def title(text) @title = text self end |
#type(chart_type) ⇒ Object
14 15 16 17 |
# File 'lib/ruby_charts/builder.rb', line 14 def type(chart_type) @chart_type = chart_type self end |