class

Opal::UI::BarChart

Inherits Opal::UI::Element < Opal::UI::Themable < Reference < Object

Renders horizontal bar charts with labels, percentage scaling, and values.

Constructors

new(items : Array(BarItem) = [] of BarItem, title : String | Nil = nil, bar_char : Char = '█', max_value : Float64 | Nil = nil)
Source

Class methods

to_string(items : Array(BarItem), title : String | Nil = nil, width : Int32 | Nil = nil, bar_char : Char = '█', max_value : Float64 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Class convenience method returning styled barchart string

Source
to_string(raw_items : Array(Tuple(String, Float64)), title : String | Nil = nil, width : Int32 | Nil = nil, bar_char : Char = '█', max_value : Float64 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Overload accepting tuples of {label, value}

Source

Instance methods

add(label : String, value : Float64, color : Color | Symbol | String = :cyan, formatted_value : String | Nil = nil) : Nil
Source
bar_char
Source
items
Source
max_value
Source
preferred_print_size(available_w : Int32) : Tuple(Int32, Int32)

Preferred size in print mode: full item count plus title lines

Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
title
Source