Class: Charty::Plotters::AbstractPlotter
- Inherits:
-
Object
- Object
- Charty::Plotters::AbstractPlotter
- Defined in:
- lib/charty/plotters/abstract_plotter.rb
Direct Known Subclasses
CategoricalPlotter, DistributionPlotter, RelationalPlotter, VectorPlotter
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#color_order ⇒ Object
Returns the value of attribute color_order.
-
#data ⇒ Object
Returns the value of attribute data.
-
#key_color ⇒ Object
Returns the value of attribute key_color.
-
#palette ⇒ Object
Returns the value of attribute palette.
-
#title ⇒ Object
Returns the value of attribute title.
-
#x ⇒ Object
Returns the value of attribute x.
-
#x_label ⇒ Object
Returns the value of attribute x_label.
-
#y ⇒ Object
Returns the value of attribute y.
-
#y_label ⇒ Object
Returns the value of attribute y_label.
Instance Method Summary collapse
-
#initialize(x, y, color, **options) {|_self| ... } ⇒ AbstractPlotter
constructor
A new instance of AbstractPlotter.
- #inspect ⇒ Object
- #processed_data ⇒ Object
- #render(notebook: false, **kwargs) ⇒ Object
- #save(filename, **kwargs) ⇒ Object
- #to_iruby ⇒ Object
- #to_iruby_mimebundle(include: [], exclude: []) ⇒ Object
- #var_levels ⇒ Object
Constructor Details
#initialize(x, y, color, **options) {|_self| ... } ⇒ AbstractPlotter
Returns a new instance of AbstractPlotter.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 4 def initialize(x, y, color, **) self.x = x self.y = y self.color = color self.data = data self.palette = palette () @var_levels = {} @var_ordered = {x: false, y: false} yield self if block_given? end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
18 19 20 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 18 def color @color end |
#color_order ⇒ Object
Returns the value of attribute color_order.
19 20 21 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 19 def color_order @color_order end |
#data ⇒ Object
Returns the value of attribute data.
18 19 20 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 18 def data @data end |
#key_color ⇒ Object
Returns the value of attribute key_color.
19 20 21 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 19 def key_color @key_color end |
#palette ⇒ Object
Returns the value of attribute palette.
19 20 21 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 19 def palette @palette end |
#title ⇒ Object
Returns the value of attribute title.
98 99 100 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 98 def title @title end |
#x ⇒ Object
Returns the value of attribute x.
18 19 20 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 18 def x @x end |
#x_label ⇒ Object
Returns the value of attribute x_label.
86 87 88 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 86 def x_label @x_label end |
#y ⇒ Object
Returns the value of attribute y.
18 19 20 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 18 def y @y end |
#y_label ⇒ Object
Returns the value of attribute y_label.
92 93 94 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 92 def y_label @y_label end |
Instance Method Details
#inspect ⇒ Object
33 34 35 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 33 def inspect "#<#{self.class}:0x%016x>" % self.object_id end |
#processed_data ⇒ Object
237 238 239 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 237 def processed_data @processed_data ||= calculate_processed_data end |
#render(notebook: false, **kwargs) ⇒ Object
252 253 254 255 256 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 252 def render(notebook: false, **kwargs) backend = Backends.current call_render_plot(backend, notebook: notebook, **kwargs) backend.render(notebook: notebook, **kwargs) end |
#save(filename, **kwargs) ⇒ Object
246 247 248 249 250 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 246 def save(filename, **kwargs) backend = Backends.current call_render_plot(backend, notebook: false, **kwargs) backend.save(filename, **kwargs) end |
#to_iruby ⇒ Object
268 269 270 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 268 def to_iruby render(notebook: IRubyHelper.iruby_notebook?) end |
#to_iruby_mimebundle(include: [], exclude: []) ⇒ Object
272 273 274 275 276 277 278 279 280 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 272 def to_iruby_mimebundle(include: [], exclude: []) backend = Backends.current if backend.respond_to?(:render_mimebundle) call_render_plot(backend, notebook: true) backend.render_mimebundle(include: include, exclude: exclude) else {} end end |
#var_levels ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/charty/plotters/abstract_plotter.rb', line 21 def var_levels variables.each_key do |var| # TODO: Move mappers from RelationalPlotter to here, # and remove the use of instance_variable_get if instance_variable_defined?(:"@#{var}_mapper") mapper = instance_variable_get(:"@#{var}_mapper") @var_levels[var] = mapper.levels end end @var_levels end |