Class: Termplot::Widgets::HistogramWidget
- Inherits:
-
BaseWidget
- Object
- BaseWidget
- Termplot::Widgets::HistogramWidget
- Defined in:
- lib/termplot/widgets/histogram_widget.rb
Defined Under Namespace
Classes: Bin, PositionedBin
Constant Summary collapse
- DEFAULT_COLOR =
"green"
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Attributes inherited from BaseWidget
#bordered_window, #cols, #dataset, #decimals, #errors, #rows, #title, #window
Instance Method Summary collapse
Methods inherited from BaseWidget
Methods included from Renderable
#debug?, #render, #render_to_string
Constructor Details
This class inherits a constructor from Termplot::Widgets::BaseWidget
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
14 15 16 |
# File 'lib/termplot/widgets/histogram_widget.rb', line 14 def color @color end |
Instance Method Details
#post_initialize(opts) ⇒ Object
16 17 18 |
# File 'lib/termplot/widgets/histogram_widget.rb', line 16 def post_initialize(opts) @color = opts[:color] || DEFAULT_COLOR end |
#render_to_window ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/termplot/widgets/histogram_widget.rb', line 20 def render_to_window errors.clear window.clear window.cursor.reset_position bins = calculate_bins bins = bin_data(bins) bins = calculate_bin_coordinates(bins) calculate_axis_size(bins) render_bins(bins) window.cursor.reset_position # Title bar Termplot::Renderers::TextRenderer.new( bordered_window: bordered_window, text: title_text, row: 0, errors: errors ).render window.cursor.reset_position # Borders Termplot::Renderers::BorderRenderer.new( bordered_window: bordered_window ).render window.cursor.reset_position # Ticks render_ticks(bins) window.cursor.reset_position end |